openai 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,17 +18,82 @@ module OpenAI
18
18
  sig { returns(String) }
19
19
  attr_accessor :id
20
20
 
21
+ # If a content parts array was provided, this is an array of `text` and
22
+ # `image_url` parts. Otherwise, null.
23
+ sig do
24
+ returns(
25
+ T.nilable(
26
+ T::Array[
27
+ OpenAI::Chat::ChatCompletionStoreMessage::ContentPart::Variants
28
+ ]
29
+ )
30
+ )
31
+ end
32
+ attr_accessor :content_parts
33
+
21
34
  # A chat completion message generated by the model.
22
- sig { params(id: String).returns(T.attached_class) }
35
+ sig do
36
+ params(
37
+ id: String,
38
+ content_parts:
39
+ T.nilable(
40
+ T::Array[
41
+ T.any(
42
+ OpenAI::Chat::ChatCompletionContentPartText::OrHash,
43
+ OpenAI::Chat::ChatCompletionContentPartImage::OrHash
44
+ )
45
+ ]
46
+ )
47
+ ).returns(T.attached_class)
48
+ end
23
49
  def self.new(
24
50
  # The identifier of the chat message.
25
- id:
51
+ id:,
52
+ # If a content parts array was provided, this is an array of `text` and
53
+ # `image_url` parts. Otherwise, null.
54
+ content_parts: nil
26
55
  )
27
56
  end
28
57
 
29
- sig { override.returns({ id: String }) }
58
+ sig do
59
+ override.returns(
60
+ {
61
+ id: String,
62
+ content_parts:
63
+ T.nilable(
64
+ T::Array[
65
+ OpenAI::Chat::ChatCompletionStoreMessage::ContentPart::Variants
66
+ ]
67
+ )
68
+ }
69
+ )
70
+ end
30
71
  def to_hash
31
72
  end
73
+
74
+ # Learn about
75
+ # [text inputs](https://platform.openai.com/docs/guides/text-generation).
76
+ module ContentPart
77
+ extend OpenAI::Internal::Type::Union
78
+
79
+ Variants =
80
+ T.type_alias do
81
+ T.any(
82
+ OpenAI::Chat::ChatCompletionContentPartText,
83
+ OpenAI::Chat::ChatCompletionContentPartImage
84
+ )
85
+ end
86
+
87
+ sig do
88
+ override.returns(
89
+ T::Array[
90
+ OpenAI::Chat::ChatCompletionStoreMessage::ContentPart::Variants
91
+ ]
92
+ )
93
+ end
94
+ def self.variants
95
+ end
96
+ end
32
97
  end
33
98
  end
34
99
  end
@@ -216,6 +216,15 @@ module OpenAI
216
216
  sig { returns(T.nilable(Float)) }
217
217
  attr_accessor :presence_penalty
218
218
 
219
+ # Used by OpenAI to cache responses for similar requests to optimize your cache
220
+ # hit rates. Replaces the `user` field.
221
+ # [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
222
+ sig { returns(T.nilable(String)) }
223
+ attr_reader :prompt_cache_key
224
+
225
+ sig { params(prompt_cache_key: String).void }
226
+ attr_writer :prompt_cache_key
227
+
219
228
  # **o-series models only**
220
229
  #
221
230
  # Constrains effort on reasoning for
@@ -262,6 +271,17 @@ module OpenAI
262
271
  end
263
272
  attr_writer :response_format
264
273
 
274
+ # A stable identifier used to help detect users of your application that may be
275
+ # violating OpenAI's usage policies. The IDs should be a string that uniquely
276
+ # identifies each user. We recommend hashing their username or email address, in
277
+ # order to avoid sending us any identifying information.
278
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
279
+ sig { returns(T.nilable(String)) }
280
+ attr_reader :safety_identifier
281
+
282
+ sig { params(safety_identifier: String).void }
283
+ attr_writer :safety_identifier
284
+
265
285
  # This feature is in Beta. If specified, our system will make a best effort to
