openai 0.34.1 → 0.35.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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -0
  3. data/README.md +1 -1
  4. data/lib/openai/internal/transport/base_client.rb +7 -1
  5. data/lib/openai/internal/transport/pooled_net_requester.rb +30 -24
  6. data/lib/openai/models/custom_tool_input_format.rb +6 -0
  7. data/lib/openai/models/image_edit_params.rb +1 -1
  8. data/lib/openai/models/realtime/realtime_session_create_request.rb +14 -3
  9. data/lib/openai/models/realtime/realtime_session_create_response.rb +15 -4
  10. data/lib/openai/models/realtime/realtime_tracing_config.rb +1 -1
  11. data/lib/openai/models/realtime/realtime_truncation.rb +13 -2
  12. data/lib/openai/models/realtime/realtime_truncation_retention_ratio.rb +38 -4
  13. data/lib/openai/models/reasoning.rb +4 -0
  14. data/lib/openai/models/responses/custom_tool.rb +3 -0
  15. data/lib/openai/models/responses/easy_input_message.rb +3 -3
  16. data/lib/openai/models/responses/file_search_tool.rb +33 -1
  17. data/lib/openai/models/responses/response_content.rb +1 -4
  18. data/lib/openai/models/responses/response_input_content.rb +1 -4
  19. data/lib/openai/models/responses/response_input_item.rb +2 -2
  20. data/lib/openai/models/responses/response_input_message_item.rb +2 -2
  21. data/lib/openai/models/responses/response_output_text.rb +8 -8
  22. data/lib/openai/models/responses/tool.rb +30 -2
  23. data/lib/openai/models/vector_stores/file_batch_create_params.rb +77 -11
  24. data/lib/openai/models/video.rb +9 -1
  25. data/lib/openai/resources/files.rb +13 -14
  26. data/lib/openai/resources/images.rb +2 -2
  27. data/lib/openai/resources/realtime/calls.rb +1 -1
  28. data/lib/openai/resources/responses.rb +4 -0
  29. data/lib/openai/resources/vector_stores/file_batches.rb +6 -4
  30. data/lib/openai/version.rb +1 -1
  31. data/rbi/openai/internal/transport/base_client.rbi +5 -0
  32. data/rbi/openai/internal/type/base_model.rbi +8 -4
  33. data/rbi/openai/models/custom_tool_input_format.rbi +2 -0
  34. data/rbi/openai/models/realtime/realtime_session_create_request.rbi +26 -4
  35. data/rbi/openai/models/realtime/realtime_session_create_response.rbi +26 -4
  36. data/rbi/openai/models/realtime/realtime_truncation.rbi +13 -2
  37. data/rbi/openai/models/realtime/realtime_truncation_retention_ratio.rbi +84 -6
  38. data/rbi/openai/models/reasoning.rbi +6 -0
  39. data/rbi/openai/models/responses/custom_tool.rbi +2 -0
  40. data/rbi/openai/models/responses/file_search_tool.rbi +65 -0
  41. data/rbi/openai/models/responses/response_content.rbi +0 -1
  42. data/rbi/openai/models/responses/response_input_content.rbi +1 -2
  43. data/rbi/openai/models/responses/response_input_item.rbi +3 -6
  44. data/rbi/openai/models/responses/response_input_message_item.rbi +1 -2
  45. data/rbi/openai/models/responses/response_output_text.rbi +10 -19
  46. data/rbi/openai/models/responses/tool.rbi +73 -4
  47. data/rbi/openai/models/vector_stores/file_batch_create_params.rbi +181 -12
  48. data/rbi/openai/models/video.rbi +8 -0
  49. data/rbi/openai/resources/files.rbi +13 -14
  50. data/rbi/openai/resources/realtime/calls.rbi +17 -6
  51. data/rbi/openai/resources/vector_stores/file_batches.rbi +15 -5
  52. data/sig/openai/internal/transport/base_client.rbs +2 -0
  53. data/sig/openai/models/realtime/realtime_truncation_retention_ratio.rbs +29 -2
  54. data/sig/openai/models/responses/file_search_tool.rbs +24 -0
  55. data/sig/openai/models/responses/response_content.rbs +0 -1
  56. data/sig/openai/models/responses/response_input_content.rbs +0 -1
  57. data/sig/openai/models/responses/response_output_text.rbs +7 -11
  58. data/sig/openai/models/responses/tool.rbs +30 -3
  59. data/sig/openai/models/vector_stores/file_batch_create_params.rbs +56 -6
  60. data/sig/openai/models/video.rbs +5 -0
  61. data/sig/openai/resources/vector_stores/file_batches.rbs +2 -1
  62. metadata +4 -3
