openai 0.16.0 → 0.17.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 (169) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/README.md +14 -20
  4. data/lib/openai/internal/transport/base_client.rb +1 -1
  5. data/lib/openai/internal/type/enum.rb +6 -6
  6. data/lib/openai/internal/type/union.rb +13 -17
  7. data/lib/openai/models/beta/assistant_create_params.rb +4 -5
  8. data/lib/openai/models/beta/assistant_update_params.rb +22 -5
  9. data/lib/openai/models/beta/threads/run_create_params.rb +4 -5
  10. data/lib/openai/models/chat/chat_completion_allowed_tool_choice.rb +33 -0
  11. data/lib/openai/models/chat/chat_completion_allowed_tools.rb +64 -0
  12. data/lib/openai/models/chat/chat_completion_assistant_message_param.rb +3 -5
  13. data/lib/openai/models/chat/chat_completion_custom_tool.rb +163 -0
  14. data/lib/openai/models/chat/chat_completion_function_tool.rb +29 -0
  15. data/lib/openai/models/chat/chat_completion_message.rb +3 -5
  16. data/lib/openai/models/chat/chat_completion_message_custom_tool_call.rb +60 -0
  17. data/lib/openai/models/chat/chat_completion_message_function_tool_call.rb +73 -0
  18. data/lib/openai/models/chat/chat_completion_message_tool_call.rb +10 -56
  19. data/lib/openai/models/chat/chat_completion_named_tool_choice.rb +2 -2
  20. data/lib/openai/models/chat/chat_completion_named_tool_choice_custom.rb +42 -0
  21. data/lib/openai/models/chat/chat_completion_stream_options.rb +14 -1
  22. data/lib/openai/models/chat/chat_completion_tool.rb +12 -14
  23. data/lib/openai/models/chat/chat_completion_tool_choice_option.rb +7 -1
  24. data/lib/openai/models/chat/completion_create_params.rb +35 -12
  25. data/lib/openai/models/chat_model.rb +7 -0
  26. data/lib/openai/models/custom_tool_input_format.rb +76 -0
  27. data/lib/openai/models/evals/create_eval_completions_run_data_source.rb +3 -3
  28. data/lib/openai/models/evals/run_cancel_response.rb +2 -2
  29. data/lib/openai/models/evals/run_create_params.rb +2 -2
  30. data/lib/openai/models/evals/run_create_response.rb +2 -2
  31. data/lib/openai/models/evals/run_list_response.rb +2 -2
  32. data/lib/openai/models/evals/run_retrieve_response.rb +2 -2
  33. data/lib/openai/models/reasoning.rb +4 -5
  34. data/lib/openai/models/reasoning_effort.rb +4 -4
  35. data/lib/openai/models/response_format_text_grammar.rb +27 -0
  36. data/lib/openai/models/response_format_text_python.rb +20 -0
  37. data/lib/openai/models/responses/custom_tool.rb +48 -0
  38. data/lib/openai/models/responses/response.rb +20 -12
  39. data/lib/openai/models/responses/response_create_params.rb +48 -10
  40. data/lib/openai/models/responses/response_custom_tool_call.rb +55 -0
  41. data/lib/openai/models/responses/response_custom_tool_call_input_delta_event.rb +52 -0
  42. data/lib/openai/models/responses/response_custom_tool_call_input_done_event.rb +52 -0
  43. data/lib/openai/models/responses/response_custom_tool_call_output.rb +47 -0
  44. data/lib/openai/models/responses/response_input_item.rb +7 -1
  45. data/lib/openai/models/responses/response_output_item.rb +4 -1
  46. data/lib/openai/models/responses/response_output_item_added_event.rb +2 -2
  47. data/lib/openai/models/responses/response_output_item_done_event.rb +2 -2
  48. data/lib/openai/models/responses/response_reasoning_item.rb +36 -5
  49. data/lib/openai/models/responses/response_reasoning_text_delta_event.rb +63 -0
  50. data/lib/openai/models/responses/response_reasoning_text_done_event.rb +63 -0
  51. data/lib/openai/models/responses/response_retrieve_params.rb +14 -1
  52. data/lib/openai/models/responses/response_stream_event.rb +13 -11
  53. data/lib/openai/models/responses/response_text_config.rb +27 -1
  54. data/lib/openai/models/responses/tool.rb +5 -1
  55. data/lib/openai/models/responses/tool_choice_allowed.rb +73 -0
  56. data/lib/openai/models/responses/tool_choice_custom.rb +28 -0
  57. data/lib/openai/models/vector_store_search_params.rb +6 -1
  58. data/lib/openai/models.rb +6 -0
  59. data/lib/openai/resources/beta/assistants.rb +2 -2
  60. data/lib/openai/resources/beta/threads/runs.rb +2 -2
  61. data/lib/openai/resources/chat/completions.rb +16 -10
  62. data/lib/openai/resources/responses.rb +38 -22
  63. data/lib/openai/version.rb +1 -1
  64. data/lib/openai.rb +19 -2
  65. data/rbi/openai/internal/transport/base_client.rbi +1 -1
  66. data/rbi/openai/models/beta/assistant_create_params.rbi +6 -8
  67. data/rbi/openai/models/beta/assistant_update_params.rbi +36 -8
  68. data/rbi/openai/models/beta/threads/run_create_params.rbi +6 -8
  69. data/rbi/openai/models/chat/chat_completion_allowed_tool_choice.rbi +60 -0
  70. data/rbi/openai/models/chat/chat_completion_allowed_tools.rbi +118 -0
  71. data/rbi/openai/models/chat/chat_completion_assistant_message_param.rbi +27 -4
  72. data/rbi/openai/models/chat/chat_completion_custom_tool.rbi +335 -0
  73. data/rbi/openai/models/chat/chat_completion_function_tool.rbi +51 -0
  74. data/rbi/openai/models/chat/chat_completion_message.rbi +17 -4
  75. data/rbi/openai/models/chat/chat_completion_message_custom_tool_call.rbi +105 -0
  76. data/rbi/openai/models/chat/chat_completion_message_function_tool_call.rbi +118 -0
  77. data/rbi/openai/models/chat/chat_completion_message_tool_call.rbi +9 -92
  78. data/rbi/openai/models/chat/chat_completion_named_tool_choice.rbi +2 -2
  79. data/rbi/openai/models/chat/chat_completion_named_tool_choice_custom.rbi +89 -0
  80. data/rbi/openai/models/chat/chat_completion_stream_options.rbi +30 -2
  81. data/rbi/openai/models/chat/chat_completion_tool.rbi +11 -30
  82. data/rbi/openai/models/chat/chat_completion_tool_choice_option.rbi +3 -1
  83. data/rbi/openai/models/chat/completion_create_params.rbi +106 -25
  84. data/rbi/openai/models/chat_model.rbi +11 -0
  85. data/rbi/openai/models/custom_tool_input_format.rbi +136 -0
  86. data/rbi/openai/models/evals/create_eval_completions_run_data_source.rbi +8 -4
  87. data/rbi/openai/models/evals/run_cancel_response.rbi +2 -0
  88. data/rbi/openai/models/evals/run_create_params.rbi +4 -0
  89. data/rbi/openai/models/evals/run_create_response.rbi +2 -0
  90. data/rbi/openai/models/evals/run_list_response.rbi +2 -0
  91. data/rbi/openai/models/evals/run_retrieve_response.rbi +2 -0
  92. data/rbi/openai/models/reasoning.rbi +6 -8
  93. data/rbi/openai/models/reasoning_effort.rbi +4 -4
  94. data/rbi/openai/models/response_format_text_grammar.rbi +35 -0
  95. data/rbi/openai/models/response_format_text_python.rbi +30 -0
  96. data/rbi/openai/models/responses/custom_tool.rbi +96 -0
  97. data/rbi/openai/models/responses/response.rbi +15 -5
  98. data/rbi/openai/models/responses/response_create_params.rbi +94 -7
  99. data/rbi/openai/models/responses/response_custom_tool_call.rbi +78 -0
  100. data/rbi/openai/models/responses/response_custom_tool_call_input_delta_event.rbi +75 -0
  101. data/rbi/openai/models/responses/response_custom_tool_call_input_done_event.rbi +75 -0
  102. data/rbi/openai/models/responses/response_custom_tool_call_output.rbi +65 -0
  103. data/rbi/openai/models/responses/response_input_item.rbi +2 -0
  104. data/rbi/openai/models/responses/response_output_item.rbi +2 -1
  105. data/rbi/openai/models/responses/response_output_item_added_event.rbi +2 -1
  106. data/rbi/openai/models/responses/response_output_item_done_event.rbi +2 -1
  107. data/rbi/openai/models/responses/response_reasoning_item.rbi +63 -4
  108. data/rbi/openai/models/responses/response_reasoning_text_delta_event.rbi +83 -0
  109. data/rbi/openai/models/responses/{response_reasoning_summary_done_event.rbi → response_reasoning_text_done_event.rbi} +20 -20
  110. data/rbi/openai/models/responses/response_retrieve_params.rbi +21 -0
  111. data/rbi/openai/models/responses/response_stream_event.rbi +4 -2
  112. data/rbi/openai/models/responses/response_text_config.rbi +64 -1
  113. data/rbi/openai/models/responses/tool.rbi +1 -0
  114. data/rbi/openai/models/responses/tool_choice_allowed.rbi +124 -0
  115. data/rbi/openai/models/responses/tool_choice_custom.rbi +39 -0
  116. data/rbi/openai/models/vector_store_search_params.rbi +12 -1
  117. data/rbi/openai/models.rbi +6 -0
  118. data/rbi/openai/resources/beta/assistants.rbi +6 -8
  119. data/rbi/openai/resources/beta/threads/runs.rbi +8 -10
  120. data/rbi/openai/resources/chat/completions.rbi +44 -19
  121. data/rbi/openai/resources/responses.rbi +215 -41
  122. data/sig/openai/internal/transport/base_client.rbs +1 -1
  123. data/sig/openai/models/beta/assistant_update_params.rbs +12 -0
  124. data/sig/openai/models/chat/chat_completion_allowed_tool_choice.rbs +29 -0
  125. data/sig/openai/models/chat/chat_completion_allowed_tools.rbs +38 -0
  126. data/sig/openai/models/chat/chat_completion_assistant_message_param.rbs +6 -6
  127. data/sig/openai/models/chat/chat_completion_custom_tool.rbs +137 -0
  128. data/sig/openai/models/chat/chat_completion_function_tool.rbs +26 -0
  129. data/sig/openai/models/chat/chat_completion_message.rbs +6 -6
  130. data/sig/openai/models/chat/chat_completion_message_custom_tool_call.rbs +46 -0
  131. data/sig/openai/models/chat/chat_completion_message_function_tool_call.rbs +46 -0
  132. data/sig/openai/models/chat/chat_completion_message_tool_call.rbs +6 -35
  133. data/sig/openai/models/chat/chat_completion_named_tool_choice_custom.rbs +39 -0
  134. data/sig/openai/models/chat/chat_completion_stream_options.rbs +11 -3
  135. data/sig/openai/models/chat/chat_completion_tool.rbs +6 -15
  136. data/sig/openai/models/chat/chat_completion_tool_choice_option.rbs +2 -0
  137. data/sig/openai/models/chat/completion_create_params.rbs +23 -6
  138. data/sig/openai/models/chat_model.rbs +15 -1
  139. data/sig/openai/models/custom_tool_input_format.rbs +61 -0
  140. data/sig/openai/models/evals/create_eval_completions_run_data_source.rbs +6 -6
  141. data/sig/openai/models/reasoning_effort.rbs +2 -1
  142. data/sig/openai/models/response_format_text_grammar.rbs +15 -0
  143. data/sig/openai/models/response_format_text_python.rbs +13 -0
  144. data/sig/openai/models/responses/custom_tool.rbs +43 -0
  145. data/sig/openai/models/responses/response.rbs +2 -0
  146. data/sig/openai/models/responses/response_create_params.rbs +19 -0
  147. data/sig/openai/models/responses/response_custom_tool_call.rbs +44 -0
  148. data/sig/openai/models/responses/response_custom_tool_call_input_delta_event.rbs +42 -0
  149. data/sig/openai/models/responses/response_custom_tool_call_input_done_event.rbs +42 -0
  150. data/sig/openai/models/responses/response_custom_tool_call_output.rbs +39 -0
  151. data/sig/openai/models/responses/response_input_item.rbs +2 -0
  152. data/sig/openai/models/responses/response_output_item.rbs +1 -0
  153. data/sig/openai/models/responses/response_reasoning_item.rbs +21 -0
  154. data/sig/openai/models/responses/{response_reasoning_summary_delta_event.rbs → response_reasoning_text_delta_event.rbs} +15 -15
  155. data/sig/openai/models/responses/{response_reasoning_summary_done_event.rbs → response_reasoning_text_done_event.rbs} +11 -11
  156. data/sig/openai/models/responses/response_retrieve_params.rbs +7 -0
  157. data/sig/openai/models/responses/response_stream_event.rbs +4 -2
  158. data/sig/openai/models/responses/response_text_config.rbs +22 -3
  159. data/sig/openai/models/responses/tool.rbs +1 -0
  160. data/sig/openai/models/responses/tool_choice_allowed.rbs +43 -0
  161. data/sig/openai/models/responses/tool_choice_custom.rbs +17 -0
  162. data/sig/openai/models/vector_store_search_params.rbs +2 -1
  163. data/sig/openai/models.rbs +6 -0
  164. data/sig/openai/resources/chat/completions.rbs +4 -2
  165. data/sig/openai/resources/responses.rbs +32 -0
  166. metadata +59 -8
  167. data/lib/openai/models/responses/response_reasoning_summary_delta_event.rb +0 -65
  168. data/lib/openai/models/responses/response_reasoning_summary_done_event.rb +0 -60
  169. data/rbi/openai/models/responses/response_reasoning_summary_delta_event.rbi +0 -85