266
286
  # sample deterministically, such that repeated requests with the same `seed` and
267
287
  # parameters should return the same result. Determinism is not guaranteed, and you
@@ -399,9 +419,11 @@ module OpenAI
399
419
  sig { returns(T.nilable(Float)) }
400
420
  attr_accessor :top_p
401
421
 
402
- # A stable identifier for your end-users. Used to boost cache hit rates by better
403
- # bucketing similar requests and to help OpenAI detect and prevent abuse.
404
- # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
422
+ # This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
423
+ # `prompt_cache_key` instead to maintain caching optimizations. A stable
424
+ # identifier for your end-users. Used to boost cache hit rates by better bucketing
425
+ # similar requests and to help OpenAI detect and prevent abuse.
426
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
405
427
  sig { returns(T.nilable(String)) }
406
428
  attr_reader :user
407
429
 
@@ -465,6 +487,7 @@ module OpenAI
465
487
  prediction:
466
488
  T.nilable(OpenAI::Chat::ChatCompletionPredictionContent::OrHash),
467
489
  presence_penalty: T.nilable(Float),
490
+ prompt_cache_key: String,
468
491
  reasoning_effort: T.nilable(OpenAI::ReasoningEffort::OrSymbol),
469
492
  response_format:
470
493
  T.any(
@@ -473,6 +496,7 @@ module OpenAI
473
496
  OpenAI::StructuredOutput::JsonSchemaConverter,
474
497
  OpenAI::ResponseFormatJSONObject::OrHash
475
498
  ),
499
+ safety_identifier: String,
476
500
  seed: T.nilable(Integer),
477
501
  service_tier:
478
502
  T.nilable(
@@ -603,6 +627,10 @@ module OpenAI
603
627
  # whether they appear in the text so far, increasing the model's likelihood to
604
628
  # talk about new topics.
605
629
  presence_penalty: nil,
630
+ # Used by OpenAI to cache responses for similar requests to optimize your cache
631
+ # hit rates. Replaces the `user` field.
632
+ # [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
633
+ prompt_cache_key: nil,
606
634
  # **o-series models only**
607
635
  #
608
636
  # Constrains effort on reasoning for
@@ -621,6 +649,12 @@ module OpenAI
621
649
  # ensures the message the model generates is valid JSON. Using `json_schema` is
622
650
  # preferred for models that support it.
623
651
  response_format: nil,
652
+ # A stable identifier used to help detect users of your application that may be
653
+ # violating OpenAI's usage policies. The IDs should be a string that uniquely
654
+ # identifies each user. We recommend hashing their username or email address, in
655
+ # order to avoid sending us any identifying information.
656
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
657
+ safety_identifier: nil,
624
658
  # This feature is in Beta. If specified, our system will make a best effort to
625
659
  # sample deterministically, such that repeated requests with the same `seed` and
626
660
  # parameters should return the same result. Determinism is not guaranteed, and you
@@ -687,9 +721,11 @@ module OpenAI
687
721
  #
688
722
  # We generally recommend altering this or `temperature` but not both.
689
723
  top_p: nil,
690
- # A stable identifier for your end-users. Used to boost cache hit rates by better
691
- # bucketing similar requests and to help OpenAI detect and prevent abuse.
692
- # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
724
+ # This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
725
+ # `prompt_cache_key` instead to maintain caching optimizations. A stable
726
+ # identifier for your end-users. Used to boost cache hit rates by better bucketing
727
+ # similar requests and to help OpenAI detect and prevent abuse.
728
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
693
729
  user: nil,
694
730
  # This tool searches the web for relevant results to use in a response. Learn more
695
731
  # about the
@@ -739,6 +775,7 @@ module OpenAI
739
775
  prediction:
740
776
  T.nilable(OpenAI::Chat::ChatCompletionPredictionContent),
741
777
  presence_penalty: T.nilable(Float),
778
+ prompt_cache_key: String,
742
779
  reasoning_effort: T.nilable(OpenAI::ReasoningEffort::OrSymbol),
743
780
  response_format:
744
781
  T.any(
@@ -746,6 +783,7 @@ module OpenAI
746
783
  OpenAI::ResponseFormatJSONSchema,
747
784
  OpenAI::ResponseFormatJSONObject
748
785
  ),
786
+ safety_identifier: String,
749
787
  seed: T.nilable(Integer),
750
788
  service_tier:
751
789
  T.nilable(
@@ -165,6 +165,15 @@ module OpenAI
165
165
  end
166
166
  attr_writer :prompt
167
167
 
168
+ # Used by OpenAI to cache responses for similar requests to optimize your cache
169
+ # hit rates. Replaces the `user` field.
170
+ # [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
171
+ sig { returns(T.nilable(String)) }
172
+ attr_reader :prompt_cache_key
173
+
174
+ sig { params(prompt_cache_key: String).void }
175
+ attr_writer :prompt_cache_key
176
+
168
177
  # **o-series models only**
169
178
  #
170
179
  # Configuration options for
@@ -175,6 +184,17 @@ module OpenAI
175
184
  sig { params(reasoning: T.nilable(OpenAI::Reasoning::OrHash)).void }
176
185
  attr_writer :reasoning
177
186
 
187
+ # A stable identifier used to help detect users of your application that may be
188
+ # violating OpenAI's usage policies. The IDs should be a string that uniquely
189
+ # identifies each user. We recommend hashing their username or email address, in
190
+ # order to avoid sending us any identifying information.
191
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
192
+ sig { returns(T.nilable(String)) }
193
+ attr_reader :safety_identifier
194
+
195
+ sig { params(safety_identifier: String).void }
196
+ attr_writer :safety_identifier
197
+
178
198
  # Specifies the processing type used for serving the request.
179
199
  #
180
200
  # - If set to 'auto', then the request will be processed with the service tier
@@ -247,9 +267,11 @@ module OpenAI
247
267
  sig { params(usage: OpenAI::Responses::ResponseUsage::OrHash).void }
248
268
  attr_writer :usage
249
269
 
250
- # A stable identifier for your end-users. Used to boost cache hit rates by better
251
- # bucketing similar requests and to help OpenAI detect and prevent abuse.
252
- # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
270
+ # This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
271
+ # `prompt_cache_key` instead to maintain caching optimizations. A stable
272
+ # identifier for your end-users. Used to boost cache hit rates by better bucketing
273
+ # similar requests and to help OpenAI detect and prevent abuse.
274
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
253
275
  sig { returns(T.nilable(String)) }
254
276
  attr_reader :user
255
277
 
@@ -317,7 +339,9 @@ module OpenAI
317
339
  max_tool_calls: T.nilable(Integer),
318
340
  previous_response_id: T.nilable(String),
319
341
  prompt: T.nilable(OpenAI::Responses::ResponsePrompt::OrHash),
342
+ prompt_cache_key: String,
320
343
  reasoning: T.nilable(OpenAI::Reasoning::OrHash),
344
+ safety_identifier: String,
321
345
  service_tier:
322
346
  T.nilable(OpenAI::Responses::Response::ServiceTier::OrSymbol),
323
347
  status: OpenAI::Responses::ResponseStatus::OrSymbol,
@@ -417,11 +441,21 @@ module OpenAI
417
441
  # Reference to a prompt template and its variables.
418
442
  # [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
419
443
  prompt: nil,
444
+ # Used by OpenAI to cache responses for similar requests to optimize your cache
445
+ # hit rates. Replaces the `user` field.
446
+ # [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
447
+ prompt_cache_key: nil,
420
448
  # **o-series models only**
421
449
  #
422
450
  # Configuration options for
423
451
  # [reasoning models](https://platform.openai.com/docs/guides/reasoning).
424
452
  reasoning: nil,
453
+ # A stable identifier used to help detect users of your application that may be
454
+ # violating OpenAI's usage policies. The IDs should be a string that uniquely
455
+ # identifies each user. We recommend hashing their username or email address, in
456
+ # order to avoid sending us any identifying information.
457
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
458
+ safety_identifier: nil,
425
459
  # Specifies the processing type used for serving the request.
426
460
  #
427
461
  # - If set to 'auto', then the request will be processed with the service tier
@@ -463,9 +497,11 @@ module OpenAI
463
497
  # Represents token usage details including input tokens, output tokens, a
464
498
  # breakdown of output tokens, and the total tokens used.
465
499
  usage: nil,
466
- # A stable identifier for your end-users. Used to boost cache hit rates by better
467
- # bucketing similar requests and to help OpenAI detect and prevent abuse.
468
- # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
500
+ # This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
501
+ # `prompt_cache_key` instead to maintain caching optimizations. A stable
502
+ # identifier for your end-users. Used to boost cache hit rates by better bucketing
503
+ # similar requests and to help OpenAI detect and prevent abuse.
504
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
469
505
  user: nil,
470
506
  # The object type of this resource - always set to `response`.
471
507
  object: :response
@@ -496,7 +532,9 @@ module OpenAI
496
532
  max_tool_calls: T.nilable(Integer),
497
533
  previous_response_id: T.nilable(String),
498
534
  prompt: T.nilable(OpenAI::Responses::ResponsePrompt),
535
+ prompt_cache_key: String,
499
536
  reasoning: T.nilable(OpenAI::Reasoning),
537
+ safety_identifier: String,
500
538
  service_tier:
501
539
  T.nilable(
502
540
  OpenAI::Responses::Response::ServiceTier::TaggedSymbol
@@ -148,6 +148,15 @@ module OpenAI
148
148
  end
149
149
  attr_writer :prompt
150
150
 
151
+ # Used by OpenAI to cache responses for similar requests to optimize your cache
152
+ # hit rates. Replaces the `user` field.
153
+ # [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
154
+ sig { returns(T.nilable(String)) }
155
+ attr_reader :prompt_cache_key
156
+
157
+ sig { params(prompt_cache_key: String).void }
158
+ attr_writer :prompt_cache_key
159
+
151
160
  # **o-series models only**
152
161
  #
153
162
  # Configuration options for
@@ -158,6 +167,17 @@ module OpenAI
158
167
  sig { params(reasoning: T.nilable(OpenAI::Reasoning::OrHash)).void }
159
168
  attr_writer :reasoning
160
169
 
170
+ # A stable identifier used to help detect users of your application that may be
171
+ # violating OpenAI's usage policies. The IDs should be a string that uniquely
172
+ # identifies each user. We recommend hashing their username or email address, in
173
+ # order to avoid sending us any identifying information.
174
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
175
+ sig { returns(T.nilable(String)) }
176
+ attr_reader :safety_identifier
177
+
178
+ sig { params(safety_identifier: String).void }
179
+ attr_writer :safety_identifier
180
+
161
181
  # Specifies the processing type used for serving the request.
162
182
  #
163
183
  # - If set to 'auto', then the request will be processed with the service tier
@@ -326,9 +346,11 @@ module OpenAI
326
346
  end
327
347
  attr_accessor :truncation
328
348
 
329
- # A stable identifier for your end-users. Used to boost cache hit rates by better
330
- # bucketing similar requests and to help OpenAI detect and prevent abuse.
331
- # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
349
+ # This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
350
+ # `prompt_cache_key` instead to maintain caching optimizations. A stable
351
+ # identifier for your end-users. Used to boost cache hit rates by better bucketing
352
+ # similar requests and to help OpenAI detect and prevent abuse.
353
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
332
354
  sig { returns(T.nilable(String)) }
333
355
  attr_reader :user
334
356
 
@@ -356,7 +378,9 @@ module OpenAI
356
378
  parallel_tool_calls: T.nilable(T::Boolean),
357
379
  previous_response_id: T.nilable(String),
358
380
  prompt: T.nilable(OpenAI::Responses::ResponsePrompt::OrHash),
381
+ prompt_cache_key: String,
359
382
  reasoning: T.nilable(OpenAI::Reasoning::OrHash),
383
+ safety_identifier: String,
360
384
  service_tier:
361
385
  T.nilable(
362
386
  OpenAI::Responses::ResponseCreateParams::ServiceTier::OrSymbol
@@ -462,11 +486,21 @@ module OpenAI
462
486
  # Reference to a prompt template and its variables.
463
487
  # [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
464
488
  prompt: nil,
489
+ # Used by OpenAI to cache responses for similar requests to optimize your cache
490
+ # hit rates. Replaces the `user` field.
491
+ # [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
492
+ prompt_cache_key: nil,
465
493
  # **o-series models only**
466
494
  #
467
495
  # Configuration options for
468
496
  # [reasoning models](https://platform.openai.com/docs/guides/reasoning).
469
497
  reasoning: nil,
498
+ # A stable identifier used to help detect users of your application that may be
499
+ # violating OpenAI's usage policies. The IDs should be a string that uniquely
500
+ # identifies each user. We recommend hashing their username or email address, in
501
+ # order to avoid sending us any identifying information.
502
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
503
+ safety_identifier: nil,
470
504
  # Specifies the processing type used for serving the request.
471
505
  #
472
506
  # - If set to 'auto', then the request will be processed with the service tier
@@ -534,9 +568,11 @@ module OpenAI
534
568
  # - `disabled` (default): If a model response will exceed the context window size
535
569
  # for a model, the request will fail with a 400 error.
536
570
  truncation: nil,
537
- # A stable identifier for your end-users. Used to boost cache hit rates by better
538
- # bucketing similar requests and to help OpenAI detect and prevent abuse.
539
- # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
571
+ # This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
572
+ # `prompt_cache_key` instead to maintain caching optimizations. A stable
573
+ # identifier for your end-users. Used to boost cache hit rates by better bucketing
574
+ # similar requests and to help OpenAI detect and prevent abuse.
575
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
540
576
  user: nil,
541
577
  request_options: {}
542
578
  )
@@ -564,7 +600,9 @@ module OpenAI
564
600
  parallel_tool_calls: T.nilable(T::Boolean),
565
601
  previous_response_id: T.nilable(String),
566
602
  prompt: T.nilable(OpenAI::Responses::ResponsePrompt),
603
+ prompt_cache_key: String,
567
604
  reasoning: T.nilable(OpenAI::Reasoning),
605
+ safety_identifier: String,
568
606
  service_tier:
569
607
  T.nilable(
570
608
  OpenAI::Responses::ResponseCreateParams::ServiceTier::OrSymbol
@@ -65,6 +65,7 @@ module OpenAI
65
65
  prediction:
66
66
  T.nilable(OpenAI::Chat::ChatCompletionPredictionContent::OrHash),
67
67
  presence_penalty: T.nilable(Float),
68
+ prompt_cache_key: String,
68
69
  reasoning_effort: T.nilable(OpenAI::ReasoningEffort::OrSymbol),
69
70
  response_format:
70
71
  T.any(
@@ -73,6 +74,7 @@ module OpenAI
73
74
  OpenAI::StructuredOutput::JsonSchemaConverter,
74
75
  OpenAI::ResponseFormatJSONObject::OrHash
75
76
  ),
77
+ safety_identifier: String,
76
78
  seed: T.nilable(Integer),
77
79
  service_tier:
78
80
  T.nilable(
@@ -204,6 +206,10 @@ module OpenAI
204
206
  # whether they appear in the text so far, increasing the model's likelihood to
205
207
  # talk about new topics.
206
208
  presence_penalty: nil,
209
+ # Used by OpenAI to cache responses for similar requests to optimize your cache
210
+ # hit rates. Replaces the `user` field.
211
+ # [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
212
+ prompt_cache_key: nil,
207
213
  # **o-series models only**
208
214
  #
209
215
  # Constrains effort on reasoning for
@@ -222,6 +228,12 @@ module OpenAI
222
228
  # ensures the message the model generates is valid JSON. Using `json_schema` is
223
229
  # preferred for models that support it.
224
230
  response_format: nil,
231
+ # A stable identifier used to help detect users of your application that may be
232
+ # violating OpenAI's usage policies. The IDs should be a string that uniquely
233
+ # identifies each user. We recommend hashing their username or email address, in
234
+ # order to avoid sending us any identifying information.
235
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
236
+ safety_identifier: nil,
225
237
  # This feature is in Beta. If specified, our system will make a best effort to
226
238
  # sample deterministically, such that repeated requests with the same `seed` and
227
239
  # parameters should return the same result. Determinism is not guaranteed, and you
@@ -288,9 +300,11 @@ module OpenAI
288
300
  #
289
301
  # We generally recommend altering this or `temperature` but not both.
290
302
  top_p: nil,
291
- # A stable identifier for your end-users. Used to boost cache hit rates by better
292
- # bucketing similar requests and to help OpenAI detect and prevent abuse.
293
- # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
303
+ # This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
304
+ # `prompt_cache_key` instead to maintain caching optimizations. A stable
305
+ # identifier for your end-users. Used to boost cache hit rates by better bucketing
306
+ # similar requests and to help OpenAI detect and prevent abuse.
307
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
294
308
  user: nil,
295
309
  # This tool searches the web for relevant results to use in a response. Learn more
296
310
  # about the
@@ -361,6 +375,7 @@ module OpenAI
361
375
  prediction:
362
376
  T.nilable(OpenAI::Chat::ChatCompletionPredictionContent::OrHash),
363
377
  presence_penalty: T.nilable(Float),
378
+ prompt_cache_key: String,
364
379
  reasoning_effort: T.nilable(OpenAI::ReasoningEffort::OrSymbol),
365
380
  response_format:
366
381
  T.any(
@@ -368,6 +383,7 @@ module OpenAI
368
383
  OpenAI::ResponseFormatJSONSchema::OrHash,
369
384
  OpenAI::ResponseFormatJSONObject::OrHash
370
385
  ),
386
+ safety_identifier: String,
371
387
  seed: T.nilable(Integer),
372
388
  service_tier:
373
389
  T.nilable(
@@ -493,6 +509,10 @@ module OpenAI
493
509
  # whether they appear in the text so far, increasing the model's likelihood to
494
510
  # talk about new topics.
495
511
  presence_penalty: nil,
512
+ # Used by OpenAI to cache responses for similar requests to optimize your cache
513
+ # hit rates. Replaces the `user` field.
514
+ # [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
515
+ prompt_cache_key: nil,
496
516
  # **o-series models only**
497
517
  #
498
518
  # Constrains effort on reasoning for
@@ -511,6 +531,12 @@ module OpenAI
511
531
  # ensures the message the model generates is valid JSON. Using `json_schema` is
512
532
  # preferred for models that support it.
513
533
  response_format: nil,
534
+ # A stable identifier used to help detect users of your application that may be
535
+ # violating OpenAI's usage policies. The IDs should be a string that uniquely
536
+ # identifies each user. We recommend hashing their username or email address, in
537
+ # order to avoid sending us any identifying information.
538
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
539
+ safety_identifier: nil,
514
540
  # This feature is in Beta. If specified, our system will make a best effort to
515
541
  # sample deterministically, such that repeated requests with the same `seed` and
516
542
  # parameters should return the same result. Determinism is not guaranteed, and you
@@ -577,9 +603,11 @@ module OpenAI
577
603
  #
578
604
  # We generally recommend altering this or `temperature` but not both.
579
605
  top_p: nil,
580
- # A stable identifier for your end-users. Used to boost cache hit rates by better
581
- # bucketing similar requests and to help OpenAI detect and prevent abuse.
582
- # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
606
+ # This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
607
+ # `prompt_cache_key` instead to maintain caching optimizations. A stable
608
+ # identifier for your end-users. Used to boost cache hit rates by better bucketing
609
+ # similar requests and to help OpenAI detect and prevent abuse.
610
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
583
611
  user: nil,
584
612
  # This tool searches the web for relevant results to use in a response. Learn more
585
613
  # about the
@@ -40,7 +40,9 @@ module OpenAI
40
40
  parallel_tool_calls: T.nilable(T::Boolean),
41
41
  previous_response_id: T.nilable(String),
42
42
  prompt: T.nilable(OpenAI::Responses::ResponsePrompt::OrHash),
43
+ prompt_cache_key: String,
43
44
  reasoning: T.nilable(OpenAI::Reasoning::OrHash),
45
+ safety_identifier: String,
44
46
  service_tier:
45
47
  T.nilable(
46
48
  OpenAI::Responses::ResponseCreateParams::ServiceTier::OrSymbol
@@ -151,11 +153,21 @@ module OpenAI
151
153
  # Reference to a prompt template and its variables.
152
154
  # [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
153
155
  prompt: nil,
156
+ # Used by OpenAI to cache responses for similar requests to optimize your cache
157
+ # hit rates. Replaces the `user` field.
158
+ # [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
159
+ prompt_cache_key: nil,
154
160
  # **o-series models only**
155
161
  #
156
162
  # Configuration options for
157
163
  # [reasoning models](https://platform.openai.com/docs/guides/reasoning).
158
164
  reasoning: nil,
165
+ # A stable identifier used to help detect users of your application that may be
166
+ # violating OpenAI's usage policies. The IDs should be a string that uniquely
167
+ # identifies each user. We recommend hashing their username or email address, in
168
+ # order to avoid sending us any identifying information.
169
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
170
+ safety_identifier: nil,
159
171
  # Specifies the processing type used for serving the request.
160
172
  #
161
173
  # - If set to 'auto', then the request will be processed with the service tier
@@ -223,9 +235,11 @@ module OpenAI
223
235
  # - `disabled` (default): If a model response will exceed the context window size
224
236
  # for a model, the request will fail with a 400 error.
225
237
  truncation: nil,
226
- # A stable identifier for your end-users. Used to boost cache hit rates by better
227
- # bucketing similar requests and to help OpenAI detect and prevent abuse.
228
- # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
238
+ # This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
239
+ # `prompt_cache_key` instead to maintain caching optimizations. A stable
240
+ # identifier for your end-users. Used to boost cache hit rates by better bucketing
241
+ # similar requests and to help OpenAI detect and prevent abuse.
242
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
229
243
  user: nil,
230
244
  # There is no need to provide `stream:`. Instead, use `#stream_raw` or `#create`
231
245
  # for streaming and non-streaming use cases, respectively.
@@ -268,7 +282,9 @@ module OpenAI
268
282
  parallel_tool_calls: T.nilable(T::Boolean),
269
283
  previous_response_id: T.nilable(String),
270
284
  prompt: T.nilable(OpenAI::Responses::ResponsePrompt::OrHash),
285
+ prompt_cache_key: String,
271
286
  reasoning: T.nilable(OpenAI::Reasoning::OrHash),
287
+ safety_identifier: String,
272
288
  service_tier:
273
289
  T.nilable(
274
290
  OpenAI::Responses::ResponseCreateParams::ServiceTier::OrSymbol
@@ -385,11 +401,21 @@ module OpenAI
385
401
  # Reference to a prompt template and its variables.
386
402
  # [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
387
403
  prompt: nil,
404
+ # Used by OpenAI to cache responses for similar requests to optimize your cache
405
+ # hit rates. Replaces the `user` field.
406
+ # [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
407
+ prompt_cache_key: nil,
388
408
  # **o-series models only**
389
409
  #
390
410
  # Configuration options for
391
411
  # [reasoning models](https://platform.openai.com/docs/guides/reasoning).
392
412
  reasoning: nil,
413
+ # A stable identifier used to help detect users of your application that may be
414
+ # violating OpenAI's usage policies. The IDs should be a string that uniquely
415
+ # identifies each user. We recommend hashing their username or email address, in
416
+ # order to avoid sending us any identifying information.
417
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
418
+ safety_identifier: nil,
393
419
  # Specifies the processing type used for serving the request.
394
420
  #
395
421
  # - If set to 'auto', then the request will be processed with the service tier
@@ -457,9 +483,11 @@ module OpenAI
457
483
  # - `disabled` (default): If a model response will exceed the context window size
458
484
  # for a model, the request will fail with a 400 error.
459
485
  truncation: nil,
460
- # A stable identifier for your end-users. Used to boost cache hit rates by better
461
- # bucketing similar requests and to help OpenAI detect and prevent abuse.
462
- # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
486
+ # This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
487
+ # `prompt_cache_key` instead to maintain caching optimizations. A stable
488
+ # identifier for your end-users. Used to boost cache hit rates by better bucketing
489
+ # similar requests and to help OpenAI detect and prevent abuse.
490
+ # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
463
491
  user: nil,
464
492
  # There is no need to provide `stream:`. Instead, use `#stream_raw` or `#create`
465
493
  # for streaming and non-streaming use cases, respectively.
@@ -3,16 +3,42 @@ module OpenAI
3
3
  class ChatCompletionStoreMessage = Chat::ChatCompletionStoreMessage
4
4
 
5
5
  module Chat
6
- type chat_completion_store_message = { id: String }
6
+ type chat_completion_store_message =
7
+ {
8
+ id: String,
9
+ content_parts: ::Array[OpenAI::Models::Chat::ChatCompletionStoreMessage::content_part]?
10
+ }
7
11
 
8
12
  class ChatCompletionStoreMessage < OpenAI::Models::Chat::ChatCompletionMessage
9
13
  def id: -> String
10
14
 
11
15
  def id=: (String _) -> String
12
16
 
13
- def initialize: (id: String) -> void
17
+ def content_parts: -> ::Array[OpenAI::Models::Chat::ChatCompletionStoreMessage::content_part]?
14
18
 
15
- def to_hash: -> { id: String }
19
+ def content_parts=: (
20
+ ::Array[OpenAI::Models::Chat::ChatCompletionStoreMessage::content_part]? _
21
+ ) -> ::Array[OpenAI::Models::Chat::ChatCompletionStoreMessage::content_part]?
22
+
23
+ def initialize: (
24
+ id: String,
25
+ ?content_parts: ::Array[OpenAI::Models::Chat::ChatCompletionStoreMessage::content_part]?
26
+ ) -> void
27
+
28
+ def to_hash: -> {
29
+ id: String,
30
+ content_parts: ::Array[OpenAI::Models::Chat::ChatCompletionStoreMessage::content_part]?
31
+ }
32
+
33
+ type content_part =
34
+ OpenAI::Chat::ChatCompletionContentPartText
35
+ | OpenAI::Chat::ChatCompletionContentPartImage
36
+
37
+ module ContentPart
38
+ extend OpenAI::Internal::Type::Union
39
+
40
+ def self?.variants: -> ::Array[OpenAI::Models::Chat::ChatCompletionStoreMessage::content_part]
41
+ end
16
42
  end
17
43
  end
18
44
  end