@@ -30,8 +30,10 @@ module OpenAI
30
30
  # A tool that generates images using a model like `gpt-image-1`.
31
31
  variant :image_generation, -> { OpenAI::Responses::Tool::ImageGeneration }
32
32
 
33
+ # A tool that allows the model to execute shell commands in a local environment.
33
34
  variant :local_shell, -> { OpenAI::Responses::Tool::LocalShell }
34
35
 
36
+ # A custom tool that processes input using a specified format. Learn more about [custom tools](https://platform.openai.com/docs/guides/function-calling#custom-tools)
35
37
  variant :custom, -> { OpenAI::Responses::CustomTool }
36
38
 
37
39
  # Search the Internet for sources related to the prompt. Learn more about the
@@ -388,13 +390,37 @@ module OpenAI
388
390
  # @return [Array<String>, nil]
389
391
  optional :file_ids, OpenAI::Internal::Type::ArrayOf[String]
390
392
 
391
- # @!method initialize(file_ids: nil, type: :auto)
393
+ # @!attribute memory_limit
394
+ #
395
+ # @return [Symbol, OpenAI::Models::Responses::Tool::CodeInterpreter::Container::CodeInterpreterToolAuto::MemoryLimit, nil]
396
+ optional :memory_limit,
397
+ enum: -> {
398
+ OpenAI::Responses::Tool::CodeInterpreter::Container::CodeInterpreterToolAuto::MemoryLimit
399
+ },
400
+ nil?: true
401
+
402
+ # @!method initialize(file_ids: nil, memory_limit: nil, type: :auto)
392
403
  # Configuration for a code interpreter container. Optionally specify the IDs of
393
404
  # the files to run the code on.
394
405
  #
395
406
  # @param file_ids [Array<String>] An optional list of uploaded files to make available to your code.
396
407
  #
408
+ # @param memory_limit [Symbol, OpenAI::Models::Responses::Tool::CodeInterpreter::Container::CodeInterpreterToolAuto::MemoryLimit, nil]
409
+ #
397
410
  # @param type [Symbol, :auto] Always `auto`.
411
+
412
+ # @see OpenAI::Models::Responses::Tool::CodeInterpreter::Container::CodeInterpreterToolAuto#memory_limit
413
+ module MemoryLimit
414
+ extend OpenAI::Internal::Type::Enum
415
+
416
+ MEMORY_LIMIT_1G = :"1g"
417
+ MEMORY_LIMIT_4G = :"4g"
418
+ MEMORY_LIMIT_16G = :"16g"
419
+ MEMORY_LIMIT_64G = :"64g"
420
+
421
+ # @!method self.values
422
+ # @return [Array<Symbol>]
423
+ end
398
424
  end
399
425
 
400
426
  # @!method self.variants
@@ -490,7 +516,7 @@ module OpenAI
490
516
  #
491
517
  # @param background [Symbol, OpenAI::Models::Responses::Tool::ImageGeneration::Background] Background type for the generated image. One of `transparent`,
492
518
  #
493
- # @param input_fidelity [Symbol, OpenAI::Models::Responses::Tool::ImageGeneration::InputFidelity, nil]
519
+ # @param input_fidelity [Symbol, OpenAI::Models::Responses::Tool::ImageGeneration::InputFidelity, nil] Control how much effort the model will exert to match the style and features, es
494
520
  #
495
521
  # @param input_image_mask [OpenAI::Models::Responses::Tool::ImageGeneration::InputImageMask] Optional mask for inpainting. Contains `image_url`
496
522
  #
@@ -650,6 +676,8 @@ module OpenAI
650
676
  required :type, const: :local_shell
651
677
 
652
678
  # @!method initialize(type: :local_shell)
679
+ # A tool that allows the model to execute shell commands in a local environment.
680
+ #
653
681
  # @param type [Symbol, :local_shell] The type of the local shell tool. Always `local_shell`.
654
682
  end
655
683
 
@@ -8,14 +8,6 @@ module OpenAI
8
8
  extend OpenAI::Internal::Type::RequestParameters::Converter
9
9
  include OpenAI::Internal::Type::RequestParameters
10
10
 
11
- # @!attribute file_ids
12
- # A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
13
- # the vector store should use. Useful for tools like `file_search` that can access
14
- # files.
15
- #
16
- # @return [Array<String>]
17
- required :file_ids, OpenAI::Internal::Type::ArrayOf[String]
18
-
19
11
  # @!attribute attributes