@@ -0,0 +1,96 @@
1
+ # typed: strong
2
+
3
+ module OpenAI
4
+ module Models
5
+ module Responses
6
+ class CustomTool < OpenAI::Internal::Type::BaseModel
7
+ OrHash =
8
+ T.type_alias do
9
+ T.any(OpenAI::Responses::CustomTool, OpenAI::Internal::AnyHash)
10
+ end
11
+
12
+ # The name of the custom tool, used to identify it in tool calls.
13
+ sig { returns(String) }
14
+ attr_accessor :name
15
+
16
+ # The type of the custom tool. Always `custom`.
17
+ sig { returns(Symbol) }
18
+ attr_accessor :type
19
+
20
+ # Optional description of the custom tool, used to provide more context.
21
+ sig { returns(T.nilable(String)) }
22
+ attr_reader :description
23
+
24
+ sig { params(description: String).void }
25
+ attr_writer :description
26
+
27
+ # The input format for the custom tool. Default is unconstrained text.
28
+ sig do
29
+ returns(
30
+ T.nilable(
31
+ T.any(
32
+ OpenAI::CustomToolInputFormat::Text,
33
+ OpenAI::CustomToolInputFormat::Grammar
34
+ )
35
+ )
36
+ )
37
+ end
38
+ attr_reader :format_
39
+
40
+ sig do
41
+ params(
42
+ format_:
43
+ T.any(
44
+ OpenAI::CustomToolInputFormat::Text::OrHash,
45
+ OpenAI::CustomToolInputFormat::Grammar::OrHash
46
+ )
47
+ ).void
48
+ end
49
+ attr_writer :format_
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).
53
+ sig do
54
+ params(
55
+ name: String,
56
+ description: String,
57
+ format_:
58
+ T.any(
59
+ OpenAI::CustomToolInputFormat::Text::OrHash,
60
+ OpenAI::CustomToolInputFormat::Grammar::OrHash
61
+ ),
62
+ type: Symbol
63
+ ).returns(T.attached_class)
64
+ end
65
+ def self.new(
66
+ # The name of the custom tool, used to identify it in tool calls.
67
+ name:,
68
+ # Optional description of the custom tool, used to provide more context.
69
+ description: nil,
70
+ # The input format for the custom tool. Default is unconstrained text.
71
+ format_: nil,
72
+ # The type of the custom tool. Always `custom`.
73
+ type: :custom
74
+ )
75
+ end
76
+
77
+ sig do
78
+ override.returns(
79
+ {
80
+ name: String,
81
+ type: Symbol,
82
+ description: String,
83
+ format_:
84
+ T.any(
85
+ OpenAI::CustomToolInputFormat::Text,
86
+ OpenAI::CustomToolInputFormat::Grammar
87
+ )
88
+ }
89
+ )
90
+ end
91
+ def to_hash
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -116,8 +116,10 @@ module OpenAI
116
116
  # Learn more about
117
117
  # [built-in tools](https://platform.openai.com/docs/guides/tools).
118
118
  # - **Function calls (custom tools)**: Functions that are defined by you, enabling
119
- # the model to call your own code. Learn more about
119
+ # the model to call your own code with strongly typed arguments and outputs.
120
+ # Learn more about
120
121
  # [function calling](https://platform.openai.com/docs/guides/function-calling).
122
+ # You can also use custom tools to call your own code.
121
123
  sig { returns(T::Array[OpenAI::Responses::Tool::Variants]) }
122
124
  attr_accessor :tools
123
125
 
@@ -308,7 +310,8 @@ module OpenAI
308
310
  OpenAI::Responses::ResponseOutputItem::LocalShellCall::OrHash,
309
311
  OpenAI::Responses::ResponseOutputItem::McpCall::OrHash,
310
312
  OpenAI::Responses::ResponseOutputItem::McpListTools::OrHash,
311
- OpenAI::Responses::ResponseOutputItem::McpApprovalRequest::OrHash
313
+ OpenAI::Responses::ResponseOutputItem::McpApprovalRequest::OrHash,
314
+ OpenAI::Responses::ResponseCustomToolCall::OrHash
312
315
  )
313
316
  ],
314
317
  parallel_tool_calls: T::Boolean,