20
12
  # Set of 16 key-value pairs that can be attached to an object. This can be useful
21
13
  # for storing additional information about the object in a structured format, and
@@ -37,16 +29,36 @@ module OpenAI
37
29
  # @return [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam, nil]
38
30
  optional :chunking_strategy, union: -> { OpenAI::FileChunkingStrategyParam }
39
31
 
40
- # @!method initialize(file_ids:, attributes: nil, chunking_strategy: nil, request_options: {})
32
+ # @!attribute file_ids
33
+ # A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
34
+ # the vector store should use. Useful for tools like `file_search` that can access
35
+ # files. If `attributes` or `chunking_strategy` are provided, they will be applied
36
+ # to all files in the batch. Mutually exclusive with `files`.
37
+ #
38
+ # @return [Array<String>, nil]
39
+ optional :file_ids, OpenAI::Internal::Type::ArrayOf[String]
40
+
41
+ # @!attribute files
42
+ # A list of objects that each include a `file_id` plus optional `attributes` or
43
+ # `chunking_strategy`. Use this when you need to override metadata for specific
44
+ # files. The global `attributes` or `chunking_strategy` will be ignored and must
45
+ # be specified for each file. Mutually exclusive with `file_ids`.
46
+ #
47
+ # @return [Array<OpenAI::Models::VectorStores::FileBatchCreateParams::File>, nil]
48
+ optional :files, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::VectorStores::FileBatchCreateParams::File] }
49
+
50
+ # @!method initialize(attributes: nil, chunking_strategy: nil, file_ids: nil, files: nil, request_options: {})
41
51
  # Some parameter documentations has been truncated, see
42
52
  # {OpenAI::Models::VectorStores::FileBatchCreateParams} for more details.
43
53
  #
44
- # @param file_ids [Array<String>] A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
45
- #
46
54
  # @param attributes [Hash{Symbol=>String, Float, Boolean}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
47
55
  #
48
56
  # @param chunking_strategy [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam] The chunking strategy used to chunk the file(s). If not set, will use the `auto`
49
57
  #
58
+ # @param file_ids [Array<String>] A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
59
+ #
60
+ # @param files [Array<OpenAI::Models::VectorStores::FileBatchCreateParams::File>] A list of objects that each include a `file_id` plus optional `attributes` or `c
61
+ #
50
62
  # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
51
63
 
52
64
  module Attribute
@@ -61,6 +73,60 @@ module OpenAI
61
73
  # @!method self.variants
62
74
  # @return [Array(String, Float, Boolean)]
63
75
  end
76
+
77
+ class File < OpenAI::Internal::Type::BaseModel
78
+ # @!attribute file_id
79
+ # A [File](https://platform.openai.com/docs/api-reference/files) ID that the
80
+ # vector store should use. Useful for tools like `file_search` that can access
81
+ # files.
82
+ #
83
+ # @return [String]
84
+ required :file_id, String
85
+
86
+ # @!attribute attributes
87
+ # Set of 16 key-value pairs that can be attached to an object. This can be useful
88
+ # for storing additional information about the object in a structured format, and
89
+ # querying for objects via API or the dashboard. Keys are strings with a maximum
90
+ # length of 64 characters. Values are strings with a maximum length of 512
91
+ # characters, booleans, or numbers.
92
+ #
93
+ # @return [Hash{Symbol=>String, Float, Boolean}, nil]
94
+ optional :attributes,
95
+ -> {
96
+ OpenAI::Internal::Type::HashOf[union: OpenAI::VectorStores::FileBatchCreateParams::File::Attribute]
97
+ },
98
+ nil?: true
99
+
100
+ # @!attribute chunking_strategy
101
+ # The chunking strategy used to chunk the file(s). If not set, will use the `auto`
102
+ # strategy. Only applicable if `file_ids` is non-empty.
103
+ #
104
+ # @return [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam, nil]
105
+ optional :chunking_strategy, union: -> { OpenAI::FileChunkingStrategyParam }
106
+
107
+ # @!method initialize(file_id:, attributes: nil, chunking_strategy: nil)
108
+ # Some parameter documentations has been truncated, see
109
+ # {OpenAI::Models::VectorStores::FileBatchCreateParams::File} for more details.
110
+ #
111
+ # @param file_id [String] A [File](https://platform.openai.com/docs/api-reference/files) ID that the vecto
112
+ #
113
+ # @param attributes [Hash{Symbol=>String, Float, Boolean}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
114
+ #
115
+ # @param chunking_strategy [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam] The chunking strategy used to chunk the file(s). If not set, will use the `auto`
116
+
117
+ module Attribute
118
+ extend OpenAI::Internal::Type::Union
119
+
120
+ variant String
121
+
122
+ variant Float
123
+
124
+ variant OpenAI::Internal::Type::Boolean
125
+
126
+ # @!method self.variants
127
+ # @return [Array(String, Float, Boolean)]
128
+ end
129
+ end
64
130
  end
65
131
  end
66
132
  end
@@ -52,6 +52,12 @@ module OpenAI
52
52
  # @return [Integer]
53
53
  required :progress, Integer
54
54
 
55
+ # @!attribute prompt
56
+ # The prompt that was used to generate the video.
57
+ #
58
+ # @return [String, nil]
59
+ required :prompt, String, nil?: true
60
+
55
61
  # @!attribute remixed_from_video_id
56
62
  # Identifier of the source video if this video is a remix.
57
63
  #
@@ -76,7 +82,7 @@ module OpenAI
76
82
  # @return [Symbol, OpenAI::Models::Video::Status]
77
83
  required :status, enum: -> { OpenAI::Video::Status }
78
84
 
79
- # @!method initialize(id:, completed_at:, created_at:, error:, expires_at:, model:, progress:, remixed_from_video_id:, seconds:, size:, status:, object: :video)
85
+ # @!method initialize(id:, completed_at:, created_at:, error:, expires_at:, model:, progress:, prompt:, remixed_from_video_id:, seconds:, size:, status:, object: :video)
80
86
  # Structured information describing a generated video job.
81
87
  #
82
88
  # @param id [String] Unique identifier for the video job.
@@ -93,6 +99,8 @@ module OpenAI
93
99
  #
94
100
  # @param progress [Integer] Approximate completion percentage for the generation task.
95
101
  #
102
+ # @param prompt [String, nil] The prompt that was used to generate the video.
103
+ #
96
104
  # @param remixed_from_video_id [String, nil] Identifier of the source video if this video is a remix.
97
105
  #
98
106
  # @param seconds [Symbol, OpenAI::Models::VideoSeconds] Duration of the generated clip in seconds.
@@ -10,20 +10,19 @@ module OpenAI
10
10
  # up to 512 MB, and the size of all files uploaded by one organization can be up
11
11
  # to 1 TB.
12
12
  #
13
- # The Assistants API supports files up to 2 million tokens and of specific file
14
- # types. See the
15
- # [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for
16
- # details.
17
- #
18
- # The Fine-tuning API only supports `.jsonl` files. The input also has certain
19
- # required formats for fine-tuning
20
- # [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
21
- # [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
22
- # models.
23
- #
24
- # The Batch API only supports `.jsonl` files up to 200 MB in size. The input also
25
- # has a specific required
26
- # [format](https://platform.openai.com/docs/api-reference/batch/request-input).
13
+ # - The Assistants API supports files up to 2 million tokens and of specific file
14
+ # types. See the
15
+ # [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools)
16
+ # for details.
17
+ # - The Fine-tuning API only supports `.jsonl` files. The input also has certain
18
+ # required formats for fine-tuning
19
+ # [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input)
20
+ # or
21
+ # [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
22
+ # models.
23
+ # - The Batch API only supports `.jsonl` files up to 200 MB in size. The input
24
+ # also has a specific required
25
+ # [format](https://platform.openai.com/docs/api-reference/batch/request-input).
27
26
  #
28
27
  # Please [contact us](https://help.openai.com/) if you need to increase these
29
28
  # storage limits.
@@ -55,7 +55,7 @@ module OpenAI
55
55
  #
56
56
  # @param background [Symbol, OpenAI::Models::ImageEditParams::Background, nil] Allows to set transparency for the background of the generated image(s).
57
57
  #
58
- # @param input_fidelity [Symbol, OpenAI::Models::ImageEditParams::InputFidelity, nil]
58
+ # @param input_fidelity [Symbol, OpenAI::Models::ImageEditParams::InputFidelity, nil] Control how much effort the model will exert to match the style and features, es
59
59
  #
60
60
  # @param mask [Pathname, StringIO, IO, String, OpenAI::FilePart] An additional image whose fully transparent areas (e.g. where alpha is zero) ind
61
61
  #
@@ -114,7 +114,7 @@ module OpenAI
114
114
  #
115
115
  # @param background [Symbol, OpenAI::Models::ImageEditParams::Background, nil] Allows to set transparency for the background of the generated image(s).
116
116
  #