@@ -316,9 +319,11 @@ module OpenAI
316
319
  tool_choice:
317
320
  T.any(
318
321
  OpenAI::Responses::ToolChoiceOptions::OrSymbol,
322
+ OpenAI::Responses::ToolChoiceAllowed::OrHash,
319
323
  OpenAI::Responses::ToolChoiceTypes::OrHash,
320
324
  OpenAI::Responses::ToolChoiceFunction::OrHash,
321
- OpenAI::Responses::ToolChoiceMcp::OrHash
325
+ OpenAI::Responses::ToolChoiceMcp::OrHash,
326
+ OpenAI::Responses::ToolChoiceCustom::OrHash
322
327
  ),
323
328
  tools:
324
329
  T::Array[
@@ -330,6 +335,7 @@ module OpenAI
330
335
  OpenAI::Responses::Tool::CodeInterpreter::OrHash,
331
336
  OpenAI::Responses::Tool::ImageGeneration::OrHash,
332
337
  OpenAI::Responses::Tool::LocalShell::OrHash,
338
+ OpenAI::Responses::CustomTool::OrHash,
333
339
  OpenAI::Responses::WebSearchTool::OrHash
334
340
  )
335
341
  ],
@@ -413,8 +419,10 @@ module OpenAI
413
419
  # Learn more about
414
420
  # [built-in tools](https://platform.openai.com/docs/guides/tools).
415
421
  # - **Function calls (custom tools)**: Functions that are defined by you, enabling
416
- # the model to call your own code. Learn more about
422
+ # the model to call your own code with strongly typed arguments and outputs.
423
+ # Learn more about
417
424
  # [function calling](https://platform.openai.com/docs/guides/function-calling).
425
+ # You can also use custom tools to call your own code.
418
426
  tools:,
419
427
  # An alternative to sampling with temperature, called nucleus sampling, where the
420
428
  # model considers the results of the tokens with top_p probability mass. So 0.1
@@ -684,9 +692,11 @@ module OpenAI
684
692
  T.type_alias do
685
693
  T.any(
686
694
  OpenAI::Responses::ToolChoiceOptions::TaggedSymbol,
695
+ OpenAI::Responses::ToolChoiceAllowed,
687
696
  OpenAI::Responses::ToolChoiceTypes,
688
697
  OpenAI::Responses::ToolChoiceFunction,
689
- OpenAI::Responses::ToolChoiceMcp
698
+ OpenAI::Responses::ToolChoiceMcp,
699
+ OpenAI::Responses::ToolChoiceCustom
690
700
  )
691
701
  end
692
702
 
@@ -208,6 +208,24 @@ module OpenAI
208
208
  sig { returns(T.nilable(T::Boolean)) }
209
209
  attr_accessor :store
210
210
 
211
+ # Options for streaming responses. Only set this when you set `stream: true`.
212
+ sig do
213
+ returns(
214
+ T.nilable(OpenAI::Responses::ResponseCreateParams::StreamOptions)
215
+ )
216
+ end
217
+ attr_reader :stream_options
218
+
219
+ sig do
220
+ params(
221
+ stream_options:
222
+ T.nilable(
223
+ OpenAI::Responses::ResponseCreateParams::StreamOptions::OrHash
224
+ )
225
+ ).void
226
+ end
227
+ attr_writer :stream_options
228
+
211
229
  # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
212
230
  # make the output more random, while lower values like 0.2 will make it more
213
231
  # focused and deterministic. We generally recommend altering this or `top_p` but
@@ -242,9 +260,11 @@ module OpenAI
242
260
  T.nilable(
243
261
  T.any(
244
262
  OpenAI::Responses::ToolChoiceOptions::OrSymbol,
263
+ OpenAI::Responses::ToolChoiceAllowed,
245
264
  OpenAI::Responses::ToolChoiceTypes,
246
265
  OpenAI::Responses::ToolChoiceFunction,
247
- OpenAI::Responses::ToolChoiceMcp
266
+ OpenAI::Responses::ToolChoiceMcp,
267
+ OpenAI::Responses::ToolChoiceCustom
248
268
  )
249
269
  )
250
270
  )
@@ -256,9 +276,11 @@ module OpenAI
256
276
  tool_choice:
257
277
  T.any(
258
278
  OpenAI::Responses::ToolChoiceOptions::OrSymbol,
279
+ OpenAI::Responses::ToolChoiceAllowed::OrHash,
259
280
  OpenAI::Responses::ToolChoiceTypes::OrHash,
260
281
  OpenAI::Responses::ToolChoiceFunction::OrHash,
261
- OpenAI::Responses::ToolChoiceMcp::OrHash
282
+ OpenAI::Responses::ToolChoiceMcp::OrHash,
283
+ OpenAI::Responses::ToolChoiceCustom::OrHash
262
284
  )
263
285
  ).void
264
286
  end
@@ -276,8 +298,10 @@ module OpenAI
276
298
  # Learn more about
277
299
  # [built-in tools](https://platform.openai.com/docs/guides/tools).
278
300
  # - **Function calls (custom tools)**: Functions that are defined by you, enabling
279
- # the model to call your own code. Learn more about
301
+ # the model to call your own code with strongly typed arguments and outputs.
302
+ # Learn more about
280
303
  # [function calling](https://platform.openai.com/docs/guides/function-calling).
304
+ # You can also use custom tools to call your own code.
281
305
  sig do
282
306
  returns(
283
307
  T.nilable(
@@ -290,6 +314,7 @@ module OpenAI
290
314
  OpenAI::Responses::Tool::CodeInterpreter,
291
315
  OpenAI::Responses::Tool::ImageGeneration,
292
316
  OpenAI::Responses::Tool::LocalShell,
317
+ OpenAI::Responses::CustomTool,
293
318
  OpenAI::Responses::WebSearchTool
294
319
  )
295
320
  ]
@@ -310,6 +335,7 @@ module OpenAI
310
335
  OpenAI::Responses::Tool::CodeInterpreter::OrHash,
311
336
  OpenAI::Responses::Tool::ImageGeneration::OrHash,
312
337
  OpenAI::Responses::Tool::LocalShell::OrHash,
338
+ OpenAI::Responses::CustomTool::OrHash,
313
339
  OpenAI::Responses::WebSearchTool::OrHash
314
340
  )
315
341
  ]
@@ -386,14 +412,20 @@ module OpenAI
386
412
  OpenAI::Responses::ResponseCreateParams::ServiceTier::OrSymbol
387
413
  ),
388
414
  store: T.nilable(T::Boolean),
415
+ stream_options:
416
+ T.nilable(
417
+ OpenAI::Responses::ResponseCreateParams::StreamOptions::OrHash
418
+ ),
389
419
  temperature: T.nilable(Float),
390
420
  text: OpenAI::Responses::ResponseTextConfig::OrHash,
391
421
  tool_choice:
392
422
  T.any(
393
423
  OpenAI::Responses::ToolChoiceOptions::OrSymbol,
424
+ OpenAI::Responses::ToolChoiceAllowed::OrHash,
394
425
  OpenAI::Responses::ToolChoiceTypes::OrHash,
395
426
  OpenAI::Responses::ToolChoiceFunction::OrHash,
396
- OpenAI::Responses::ToolChoiceMcp::OrHash
427
+ OpenAI::Responses::ToolChoiceMcp::OrHash,
428
+ OpenAI::Responses::ToolChoiceCustom::OrHash
397
429
  ),
398
430
  tools:
399
431
  T::Array[
@@ -405,6 +437,7 @@ module OpenAI
405
437
  OpenAI::Responses::Tool::CodeInterpreter::OrHash,
406
438
  OpenAI::Responses::Tool::ImageGeneration::OrHash,
407
439
  OpenAI::Responses::Tool::LocalShell::OrHash,
440
+ OpenAI::Responses::CustomTool::OrHash,
408
441
  OpenAI::Responses::WebSearchTool::OrHash
409
442
  )
410
443
  ],
@@ -521,6 +554,8 @@ module OpenAI
521
554
  service_tier: nil,
522
555
  # Whether to store the generated model response for later retrieval via API.
523
556
  store: nil,
557
+ # Options for streaming responses. Only set this when you set `stream: true`.
558
+ stream_options: nil,
524
559
  # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
525
560
  # make the output more random, while lower values like 0.2 will make it more
526
561
  # focused and deterministic. We generally recommend altering this or `top_p` but
@@ -548,8 +583,10 @@ module OpenAI
548
583
  # Learn more about
549
584
  # [built-in tools](https://platform.openai.com/docs/guides/tools).
550
585
  # - **Function calls (custom tools)**: Functions that are defined by you, enabling
551
- # the model to call your own code. Learn more about
586
+ # the model to call your own code with strongly typed arguments and outputs.
587
+ # Learn more about
552
588
  # [function calling](https://platform.openai.com/docs/guides/function-calling).
589
+ # You can also use custom tools to call your own code.
553
590
  tools: nil,
554
591
  # An integer between 0 and 20 specifying the number of most likely tokens to
555
592
  # return at each token position, each with an associated log probability.
@@ -608,14 +645,20 @@ module OpenAI
608
645
  OpenAI::Responses::ResponseCreateParams::ServiceTier::OrSymbol
609
646
  ),
610
647
  store: T.nilable(T::Boolean),
648
+ stream_options:
649
+ T.nilable(
650
+ OpenAI::Responses::ResponseCreateParams::StreamOptions
651
+ ),
611
652
  temperature: T.nilable(Float),
612
653
  text: OpenAI::Responses::ResponseTextConfig,
613
654
  tool_choice:
614
655
  T.any(
615
656
  OpenAI::Responses::ToolChoiceOptions::OrSymbol,
657
+ OpenAI::Responses::ToolChoiceAllowed,
616
658
  OpenAI::Responses::ToolChoiceTypes,
617
659
  OpenAI::Responses::ToolChoiceFunction,
618
- OpenAI::Responses::ToolChoiceMcp
660
+ OpenAI::Responses::ToolChoiceMcp,
661
+ OpenAI::Responses::ToolChoiceCustom
619
662
  ),
620
663
  tools:
621
664
  T::Array[
@@ -627,6 +670,7 @@ module OpenAI
627
670
  OpenAI::Responses::Tool::CodeInterpreter,
628
671
  OpenAI::Responses::Tool::ImageGeneration,
629
672
  OpenAI::Responses::Tool::LocalShell,
673
+ OpenAI::Responses::CustomTool,
630
674
  OpenAI::Responses::WebSearchTool
631
675
  )
632
676
  ],
@@ -739,6 +783,47 @@ module OpenAI
739
783
  end
740
784
  end
741
785
 
786
+ class StreamOptions < OpenAI::Internal::Type::BaseModel
787
+ OrHash =
788
+ T.type_alias do
789
+ T.any(
790
+ OpenAI::Responses::ResponseCreateParams::StreamOptions,
791
+ OpenAI::Internal::AnyHash
792
+ )
793
+ end
794
+
795
+ # When true, stream obfuscation will be enabled. Stream obfuscation adds random
796
+ # characters to an `obfuscation` field on streaming delta events to normalize
797
+ # payload sizes as a mitigation to certain side-channel attacks. These obfuscation
798
+ # fields are included by default, but add a small amount of overhead to the data
799
+ # stream. You can set `include_obfuscation` to false to optimize for bandwidth if
800
+ # you trust the network links between your application and the OpenAI API.
801
+ sig { returns(T.nilable(T::Boolean)) }
802
+ attr_reader :include_obfuscation
803
+
804
+ sig { params(include_obfuscation: T::Boolean).void }
805
+ attr_writer :include_obfuscation
806
+
807
+ # Options for streaming responses. Only set this when you set `stream: true`.
808
+ sig do
809
+ params(include_obfuscation: T::Boolean).returns(T.attached_class)
810
+ end
811
+ def self.new(
812
+ # When true, stream obfuscation will be enabled. Stream obfuscation adds random
813
+ # characters to an `obfuscation` field on streaming delta events to normalize
814
+ # payload sizes as a mitigation to certain side-channel attacks. These obfuscation
815
+ # fields are included by default, but add a small amount of overhead to the data
816
+ # stream. You can set `include_obfuscation` to false to optimize for bandwidth if
817
+ # you trust the network links between your application and the OpenAI API.
818
+ include_obfuscation: nil
819
+ )
820
+ end
821
+
822
+ sig { override.returns({ include_obfuscation: T::Boolean }) }
823
+ def to_hash
824
+ end
825
+ end
826
+
742
827
  # How the model should select which tool (or tools) to use when generating a
743
828
  # response. See the `tools` parameter to see how to specify which tools the model
744
829
  # can call.
@@ -749,9 +834,11 @@ module OpenAI
749
834
  T.type_alias do