117
- # @param input_fidelity [Symbol, OpenAI::Models::ImageEditParams::InputFidelity, nil]
117
+ # @param input_fidelity [Symbol, OpenAI::Models::ImageEditParams::InputFidelity, nil] Control how much effort the model will exert to match the style and features, es
118
118
  #
119
119
  # @param mask [Pathname, StringIO, IO, String, OpenAI::FilePart] An additional image whose fully transparent areas (e.g. where alpha is zero) ind
120
120
  #
@@ -34,7 +34,7 @@ module OpenAI
34
34
  #
35
35
  # @param tracing [Symbol, :auto, OpenAI::Models::Realtime::RealtimeTracingConfig::TracingConfiguration, nil] Realtime API can write session traces to the [Traces Dashboard](/logs?api=traces
36
36
  #
37
- # @param truncation [Symbol, OpenAI::Models::Realtime::RealtimeTruncation::RealtimeTruncationStrategy, OpenAI::Models::Realtime::RealtimeTruncationRetentionRatio] Controls how the realtime conversation is truncated prior to model inference.
37
+ # @param truncation [Symbol, OpenAI::Models::Realtime::RealtimeTruncation::RealtimeTruncationStrategy, OpenAI::Models::Realtime::RealtimeTruncationRetentionRatio] When the number of tokens in a conversation exceeds the model's input token limi
38
38
  #
39
39
  # @param type [Symbol, :realtime] The type of session to create. Always `realtime` for the Realtime API.
40
40
  #
@@ -559,6 +559,10 @@ module OpenAI
559
559
  in {text: {format: {type: :json_schema,
560
560
  schema: OpenAI::StructuredOutput::JsonSchemaConverter => model}}}
561
561
  parsed.dig(:text, :format).store(:schema, model.to_json_schema)
562
+ else
563
+ end
564
+
565
+ case parsed
562
566
  in {tools: Array => tools}
563
567
  # rubocop:disable Metrics/BlockLength
564
568
  mapped = tools.map do |tool|
@@ -9,22 +9,24 @@ module OpenAI
9
9
  #
10
10
  # Create a vector store file batch.
11
11
  #
12
- # @overload create(vector_store_id, file_ids:, attributes: nil, chunking_strategy: nil, request_options: {})
12
+ # @overload create(vector_store_id, attributes: nil, chunking_strategy: nil, file_ids: nil, files: nil, request_options: {})
13
13
  #
14
14
  # @param vector_store_id [String] The ID of the vector store for which to create a File Batch.
15
15
  #
16
- # @param file_ids [Array<String>] A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
17
- #
18
16
  # @param attributes [Hash{Symbol=>String, Float, Boolean}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
19
17
  #
20
18
  # @param chunking_strategy [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam] The chunking strategy used to chunk the file(s). If not set, will use the `auto`
21
19
  #
20
+ # @param file_ids [Array<String>] A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
21
+ #
22
+ # @param files [Array<OpenAI::Models::VectorStores::FileBatchCreateParams::File>] A list of objects that each include a `file_id` plus optional `attributes` or `c
23
+ #
22
24
  # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
23
25
  #
24
26
  # @return [OpenAI::Models::VectorStores::VectorStoreFileBatch]
25
27
  #
26
28
  # @see OpenAI::Models::VectorStores::FileBatchCreateParams
27
- def create(vector_store_id, params)
29
+ def create(vector_store_id, params = {})
28
30
  parsed, options = OpenAI::VectorStores::FileBatchCreateParams.dump_request(params)
29
31
  @client.request(
30
32
  method: :post,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenAI
4
- VERSION = "0.34.1"
4
+ VERSION = "0.35.0"
5
5
  end
@@ -184,6 +184,11 @@ module OpenAI
184
184
  private def auth_headers
185
185
  end
186
186
 
187
+ # @api private
188
+ sig { returns(String) }
189
+ private def user_agent
190
+ end
191
+
187
192
  # @api private
188
193
  sig { returns(String) }
189
194
  private def generate_idempotency_key
@@ -28,7 +28,7 @@ module OpenAI
28
28
  #
29
29
  # Assumes superclass fields are totally defined before fields are accessed /
30
30
  # defined on subclasses.
31
- sig { params(child: T.self_type).void }
31
+ sig { params(child: OpenAI::Internal::Type::BaseModel).void }
32
32
  def inherited(child)
33
33
  end
34
34
 
@@ -267,9 +267,13 @@ module OpenAI
267
267
 
268
268
  # Create a new instance of a model.
269
269
  sig do
270
- params(data: T.any(T::Hash[Symbol, T.anything], T.self_type)).returns(
271
- T.attached_class
272
- )
270
+ params(
271
+ data:
272
+ T.any(
273
+ T::Hash[Symbol, T.anything],
274
+ OpenAI::Internal::Type::BaseModel
275
+ )
276
+ ).returns(T.attached_class)
273
277
  end
274
278
  def self.new(data = {})
275
279
  end
@@ -27,6 +27,7 @@ module OpenAI
27
27
  sig { returns(Symbol) }
28
28
  attr_accessor :type
29
29
 
30
+ # Unconstrained free-form text.
30
31
  sig { params(type: Symbol).returns(T.attached_class) }
31
32
  def self.new(
32
33
  # Unconstrained text format. Always `text`.
@@ -62,6 +63,7 @@ module OpenAI
62
63
  sig { returns(Symbol) }
63
64
  attr_accessor :type
64
65
 
66
+ # A grammar defined by the user.
65
67
  sig do
66
68
  params(
67
69
  definition: String,
@@ -210,8 +210,19 @@ module OpenAI
210
210
  end
211
211
  attr_accessor :tracing
212
212
 
213
- # Controls how the realtime conversation is truncated prior to model inference.
214
- # The default is `auto`.
213
+ # When the number of tokens in a conversation exceeds the model's input token
214
+ # limit, the conversation be truncated, meaning messages (starting from the
215
+ # oldest) will not be included in the model's context. A 32k context model with
216
+ # 4,096 max output tokens can only include 28,224 tokens in the context before
217
+ # truncation occurs. Clients can configure truncation behavior to truncate with a
218
+ # lower max token limit, which is an effective way to control token usage and
219
+ # cost. Truncation will reduce the number of cached tokens on the next turn
220
+ # (busting the cache), since messages are dropped from the beginning of the
221
+ # context. However, clients can also configure truncation to retain messages up to
222
+ # a fraction of the maximum context size, which will reduce the need for future
223
+ # truncations and thus improve the cache rate. Truncation can be disabled
224
+ # entirely, which means the server will never truncate but would instead return an
225
+ # error if the conversation exceeds the model's input token limit.
215
226
  sig do
216
227
  returns(
217
228
  T.nilable(
@@ -329,8 +340,19 @@ module OpenAI
329
340
  # `auto` will create a trace for the session with default values for the workflow
330
341
  # name, group id, and metadata.
331
342
  tracing: nil,
332
- # Controls how the realtime conversation is truncated prior to model inference.
333
- # The default is `auto`.
343
+ # When the number of tokens in a conversation exceeds the model's input token
344
+ # limit, the conversation be truncated, meaning messages (starting from the
345
+ # oldest) will not be included in the model's context. A 32k context model with
346
+ # 4,096 max output tokens can only include 28,224 tokens in the context before
347
+ # truncation occurs. Clients can configure truncation behavior to truncate with a
348
+ # lower max token limit, which is an effective way to control token usage and
349
+ # cost. Truncation will reduce the number of cached tokens on the next turn
350
+ # (busting the cache), since messages are dropped from the beginning of the
351
+ # context. However, clients can also configure truncation to retain messages up to
352
+ # a fraction of the maximum context size, which will reduce the need for future
353
+ # truncations and thus improve the cache rate. Truncation can be disabled
354
+ # entirely, which means the server will never truncate but would instead return an
355
+ # error if the conversation exceeds the model's input token limit.
334
356
  truncation: nil,
335
357
  # The type of session to create. Always `realtime` for the Realtime API.
336
358
  type: :realtime
@@ -223,8 +223,19 @@ module OpenAI
223
223
  end
224
224
  attr_accessor :tracing
225
225
 
226
- # Controls how the realtime conversation is truncated prior to model inference.
227
- # The default is `auto`.
226
+ # When the number of tokens in a conversation exceeds the model's input token
227
+ # limit, the conversation be truncated, meaning messages (starting from the
228
+ # oldest) will not be included in the model's context. A 32k context model with
229
+ # 4,096 max output tokens can only include 28,224 tokens in the context before
230
+ # truncation occurs. Clients can configure truncation behavior to truncate with a
231
+ # lower max token limit, which is an effective way to control token usage and
232
+ # cost. Truncation will reduce the number of cached tokens on the next turn
233
+ # (busting the cache), since messages are dropped from the beginning of the
234
+ # context. However, clients can also configure truncation to retain messages up to
235
+ # a fraction of the maximum context size, which will reduce the need for future
236
+ # truncations and thus improve the cache rate. Truncation can be disabled
237
+ # entirely, which means the server will never truncate but would instead return an
238
+ # error if the conversation exceeds the model's input token limit.
228
239
  sig do
229
240
  returns(T.nilable(OpenAI::Realtime::RealtimeTruncation::Variants))
230
241
  end
@@ -341,8 +352,19 @@ module OpenAI
341
352
  # `auto` will create a trace for the session with default values for the workflow
342
353
  # name, group id, and metadata.
343
354
  tracing: nil,
344
- # Controls how the realtime conversation is truncated prior to model inference.
345
- # The default is `auto`.
355
+ # When the number of tokens in a conversation exceeds the model's input token
356
+ # limit, the conversation be truncated, meaning messages (starting from the
357
+ # oldest) will not be included in the model's context. A 32k context model with
358
+ # 4,096 max output tokens can only include 28,224 tokens in the context before
359
+ # truncation occurs. Clients can configure truncation behavior to truncate with a
360
+ # lower max token limit, which is an effective way to control token usage and
361
+ # cost. Truncation will reduce the number of cached tokens on the next turn
362
+ # (busting the cache), since messages are dropped from the beginning of the
363
+ # context. However, clients can also configure truncation to retain messages up to
364
+ # a fraction of the maximum context size, which will reduce the need for future
365
+ # truncations and thus improve the cache rate. Truncation can be disabled
366
+ # entirely, which means the server will never truncate but would instead return an
367
+ # error if the conversation exceeds the model's input token limit.
346
368
  truncation: nil,
347
369
  # The type of session to create. Always `realtime` for the Realtime API.
348
370
  type: :realtime
@@ -3,8 +3,19 @@
3
3
  module OpenAI
4
4
  module Models
5
5
  module Realtime
6
- # Controls how the realtime conversation is truncated prior to model inference.
7
- # The default is `auto`.
6
+ # When the number of tokens in a conversation exceeds the model's input token
7
+ # limit, the conversation be truncated, meaning messages (starting from the
8
+ # oldest) will not be included in the model's context. A 32k context model with
9
+ # 4,096 max output tokens can only include 28,224 tokens in the context before
10
+ # truncation occurs. Clients can configure truncation behavior to truncate with a
11
+ # lower max token limit, which is an effective way to control token usage and
12
+ # cost. Truncation will reduce the number of cached tokens on the next turn
13
+ # (busting the cache), since messages are dropped from the beginning of the
14
+ # context. However, clients can also configure truncation to retain messages up to
15
+ # a fraction of the maximum context size, which will reduce the need for future
16
+ # truncations and thus improve the cache rate. Truncation can be disabled
17
+ # entirely, which means the server will never truncate but would instead return an
18
+ # error if the conversation exceeds the model's input token limit.
8
19
  module RealtimeTruncation
9
20
  extend OpenAI::Internal::Type::Union
10
21
 
@@ -12,8 +12,10 @@ module OpenAI
12
12
  )
13
13
  end
14
14
 
15
- # Fraction of post-instruction conversation tokens to retain (0.0 - 1.0) when the
16
- # conversation exceeds the input token limit.
15
+ # Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when
16
+ # the conversation exceeds the input token limit. Setting this to `0.8` means that
17
+ # messages will be dropped until 80% of the maximum allowed tokens are used. This
18
+ # helps reduce the frequency of truncations and improve cache rates.
17
19
  sig { returns(Float) }
18
20
  attr_accessor :retention_ratio
19
21
 
@@ -21,24 +23,100 @@ module OpenAI
21
23
  sig { returns(Symbol) }
22
24
  attr_accessor :type
23
25
 
26
+ # Optional custom token limits for this truncation strategy. If not provided, the
27
+ # model's default token limits will be used.
28
+ sig do
29
+ returns(
30
+ T.nilable(
31
+ OpenAI::Realtime::RealtimeTruncationRetentionRatio::TokenLimits
32
+ )
33
+ )
34
+ end
35
+ attr_reader :token_limits
36
+
37
+ sig do
38
+ params(
39
+ token_limits:
40
+ OpenAI::Realtime::RealtimeTruncationRetentionRatio::TokenLimits::OrHash
41
+ ).void
42
+ end
43
+ attr_writer :token_limits
44
+
24
45
  # Retain a fraction of the conversation tokens when the conversation exceeds the
25
46
  # input token limit. This allows you to amortize truncations across multiple
26
47
  # turns, which can help improve cached token usage.
27
48
  sig do
28
- params(retention_ratio: Float, type: Symbol).returns(T.attached_class)
49
+ params(
50
+ retention_ratio: Float,
51
+ token_limits:
52
+ OpenAI::Realtime::RealtimeTruncationRetentionRatio::TokenLimits::OrHash,
53
+ type: Symbol
54
+ ).returns(T.attached_class)
29
55
  end
30
56
  def self.new(
31
- # Fraction of post-instruction conversation tokens to retain (0.0 - 1.0) when the
32
- # conversation exceeds the input token limit.
57
+ # Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when
58
+ # the conversation exceeds the input token limit. Setting this to `0.8` means that
59
+ # messages will be dropped until 80% of the maximum allowed tokens are used. This
60
+ # helps reduce the frequency of truncations and improve cache rates.
33
61
  retention_ratio:,
62
+ # Optional custom token limits for this truncation strategy. If not provided, the
63
+ # model's default token limits will be used.
64
+ token_limits: nil,
34
65
  # Use retention ratio truncation.
35
66
  type: :retention_ratio
36
67
  )
37
68
  end
38
69
 
39
- sig { override.returns({ retention_ratio: Float, type: Symbol }) }
70
+ sig do
71
+ override.returns(
72
+ {
73
+ retention_ratio: Float,
74
+ type: Symbol,
75
+ token_limits:
76
+ OpenAI::Realtime::RealtimeTruncationRetentionRatio::TokenLimits
77
+ }
78
+ )
79
+ end
40
80
  def to_hash
41
81
  end
82
+
83
+ class TokenLimits < OpenAI::Internal::Type::BaseModel
84
+ OrHash =
85
+ T.type_alias do
86
+ T.any(
87
+ OpenAI::Realtime::RealtimeTruncationRetentionRatio::TokenLimits,
88
+ OpenAI::Internal::AnyHash
89
+ )
90
+ end
91
+
92
+ # Maximum tokens allowed in the conversation after instructions (which including
93
+ # tool definitions). For example, setting this to 5,000 would mean that truncation
94
+ # would occur when the conversation exceeds 5,000 tokens after instructions. This
95
+ # cannot be higher than the model's context window size minus the maximum output
96
+ # tokens.
97
+ sig { returns(T.nilable(Integer)) }
98
+ attr_reader :post_instructions
99
+
100
+ sig { params(post_instructions: Integer).void }
101
+ attr_writer :post_instructions
102
+
103
+ # Optional custom token limits for this truncation strategy. If not provided, the
104
+ # model's default token limits will be used.
105
+ sig { params(post_instructions: Integer).returns(T.attached_class) }
106
+ def self.new(
107
+ # Maximum tokens allowed in the conversation after instructions (which including
108
+ # tool definitions). For example, setting this to 5,000 would mean that truncation
109
+ # would occur when the conversation exceeds 5,000 tokens after instructions. This
110
+ # cannot be higher than the model's context window size minus the maximum output
111
+ # tokens.
112
+ post_instructions: nil
113
+ )
114
+ end
115
+
116
+ sig { override.returns({ post_instructions: Integer }) }
117
+ def to_hash
118
+ end
119
+ end
42
120
  end
43
121
  end
44
122
  end
@@ -28,6 +28,8 @@ module OpenAI
28
28
  # A summary of the reasoning performed by the model. This can be useful for
29
29
  # debugging and understanding the model's reasoning process. One of `auto`,
30
30
  # `concise`, or `detailed`.
31
+ #
32
+ # `concise` is only supported for `computer-use-preview` models.
31
33
  sig { returns(T.nilable(OpenAI::Reasoning::Summary::OrSymbol)) }
32
34
  attr_accessor :summary
33
35
 
@@ -62,6 +64,8 @@ module OpenAI
62
64
  # A summary of the reasoning performed by the model. This can be useful for
63
65
  # debugging and understanding the model's reasoning process. One of `auto`,
64
66
  # `concise`, or `detailed`.
67
+ #
68
+ # `concise` is only supported for `computer-use-preview` models.
65
69
  summary: nil
66
70
  )
67
71
  end
@@ -109,6 +113,8 @@ module OpenAI
109
113
  # A summary of the reasoning performed by the model. This can be useful for
110
114
  # debugging and understanding the model's reasoning process. One of `auto`,
111
115
  # `concise`, or `detailed`.
116
+ #
117
+ # `concise` is only supported for `computer-use-preview` models.
112
118
  module Summary
113
119
  extend OpenAI::Internal::Type::Enum
114
120
 
@@ -48,6 +48,8 @@ module OpenAI
48
48
  end
49
49
  attr_writer :format_
50
50
 
51
+ # A custom tool that processes input using a specified format. Learn more about
52
+ # [custom tools](https://platform.openai.com/docs/guides/function-calling#custom-tools)
51
53
  sig do
52
54
  params(
53
55
  name: String,