750
835
  T.any(
751
836
  OpenAI::Responses::ToolChoiceOptions::TaggedSymbol,
837
+ OpenAI::Responses::ToolChoiceAllowed,
752
838
  OpenAI::Responses::ToolChoiceTypes,
753
839
  OpenAI::Responses::ToolChoiceFunction,
754
- OpenAI::Responses::ToolChoiceMcp
840
+ OpenAI::Responses::ToolChoiceMcp,
841
+ OpenAI::Responses::ToolChoiceCustom
755
842
  )
756
843
  end
757
844
 
@@ -0,0 +1,78 @@
1
+ # typed: strong
2
+
3
+ module OpenAI
4
+ module Models
5
+ module Responses
6
+ class ResponseCustomToolCall < OpenAI::Internal::Type::BaseModel
7
+ OrHash =
8
+ T.type_alias do
9
+ T.any(
10
+ OpenAI::Responses::ResponseCustomToolCall,
11
+ OpenAI::Internal::AnyHash
12
+ )
13
+ end
14
+
15
+ # An identifier used to map this custom tool call to a tool call output.
16
+ sig { returns(String) }
17
+ attr_accessor :call_id
18
+
19
+ # The input for the custom tool call generated by the model.
20
+ sig { returns(String) }
21
+ attr_accessor :input
22
+
23
+ # The name of the custom tool being called.
24
+ sig { returns(String) }
25
+ attr_accessor :name
26
+
27
+ # The type of the custom tool call. Always `custom_tool_call`.
28
+ sig { returns(Symbol) }
29
+ attr_accessor :type
30
+
31
+ # The unique ID of the custom tool call in the OpenAI platform.
32
+ sig { returns(T.nilable(String)) }
33
+ attr_reader :id
34
+
35
+ sig { params(id: String).void }
36
+ attr_writer :id
37
+
38
+ # A call to a custom tool created by the model.
39
+ sig do
40
+ params(
41
+ call_id: String,
42
+ input: String,
43
+ name: String,
44
+ id: String,
45
+ type: Symbol
46
+ ).returns(T.attached_class)
47
+ end
48
+ def self.new(
49
+ # An identifier used to map this custom tool call to a tool call output.
50
+ call_id:,
51
+ # The input for the custom tool call generated by the model.
52
+ input:,
53
+ # The name of the custom tool being called.
54
+ name:,
55
+ # The unique ID of the custom tool call in the OpenAI platform.
56
+ id: nil,
57
+ # The type of the custom tool call. Always `custom_tool_call`.
58
+ type: :custom_tool_call
59
+ )
60
+ end
61
+
62
+ sig do
63
+ override.returns(
64
+ {
65
+ call_id: String,
66
+ input: String,
67
+ name: String,
68
+ type: Symbol,
69
+ id: String
70
+ }
71
+ )
72
+ end
73
+ def to_hash
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,75 @@
1
+ # typed: strong
2
+
3
+ module OpenAI
4
+ module Models
5
+ module Responses
6
+ class ResponseCustomToolCallInputDeltaEvent < OpenAI::Internal::Type::BaseModel
7
+ OrHash =
8
+ T.type_alias do
9
+ T.any(
10
+ OpenAI::Responses::ResponseCustomToolCallInputDeltaEvent,
11
+ OpenAI::Internal::AnyHash
12
+ )
13
+ end
14
+
15
+ # The incremental input data (delta) for the custom tool call.
16
+ sig { returns(String) }
17
+ attr_accessor :delta
18
+
19
+ # Unique identifier for the API item associated with this event.
20
+ sig { returns(String) }
21
+ attr_accessor :item_id
22
+
23
+ # The index of the output this delta applies to.
24
+ sig { returns(Integer) }
25
+ attr_accessor :output_index
26
+
27
+ # The sequence number of this event.
28
+ sig { returns(Integer) }
29
+ attr_accessor :sequence_number
30
+
31
+ # The event type identifier.
32
+ sig { returns(Symbol) }
33
+ attr_accessor :type
34
+
35
+ # Event representing a delta (partial update) to the input of a custom tool call.
36
+ sig do
37
+ params(
38
+ delta: String,
39
+ item_id: String,
40
+ output_index: Integer,
41
+ sequence_number: Integer,
42
+ type: Symbol
43
+ ).returns(T.attached_class)
44
+ end
45
+ def self.new(
46
+ # The incremental input data (delta) for the custom tool call.
47
+ delta:,
48
+ # Unique identifier for the API item associated with this event.
49
+ item_id:,
50
+ # The index of the output this delta applies to.
51
+ output_index:,
52
+ # The sequence number of this event.
53
+ sequence_number:,
54
+ # The event type identifier.
55
+ type: :"response.custom_tool_call_input.delta"
56
+ )
57
+ end
58
+
59
+ sig do
60
+ override.returns(
61
+ {
62
+ delta: String,
63
+ item_id: String,
64
+ output_index: Integer,
65
+ sequence_number: Integer,
66
+ type: Symbol
67
+ }
68
+ )
69
+ end
70
+ def to_hash
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,75 @@
1
+ # typed: strong
2
+
3
+ module OpenAI
4
+ module Models
5
+ module Responses
6
+ class ResponseCustomToolCallInputDoneEvent < OpenAI::Internal::Type::BaseModel
7
+ OrHash =
8
+ T.type_alias do
9
+ T.any(
10
+ OpenAI::Responses::ResponseCustomToolCallInputDoneEvent,
11
+ OpenAI::Internal::AnyHash
12
+ )
13
+ end
14
+
15
+ # The complete input data for the custom tool call.
16
+ sig { returns(String) }
17
+ attr_accessor :input
18
+
19
+ # Unique identifier for the API item associated with this event.
20
+ sig { returns(String) }
21
+ attr_accessor :item_id
22
+
23
+ # The index of the output this event applies to.
24
+ sig { returns(Integer) }
25
+ attr_accessor :output_index
26
+
27
+ # The sequence number of this event.
28
+ sig { returns(Integer) }
29
+ attr_accessor :sequence_number
30
+
31
+ # The event type identifier.
32
+ sig { returns(Symbol) }
33
+ attr_accessor :type
34
+
35
+ # Event indicating that input for a custom tool call is complete.
36
+ sig do
37
+ params(
38
+ input: String,
39
+ item_id: String,
40
+ output_index: Integer,
41
+ sequence_number: Integer,
42
+ type: Symbol
43
+ ).returns(T.attached_class)
44
+ end
45
+ def self.new(
46
+ # The complete input data for the custom tool call.
47
+ input:,
48
+ # Unique identifier for the API item associated with this event.
49
+ item_id:,
50
+ # The index of the output this event applies to.
51
+ output_index:,
52
+ # The sequence number of this event.
53
+ sequence_number:,
54
+ # The event type identifier.
55
+ type: :"response.custom_tool_call_input.done"
56
+ )
57
+ end
58
+
59
+ sig do
60
+ override.returns(
61
+ {
62
+ input: String,
63
+ item_id: String,
64
+ output_index: Integer,
65
+ sequence_number: Integer,
66
+ type: Symbol
67
+ }
68
+ )
69
+ end
70
+ def to_hash
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,65 @@
1
+ # typed: strong
2
+
3
+ module OpenAI
4
+ module Models
5
+ module Responses
6
+ class ResponseCustomToolCallOutput < OpenAI::Internal::Type::BaseModel
7
+ OrHash =
8
+ T.type_alias do
9
+ T.any(
10
+ OpenAI::Responses::ResponseCustomToolCallOutput,
11
+ OpenAI::Internal::AnyHash
12
+ )
13
+ end
14
+
15
+ # The call ID, used to map this custom tool call output to a custom tool call.
16
+ sig { returns(String) }
17
+ attr_accessor :call_id
18
+
19
+ # The output from the custom tool call generated by your code.
20
+ sig { returns(String) }
21
+ attr_accessor :output
22
+
23
+ # The type of the custom tool call output. Always `custom_tool_call_output`.
24
+ sig { returns(Symbol) }
25
+ attr_accessor :type
26
+
27
+ # The unique ID of the custom tool call output in the OpenAI platform.
28
+ sig { returns(T.nilable(String)) }
29
+ attr_reader :id
30
+
31
+ sig { params(id: String).void }
32
+ attr_writer :id
33
+
34
+ # The output of a custom tool call from your code, being sent back to the model.
35
+ sig do
36
+ params(
37
+ call_id: String,
38
+ output: String,
39
+ id: String,
40
+ type: Symbol
41
+ ).returns(T.attached_class)
42
+ end
43
+ def self.new(
44
+ # The call ID, used to map this custom tool call output to a custom tool call.
45
+ call_id:,
46
+ # The output from the custom tool call generated by your code.
47
+ output:,
48
+ # The unique ID of the custom tool call output in the OpenAI platform.
49
+ id: nil,
50
+ # The type of the custom tool call output. Always `custom_tool_call_output`.
51
+ type: :custom_tool_call_output
52
+ )
53
+ end
54
+
55
+ sig do
56
+ override.returns(
57
+ { call_id: String, output: String, type: Symbol, id: String }
58
+ )
59
+ end
60
+ def to_hash
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -32,6 +32,8 @@ module OpenAI
32
32
  OpenAI::Responses::ResponseInputItem::McpApprovalRequest,
33
33
  OpenAI::Responses::ResponseInputItem::McpApprovalResponse,
34
34
  OpenAI::Responses::ResponseInputItem::McpCall,
35
+ OpenAI::Responses::ResponseCustomToolCallOutput,
36
+ OpenAI::Responses::ResponseCustomToolCall,
35
37
  OpenAI::Responses::ResponseInputItem::ItemReference
36
38
  )
37
39
  end
@@ -21,7 +21,8 @@ module OpenAI
21
21
  OpenAI::Responses::ResponseOutputItem::LocalShellCall,
22
22
  OpenAI::Responses::ResponseOutputItem::McpCall,
23
23
  OpenAI::Responses::ResponseOutputItem::McpListTools,
24
- OpenAI::Responses::ResponseOutputItem::McpApprovalRequest
24
+ OpenAI::Responses::ResponseOutputItem::McpApprovalRequest,
25
+ OpenAI::Responses::ResponseCustomToolCall
25
26
  )
26
27
  end
27
28