openai 0.18.1 → 0.20.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 (186) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +35 -0
  3. data/README.md +1 -1
  4. data/lib/openai/client.rb +4 -0
  5. data/lib/openai/helpers/structured_output/boolean.rb +1 -0
  6. data/lib/openai/internal/conversation_cursor_page.rb +92 -0
  7. data/lib/openai/internal/transport/base_client.rb +1 -4
  8. data/lib/openai/internal/transport/pooled_net_requester.rb +1 -9
  9. data/lib/openai/internal/util.rb +1 -1
  10. data/lib/openai/models/audio/transcription.rb +1 -4
  11. data/lib/openai/models/audio/transcription_create_params.rb +2 -7
  12. data/lib/openai/models/audio/transcription_text_done_event.rb +1 -4
  13. data/lib/openai/models/beta/assistant_create_params.rb +6 -19
  14. data/lib/openai/models/beta/assistant_stream_event.rb +6 -24
  15. data/lib/openai/models/beta/assistant_update_params.rb +1 -4
  16. data/lib/openai/models/beta/message_stream_event.rb +1 -4
  17. data/lib/openai/models/beta/run_step_stream_event.rb +1 -4
  18. data/lib/openai/models/beta/thread_create_and_run_params.rb +10 -32
  19. data/lib/openai/models/beta/thread_create_params.rb +7 -22
  20. data/lib/openai/models/beta/threads/message.rb +3 -10
  21. data/lib/openai/models/beta/threads/message_create_params.rb +2 -7
  22. data/lib/openai/models/beta/threads/run.rb +2 -7
  23. data/lib/openai/models/beta/threads/run_create_params.rb +3 -10
  24. data/lib/openai/models/beta/threads/run_submit_tool_outputs_params.rb +1 -3
  25. data/lib/openai/models/beta/threads/runs/code_interpreter_tool_call.rb +5 -17
  26. data/lib/openai/models/beta/threads/runs/code_interpreter_tool_call_delta.rb +1 -3
  27. data/lib/openai/models/beta/threads/runs/file_search_tool_call.rb +4 -12
  28. data/lib/openai/models/beta/threads/runs/run_step_delta_message_delta.rb +1 -4
  29. data/lib/openai/models/beta/threads/runs/tool_calls_step_details.rb +1 -4
  30. data/lib/openai/models/beta/threads/text.rb +1 -4
  31. data/lib/openai/models/chat/chat_completion_chunk.rb +1 -3
  32. data/lib/openai/models/chat/chat_completion_custom_tool.rb +2 -7
  33. data/lib/openai/models/chat/chat_completion_message.rb +7 -5
  34. data/lib/openai/models/chat/chat_completion_message_function_tool_call.rb +7 -5
  35. data/lib/openai/models/conversations/computer_screenshot_content.rb +38 -0
  36. data/lib/openai/models/conversations/container_file_citation_body.rb +58 -0
  37. data/lib/openai/models/conversations/conversation.rb +51 -0
  38. data/lib/openai/models/conversations/conversation_create_params.rb +39 -0
  39. data/lib/openai/models/conversations/conversation_delete_params.rb +16 -0
  40. data/lib/openai/models/conversations/conversation_deleted.rb +29 -0
  41. data/lib/openai/models/conversations/conversation_deleted_resource.rb +30 -0
  42. data/lib/openai/models/conversations/conversation_item.rb +568 -0
  43. data/lib/openai/models/conversations/conversation_item_list.rb +55 -0
  44. data/lib/openai/models/conversations/conversation_retrieve_params.rb +16 -0
  45. data/lib/openai/models/conversations/conversation_update_params.rb +31 -0
  46. data/lib/openai/models/conversations/file_citation_body.rb +42 -0
  47. data/lib/openai/models/conversations/input_file_content.rb +42 -0
  48. data/lib/openai/models/conversations/input_image_content.rb +62 -0
  49. data/lib/openai/models/conversations/input_text_content.rb +26 -0
  50. data/lib/openai/models/conversations/item_create_params.rb +37 -0
  51. data/lib/openai/models/conversations/item_delete_params.rb +22 -0
  52. data/lib/openai/models/conversations/item_list_params.rb +86 -0
  53. data/lib/openai/models/conversations/item_retrieve_params.rb +36 -0
  54. data/lib/openai/models/conversations/lob_prob.rb +35 -0
  55. data/lib/openai/models/conversations/message.rb +115 -0
  56. data/lib/openai/models/conversations/output_text_content.rb +57 -0
  57. data/lib/openai/models/conversations/refusal_content.rb +26 -0
  58. data/lib/openai/models/conversations/summary_text_content.rb +23 -0
  59. data/lib/openai/models/conversations/text_content.rb +23 -0
  60. data/lib/openai/models/conversations/top_log_prob.rb +29 -0
  61. data/lib/openai/models/conversations/url_citation_body.rb +50 -0
  62. data/lib/openai/models/eval_create_params.rb +6 -20
  63. data/lib/openai/models/evals/create_eval_completions_run_data_source.rb +29 -53
  64. data/lib/openai/models/evals/create_eval_jsonl_run_data_source.rb +1 -3
  65. data/lib/openai/models/evals/run_cancel_response.rb +2 -2
  66. data/lib/openai/models/evals/run_create_params.rb +20 -56
  67. data/lib/openai/models/evals/run_create_response.rb +2 -2
  68. data/lib/openai/models/evals/run_list_response.rb +2 -2
  69. data/lib/openai/models/evals/run_retrieve_response.rb +2 -2
  70. data/lib/openai/models/fine_tuning/reinforcement_hyperparameters.rb +1 -4
  71. data/lib/openai/models/moderation.rb +5 -15
  72. data/lib/openai/models/responses/input_item_list_params.rb +1 -9
  73. data/lib/openai/models/responses/response.rb +28 -3
  74. data/lib/openai/models/responses/response_computer_tool_call.rb +2 -6
  75. data/lib/openai/models/responses/response_computer_tool_call_output_item.rb +1 -3
  76. data/lib/openai/models/responses/response_conversation_param.rb +20 -0
  77. data/lib/openai/models/responses/response_create_params.rb +38 -3
  78. data/lib/openai/models/responses/response_function_tool_call.rb +7 -5
  79. data/lib/openai/models/responses/response_function_web_search.rb +35 -1
  80. data/lib/openai/models/responses/response_includable.rb +2 -0
  81. data/lib/openai/models/responses/response_input_item.rb +2 -7
  82. data/lib/openai/models/responses/response_input_message_item.rb +1 -4
  83. data/lib/openai/models/responses/response_output_item.rb +1 -3
  84. data/lib/openai/models/responses/response_output_message.rb +1 -3
  85. data/lib/openai/models/responses/response_output_text.rb +10 -15
  86. data/lib/openai/models/responses/response_stream_event.rb +4 -16
  87. data/lib/openai/models/responses/response_text_delta_event.rb +1 -3
  88. data/lib/openai/models/responses/response_text_done_event.rb +1 -3
  89. data/lib/openai/models/responses/tool.rb +303 -35
  90. data/lib/openai/models.rb +2 -0
  91. data/lib/openai/resources/conversations/items.rb +141 -0
  92. data/lib/openai/resources/conversations.rb +112 -0
  93. data/lib/openai/resources/responses/input_items.rb +1 -3
  94. data/lib/openai/resources/responses.rb +8 -4
  95. data/lib/openai/version.rb +1 -1
  96. data/lib/openai.rb +31 -0
  97. data/rbi/openai/client.rbi +3 -0
  98. data/rbi/openai/errors.rbi +5 -5
  99. data/rbi/openai/internal/conversation_cursor_page.rbi +25 -0
  100. data/rbi/openai/models/conversations/computer_screenshot_content.rbi +60 -0
  101. data/rbi/openai/models/conversations/container_file_citation_body.rbi +82 -0
  102. data/rbi/openai/models/conversations/conversation.rbi +76 -0
  103. data/rbi/openai/models/conversations/conversation_create_params.rbi +144 -0
  104. data/rbi/openai/models/conversations/conversation_delete_params.rbi +32 -0
  105. data/rbi/openai/models/conversations/conversation_deleted.rbi +40 -0
  106. data/rbi/openai/models/conversations/conversation_deleted_resource.rbi +40 -0
  107. data/rbi/openai/models/conversations/conversation_item.rbi +835 -0
  108. data/rbi/openai/models/conversations/conversation_item_list.rbi +101 -0
  109. data/rbi/openai/models/conversations/conversation_retrieve_params.rbi +32 -0
  110. data/rbi/openai/models/conversations/conversation_update_params.rbi +56 -0
  111. data/rbi/openai/models/conversations/file_citation_body.rbi +61 -0
  112. data/rbi/openai/models/conversations/input_file_content.rbi +72 -0
  113. data/rbi/openai/models/conversations/input_image_content.rbi +113 -0
  114. data/rbi/openai/models/conversations/input_text_content.rbi +38 -0
  115. data/rbi/openai/models/conversations/item_create_params.rbi +150 -0
  116. data/rbi/openai/models/conversations/item_delete_params.rbi +40 -0
  117. data/rbi/openai/models/conversations/item_list_params.rbi +178 -0
  118. data/rbi/openai/models/conversations/item_retrieve_params.rbi +70 -0
  119. data/rbi/openai/models/conversations/lob_prob.rbi +50 -0
  120. data/rbi/openai/models/conversations/message.rbi +196 -0
  121. data/rbi/openai/models/conversations/output_text_content.rbi +110 -0
  122. data/rbi/openai/models/conversations/refusal_content.rbi +38 -0
  123. data/rbi/openai/models/conversations/summary_text_content.rbi +31 -0
  124. data/rbi/openai/models/conversations/text_content.rbi +28 -0
  125. data/rbi/openai/models/conversations/top_log_prob.rbi +41 -0
  126. data/rbi/openai/models/conversations/url_citation_body.rbi +74 -0
  127. data/rbi/openai/models/evals/create_eval_completions_run_data_source.rbi +33 -33
  128. data/rbi/openai/models/evals/run_cancel_response.rbi +2 -0
  129. data/rbi/openai/models/evals/run_create_params.rbi +4 -0
  130. data/rbi/openai/models/evals/run_create_response.rbi +2 -0
  131. data/rbi/openai/models/evals/run_list_response.rbi +2 -0
  132. data/rbi/openai/models/evals/run_retrieve_response.rbi +2 -0
  133. data/rbi/openai/models/responses/input_item_list_params.rbi +0 -11
  134. data/rbi/openai/models/responses/response.rbi +50 -0
  135. data/rbi/openai/models/responses/response_conversation_param.rbi +33 -0
  136. data/rbi/openai/models/responses/response_create_params.rbi +62 -0
  137. data/rbi/openai/models/responses/response_function_web_search.rbi +78 -2
  138. data/rbi/openai/models/responses/response_includable.rbi +2 -0
  139. data/rbi/openai/models/responses/tool.rbi +590 -31
  140. data/rbi/openai/models.rbi +2 -0
  141. data/rbi/openai/resources/conversations/items.rbi +154 -0
  142. data/rbi/openai/resources/conversations.rbi +110 -0
  143. data/rbi/openai/resources/responses/input_items.rbi +0 -3
  144. data/rbi/openai/resources/responses.rbi +32 -0
  145. data/sig/openai/client.rbs +2 -0
  146. data/sig/openai/internal/conversation_cursor_page.rbs +15 -0
  147. data/sig/openai/models/conversations/computer_screenshot_content.rbs +28 -0
  148. data/sig/openai/models/conversations/container_file_citation_body.rbs +47 -0
  149. data/sig/openai/models/conversations/conversation.rbs +37 -0
  150. data/sig/openai/models/conversations/conversation_create_params.rbs +33 -0
  151. data/sig/openai/models/conversations/conversation_delete_params.rbs +17 -0
  152. data/sig/openai/models/conversations/conversation_deleted.rbs +28 -0
  153. data/sig/openai/models/conversations/conversation_deleted_resource.rbs +28 -0
  154. data/sig/openai/models/conversations/conversation_item.rbs +403 -0
  155. data/sig/openai/models/conversations/conversation_item_list.rbs +44 -0
  156. data/sig/openai/models/conversations/conversation_retrieve_params.rbs +17 -0
  157. data/sig/openai/models/conversations/conversation_update_params.rbs +26 -0
  158. data/sig/openai/models/conversations/file_citation_body.rbs +37 -0
  159. data/sig/openai/models/conversations/input_file_content.rbs +41 -0
  160. data/sig/openai/models/conversations/input_image_content.rbs +49 -0
  161. data/sig/openai/models/conversations/input_text_content.rbs +17 -0
  162. data/sig/openai/models/conversations/item_create_params.rbs +37 -0
  163. data/sig/openai/models/conversations/item_delete_params.rbs +25 -0
  164. data/sig/openai/models/conversations/item_list_params.rbs +66 -0
  165. data/sig/openai/models/conversations/item_retrieve_params.rbs +37 -0
  166. data/sig/openai/models/conversations/lob_prob.rbs +37 -0
  167. data/sig/openai/models/conversations/message.rbs +95 -0
  168. data/sig/openai/models/conversations/output_text_content.rbs +52 -0
  169. data/sig/openai/models/conversations/refusal_content.rbs +17 -0
  170. data/sig/openai/models/conversations/summary_text_content.rbs +17 -0
  171. data/sig/openai/models/conversations/text_content.rbs +17 -0
  172. data/sig/openai/models/conversations/top_log_prob.rbs +28 -0
  173. data/sig/openai/models/conversations/url_citation_body.rbs +42 -0
  174. data/sig/openai/models/evals/create_eval_completions_run_data_source.rbs +22 -22
  175. data/sig/openai/models/responses/input_item_list_params.rbs +0 -7
  176. data/sig/openai/models/responses/response.rbs +15 -0
  177. data/sig/openai/models/responses/response_conversation_param.rbs +15 -0
  178. data/sig/openai/models/responses/response_create_params.rbs +14 -0
  179. data/sig/openai/models/responses/response_function_web_search.rbs +34 -3
  180. data/sig/openai/models/responses/tool.rbs +204 -18
  181. data/sig/openai/models.rbs +2 -0
  182. data/sig/openai/resources/conversations/items.rbs +38 -0
  183. data/sig/openai/resources/conversations.rbs +31 -0
  184. data/sig/openai/resources/responses/input_items.rbs +0 -1
  185. data/sig/openai/resources/responses.rbs +2 -0
  186. metadata +95 -2
@@ -18,10 +18,357 @@ module OpenAI
18
18
  OpenAI::Responses::Tool::ImageGeneration,
19
19
  OpenAI::Responses::Tool::LocalShell,
20
20
  OpenAI::Responses::CustomTool,
21
+ OpenAI::Responses::Tool::WebSearchTool,
21
22
  OpenAI::Responses::WebSearchTool
22
23
  )
23
24
  end
24
25
 
26
+ class WebSearchTool < OpenAI::Internal::Type::BaseModel
27
+ OrHash =
28
+ T.type_alias do
29
+ T.any(
30
+ OpenAI::Responses::Tool::WebSearchTool,
31
+ OpenAI::Internal::AnyHash
32
+ )
33
+ end
34
+
35
+ # The type of the web search tool. One of `web_search` or `web_search_2025_08_26`.
36
+ sig do
37
+ returns(OpenAI::Responses::Tool::WebSearchTool::Type::OrSymbol)
38
+ end
39
+ attr_accessor :type
40
+
41
+ # Filters for the search.
42
+ sig do
43
+ returns(T.nilable(OpenAI::Responses::Tool::WebSearchTool::Filters))
44
+ end
45
+ attr_reader :filters
46
+
47
+ sig do
48
+ params(
49
+ filters:
50
+ T.nilable(
51
+ OpenAI::Responses::Tool::WebSearchTool::Filters::OrHash
52
+ )
53
+ ).void
54
+ end
55
+ attr_writer :filters
56
+
57
+ # High level guidance for the amount of context window space to use for the
58
+ # search. One of `low`, `medium`, or `high`. `medium` is the default.
59
+ sig do
60
+ returns(
61
+ T.nilable(
62
+ OpenAI::Responses::Tool::WebSearchTool::SearchContextSize::OrSymbol
63
+ )
64
+ )
65
+ end
66
+ attr_reader :search_context_size
67
+
68
+ sig do
69
+ params(
70
+ search_context_size:
71
+ OpenAI::Responses::Tool::WebSearchTool::SearchContextSize::OrSymbol
72
+ ).void
73
+ end
74
+ attr_writer :search_context_size
75
+
76
+ # The approximate location of the user.
77
+ sig do
78
+ returns(
79
+ T.nilable(OpenAI::Responses::Tool::WebSearchTool::UserLocation)
80
+ )
81
+ end
82
+ attr_reader :user_location
83
+
84
+ sig do
85
+ params(
86
+ user_location:
87
+ T.nilable(
88
+ OpenAI::Responses::Tool::WebSearchTool::UserLocation::OrHash
89
+ )
90
+ ).void
91
+ end
92
+ attr_writer :user_location
93
+
94
+ # Search the Internet for sources related to the prompt. Learn more about the
95
+ # [web search tool](https://platform.openai.com/docs/guides/tools-web-search).
96
+ sig do
97
+ params(
98
+ type: OpenAI::Responses::Tool::WebSearchTool::Type::OrSymbol,
99
+ filters:
100
+ T.nilable(
101
+ OpenAI::Responses::Tool::WebSearchTool::Filters::OrHash
102
+ ),
103
+ search_context_size:
104
+ OpenAI::Responses::Tool::WebSearchTool::SearchContextSize::OrSymbol,
105
+ user_location:
106
+ T.nilable(
107
+ OpenAI::Responses::Tool::WebSearchTool::UserLocation::OrHash
108
+ )
109
+ ).returns(T.attached_class)
110
+ end
111
+ def self.new(
112
+ # The type of the web search tool. One of `web_search` or `web_search_2025_08_26`.
113
+ type:,
114
+ # Filters for the search.
115
+ filters: nil,
116
+ # High level guidance for the amount of context window space to use for the
117
+ # search. One of `low`, `medium`, or `high`. `medium` is the default.
118
+ search_context_size: nil,
119
+ # The approximate location of the user.
120
+ user_location: nil
121
+ )
122
+ end
123
+
124
+ sig do
125
+ override.returns(
126
+ {
127
+ type: OpenAI::Responses::Tool::WebSearchTool::Type::OrSymbol,
128
+ filters:
129
+ T.nilable(OpenAI::Responses::Tool::WebSearchTool::Filters),
130
+ search_context_size:
131
+ OpenAI::Responses::Tool::WebSearchTool::SearchContextSize::OrSymbol,
132
+ user_location:
133
+ T.nilable(
134
+ OpenAI::Responses::Tool::WebSearchTool::UserLocation
135
+ )
136
+ }
137
+ )
138
+ end
139
+ def to_hash
140
+ end
141
+
142
+ # The type of the web search tool. One of `web_search` or `web_search_2025_08_26`.
143
+ module Type
144
+ extend OpenAI::Internal::Type::Enum
145
+
146
+ TaggedSymbol =
147
+ T.type_alias do
148
+ T.all(Symbol, OpenAI::Responses::Tool::WebSearchTool::Type)
149
+ end
150
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
151
+
152
+ WEB_SEARCH =
153
+ T.let(
154
+ :web_search,
155
+ OpenAI::Responses::Tool::WebSearchTool::Type::TaggedSymbol
156
+ )
157
+ WEB_SEARCH_2025_08_26 =
158
+ T.let(
159
+ :web_search_2025_08_26,
160
+ OpenAI::Responses::Tool::WebSearchTool::Type::TaggedSymbol
161
+ )
162
+
163
+ sig do
164
+ override.returns(
165
+ T::Array[
166
+ OpenAI::Responses::Tool::WebSearchTool::Type::TaggedSymbol
167
+ ]
168
+ )
169
+ end
170
+ def self.values
171
+ end
172
+ end
173
+
174
+ class Filters < OpenAI::Internal::Type::BaseModel
175
+ OrHash =
176
+ T.type_alias do
177
+ T.any(
178
+ OpenAI::Responses::Tool::WebSearchTool::Filters,
179
+ OpenAI::Internal::AnyHash
180
+ )
181
+ end
182
+
183
+ # Allowed domains for the search. If not provided, all domains are allowed.
184
+ # Subdomains of the provided domains are allowed as well.
185
+ #
186
+ # Example: `["pubmed.ncbi.nlm.nih.gov"]`
187
+ sig { returns(T.nilable(T::Array[String])) }
188
+ attr_accessor :allowed_domains
189
+
190
+ # Filters for the search.
191
+ sig do
192
+ params(allowed_domains: T.nilable(T::Array[String])).returns(
193
+ T.attached_class
194
+ )
195
+ end
196
+ def self.new(
197
+ # Allowed domains for the search. If not provided, all domains are allowed.
198
+ # Subdomains of the provided domains are allowed as well.
199
+ #
200
+ # Example: `["pubmed.ncbi.nlm.nih.gov"]`
201
+ allowed_domains: nil
202
+ )
203
+ end
204
+
205
+ sig do
206
+ override.returns({ allowed_domains: T.nilable(T::Array[String]) })
207
+ end
208
+ def to_hash
209
+ end
210
+ end
211
+
212
+ # High level guidance for the amount of context window space to use for the
213
+ # search. One of `low`, `medium`, or `high`. `medium` is the default.
214
+ module SearchContextSize
215
+ extend OpenAI::Internal::Type::Enum
216
+
217
+ TaggedSymbol =
218
+ T.type_alias do
219
+ T.all(
220
+ Symbol,
221
+ OpenAI::Responses::Tool::WebSearchTool::SearchContextSize
222
+ )
223
+ end
224
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
225
+
226
+ LOW =
227
+ T.let(
228
+ :low,
229
+ OpenAI::Responses::Tool::WebSearchTool::SearchContextSize::TaggedSymbol
230
+ )
231
+ MEDIUM =
232
+ T.let(
233
+ :medium,
234
+ OpenAI::Responses::Tool::WebSearchTool::SearchContextSize::TaggedSymbol
235
+ )
236
+ HIGH =
237
+ T.let(
238
+ :high,
239
+ OpenAI::Responses::Tool::WebSearchTool::SearchContextSize::TaggedSymbol
240
+ )
241
+
242
+ sig do
243
+ override.returns(
244
+ T::Array[
245
+ OpenAI::Responses::Tool::WebSearchTool::SearchContextSize::TaggedSymbol
246
+ ]
247
+ )
248
+ end
249
+ def self.values
250
+ end
251
+ end
252
+
253
+ class UserLocation < OpenAI::Internal::Type::BaseModel
254
+ OrHash =
255
+ T.type_alias do
256
+ T.any(
257
+ OpenAI::Responses::Tool::WebSearchTool::UserLocation,
258
+ OpenAI::Internal::AnyHash
259
+ )
260
+ end
261
+
262
+ # Free text input for the city of the user, e.g. `San Francisco`.
263
+ sig { returns(T.nilable(String)) }
264
+ attr_accessor :city
265
+
266
+ # The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of
267
+ # the user, e.g. `US`.
268
+ sig { returns(T.nilable(String)) }
269
+ attr_accessor :country
270
+
271
+ # Free text input for the region of the user, e.g. `California`.
272
+ sig { returns(T.nilable(String)) }
273
+ attr_accessor :region
274
+
275
+ # The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the
276
+ # user, e.g. `America/Los_Angeles`.
277
+ sig { returns(T.nilable(String)) }
278
+ attr_accessor :timezone
279
+
280
+ # The type of location approximation. Always `approximate`.
281
+ sig do
282
+ returns(
283
+ T.nilable(
284
+ OpenAI::Responses::Tool::WebSearchTool::UserLocation::Type::OrSymbol
285
+ )
286
+ )
287
+ end
288
+ attr_reader :type
289
+
290
+ sig do
291
+ params(
292
+ type:
293
+ OpenAI::Responses::Tool::WebSearchTool::UserLocation::Type::OrSymbol
294
+ ).void
295
+ end
296
+ attr_writer :type
297
+
298
+ # The approximate location of the user.
299
+ sig do
300
+ params(
301
+ city: T.nilable(String),
302
+ country: T.nilable(String),
303
+ region: T.nilable(String),
304
+ timezone: T.nilable(String),
305
+ type:
306
+ OpenAI::Responses::Tool::WebSearchTool::UserLocation::Type::OrSymbol
307
+ ).returns(T.attached_class)
308
+ end
309
+ def self.new(
310
+ # Free text input for the city of the user, e.g. `San Francisco`.
311
+ city: nil,
312
+ # The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of
313
+ # the user, e.g. `US`.
314
+ country: nil,
315
+ # Free text input for the region of the user, e.g. `California`.
316
+ region: nil,
317
+ # The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the
318
+ # user, e.g. `America/Los_Angeles`.
319
+ timezone: nil,
320
+ # The type of location approximation. Always `approximate`.
321
+ type: nil
322
+ )
323
+ end
324
+
325
+ sig do
326
+ override.returns(
327
+ {
328
+ city: T.nilable(String),
329
+ country: T.nilable(String),
330
+ region: T.nilable(String),
331
+ timezone: T.nilable(String),
332
+ type:
333
+ OpenAI::Responses::Tool::WebSearchTool::UserLocation::Type::OrSymbol
334
+ }
335
+ )
336
+ end
337
+ def to_hash
338
+ end
339
+
340
+ # The type of location approximation. Always `approximate`.
341
+ module Type
342
+ extend OpenAI::Internal::Type::Enum
343
+
344
+ TaggedSymbol =
345
+ T.type_alias do
346
+ T.all(
347
+ Symbol,
348
+ OpenAI::Responses::Tool::WebSearchTool::UserLocation::Type
349
+ )
350
+ end
351
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
352
+
353
+ APPROXIMATE =
354
+ T.let(
355
+ :approximate,
356
+ OpenAI::Responses::Tool::WebSearchTool::UserLocation::Type::TaggedSymbol
357
+ )
358
+
359
+ sig do
360
+ override.returns(
361
+ T::Array[
362
+ OpenAI::Responses::Tool::WebSearchTool::UserLocation::Type::TaggedSymbol
363
+ ]
364
+ )
365
+ end
366
+ def self.values
367
+ end
368
+ end
369
+ end
370
+ end
371
+
25
372
  class Mcp < OpenAI::Internal::Type::BaseModel
26
373
  OrHash =
27
374
  T.type_alias do
@@ -32,10 +379,6 @@ module OpenAI
32
379
  sig { returns(String) }
33
380
  attr_accessor :server_label
34
381
 
35
- # The URL for the MCP server.
36
- sig { returns(String) }
37
- attr_accessor :server_url
38
-
39
382
  # The type of the MCP tool. Always `mcp`.
40
383
  sig { returns(Symbol) }
41
384
  attr_accessor :type
@@ -46,13 +389,51 @@ module OpenAI
46
389
  T.nilable(
47
390
  T.any(
48
391
  T::Array[String],
49
- OpenAI::Responses::Tool::Mcp::AllowedTools::McpAllowedToolsFilter
392
+ OpenAI::Responses::Tool::Mcp::AllowedTools::McpToolFilter
50
393
  )
51
394
  )
52
395
  )
53
396
  end
54
397
  attr_accessor :allowed_tools
55
398
 
399
+ # An OAuth access token that can be used with a remote MCP server, either with a
400
+ # custom MCP server URL or a service connector. Your application must handle the
401
+ # OAuth authorization flow and provide the token here.
402
+ sig { returns(T.nilable(String)) }
403
+ attr_reader :authorization
404
+
405
+ sig { params(authorization: String).void }
406
+ attr_writer :authorization
407
+
408
+ # Identifier for service connectors, like those available in ChatGPT. One of
409
+ # `server_url` or `connector_id` must be provided. Learn more about service
410
+ # connectors
411
+ # [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).
412
+ #
413
+ # Currently supported `connector_id` values are:
414
+ #
415
+ # - Dropbox: `connector_dropbox`
416
+ # - Gmail: `connector_gmail`
417
+ # - Google Calendar: `connector_googlecalendar`
418
+ # - Google Drive: `connector_googledrive`
419
+ # - Microsoft Teams: `connector_microsoftteams`
420
+ # - Outlook Calendar: `connector_outlookcalendar`
421
+ # - Outlook Email: `connector_outlookemail`
422
+ # - SharePoint: `connector_sharepoint`
423
+ sig do
424
+ returns(
425
+ T.nilable(OpenAI::Responses::Tool::Mcp::ConnectorID::OrSymbol)
426
+ )
427
+ end
428
+ attr_reader :connector_id
429
+
430
+ sig do
431
+ params(
432
+ connector_id: OpenAI::Responses::Tool::Mcp::ConnectorID::OrSymbol
433
+ ).void
434
+ end
435
+ attr_writer :connector_id
436
+
56
437
  # Optional HTTP headers to send to the MCP server. Use for authentication or other
57
438
  # purposes.
58
439
  sig { returns(T.nilable(T::Hash[Symbol, String])) }
@@ -78,20 +459,29 @@ module OpenAI
78
459
  sig { params(server_description: String).void }
79
460
  attr_writer :server_description
80
461
 
462
+ # The URL for the MCP server. One of `server_url` or `connector_id` must be
463
+ # provided.
464
+ sig { returns(T.nilable(String)) }
465
+ attr_reader :server_url
466
+
467
+ sig { params(server_url: String).void }
468
+ attr_writer :server_url
469
+
81
470
  # Give the model access to additional tools via remote Model Context Protocol
82
471
  # (MCP) servers.
83
472
  # [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).
84
473
  sig do
85
474
  params(
86
475
  server_label: String,
87
- server_url: String,
88
476
  allowed_tools:
89
477
  T.nilable(
90
478
  T.any(
91
479
  T::Array[String],
92
- OpenAI::Responses::Tool::Mcp::AllowedTools::McpAllowedToolsFilter::OrHash
480
+ OpenAI::Responses::Tool::Mcp::AllowedTools::McpToolFilter::OrHash
93
481
  )
94
482
  ),
483
+ authorization: String,
484
+ connector_id: OpenAI::Responses::Tool::Mcp::ConnectorID::OrSymbol,
95
485
  headers: T.nilable(T::Hash[Symbol, String]),
96
486
  require_approval:
97
487
  T.nilable(
@@ -101,16 +491,35 @@ module OpenAI
101
491
  )
102
492
  ),
103
493
  server_description: String,
494
+ server_url: String,
104
495
  type: Symbol
105
496
  ).returns(T.attached_class)
106
497
  end
107
498
  def self.new(
108
499
  # A label for this MCP server, used to identify it in tool calls.
109
500
  server_label:,
110
- # The URL for the MCP server.
111
- server_url:,
112
501
  # List of allowed tool names or a filter object.
113
502
  allowed_tools: nil,
503
+ # An OAuth access token that can be used with a remote MCP server, either with a
504
+ # custom MCP server URL or a service connector. Your application must handle the
505
+ # OAuth authorization flow and provide the token here.
506
+ authorization: nil,
507
+ # Identifier for service connectors, like those available in ChatGPT. One of
508
+ # `server_url` or `connector_id` must be provided. Learn more about service
509
+ # connectors
510
+ # [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).
511
+ #
512
+ # Currently supported `connector_id` values are:
513
+ #
514
+ # - Dropbox: `connector_dropbox`
515
+ # - Gmail: `connector_gmail`
516
+ # - Google Calendar: `connector_googlecalendar`
517
+ # - Google Drive: `connector_googledrive`
518
+ # - Microsoft Teams: `connector_microsoftteams`
519
+ # - Outlook Calendar: `connector_outlookcalendar`
520
+ # - Outlook Email: `connector_outlookemail`
521
+ # - SharePoint: `connector_sharepoint`
522
+ connector_id: nil,
114
523
  # Optional HTTP headers to send to the MCP server. Use for authentication or other
115
524
  # purposes.
116
525
  headers: nil,
@@ -118,6 +527,9 @@ module OpenAI
118
527
  require_approval: nil,
119
528
  # Optional description of the MCP server, used to provide more context.
120
529
  server_description: nil,
530
+ # The URL for the MCP server. One of `server_url` or `connector_id` must be
531
+ # provided.
532
+ server_url: nil,
121
533
  # The type of the MCP tool. Always `mcp`.
122
534
  type: :mcp
123
535
  )
@@ -127,15 +539,17 @@ module OpenAI
127
539
  override.returns(
128
540
  {
129
541
  server_label: String,
130
- server_url: String,
131
542
  type: Symbol,
132
543
  allowed_tools:
133
544
  T.nilable(
134
545
  T.any(
135
546
  T::Array[String],
136
- OpenAI::Responses::Tool::Mcp::AllowedTools::McpAllowedToolsFilter
547
+ OpenAI::Responses::Tool::Mcp::AllowedTools::McpToolFilter
137
548
  )
138
549
  ),
550
+ authorization: String,
551
+ connector_id:
552
+ OpenAI::Responses::Tool::Mcp::ConnectorID::OrSymbol,
139
553
  headers: T.nilable(T::Hash[Symbol, String]),
140
554
  require_approval:
141
555
  T.nilable(
@@ -144,7 +558,8 @@ module OpenAI
144
558
  OpenAI::Responses::Tool::Mcp::RequireApproval::McpToolApprovalSetting::OrSymbol
145
559
  )
146
560
  ),
147
- server_description: String
561
+ server_description: String,
562
+ server_url: String
148
563
  }
149
564
  )
150
565
  end
@@ -159,19 +574,29 @@ module OpenAI
159
574
  T.type_alias do
160
575
  T.any(
161
576
  T::Array[String],
162
- OpenAI::Responses::Tool::Mcp::AllowedTools::McpAllowedToolsFilter
577
+ OpenAI::Responses::Tool::Mcp::AllowedTools::McpToolFilter
163
578
  )
164
579
  end
165
580
 
166
- class McpAllowedToolsFilter < OpenAI::Internal::Type::BaseModel
581
+ class McpToolFilter < OpenAI::Internal::Type::BaseModel
167
582
  OrHash =
168
583
  T.type_alias do
169
584
  T.any(
170
- OpenAI::Responses::Tool::Mcp::AllowedTools::McpAllowedToolsFilter,
585
+ OpenAI::Responses::Tool::Mcp::AllowedTools::McpToolFilter,
171
586
  OpenAI::Internal::AnyHash
172
587
  )
173
588
  end
174
589
 
590
+ # Indicates whether or not a tool modifies data or is read-only. If an MCP server
591
+ # is
592
+ # [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
593
+ # it will match this filter.
594
+ sig { returns(T.nilable(T::Boolean)) }
595
+ attr_reader :read_only
596
+
597
+ sig { params(read_only: T::Boolean).void }
598
+ attr_writer :read_only
599
+
175
600
  # List of allowed tool names.
176
601
  sig { returns(T.nilable(T::Array[String])) }
177
602
  attr_reader :tool_names
@@ -181,15 +606,27 @@ module OpenAI
181
606
 
182
607
  # A filter object to specify which tools are allowed.
183
608
  sig do
184
- params(tool_names: T::Array[String]).returns(T.attached_class)
609
+ params(
610
+ read_only: T::Boolean,
611
+ tool_names: T::Array[String]
612
+ ).returns(T.attached_class)
185
613
  end
186
614
  def self.new(
615
+ # Indicates whether or not a tool modifies data or is read-only. If an MCP server
616
+ # is
617
+ # [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
618
+ # it will match this filter.
619
+ read_only: nil,
187
620
  # List of allowed tool names.
188
621
  tool_names: nil
189
622
  )
190
623
  end
191
624
 
192
- sig { override.returns({ tool_names: T::Array[String] }) }
625
+ sig do
626
+ override.returns(
627
+ { read_only: T::Boolean, tool_names: T::Array[String] }
628
+ )
629
+ end
193
630
  def to_hash
194
631
  end
195
632
  end
@@ -209,6 +646,82 @@ module OpenAI
209
646
  )
210
647
  end
211
648
 
649
+ # Identifier for service connectors, like those available in ChatGPT. One of
650
+ # `server_url` or `connector_id` must be provided. Learn more about service
651
+ # connectors
652
+ # [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).
653
+ #
654
+ # Currently supported `connector_id` values are:
655
+ #
656
+ # - Dropbox: `connector_dropbox`
657
+ # - Gmail: `connector_gmail`
658
+ # - Google Calendar: `connector_googlecalendar`
659
+ # - Google Drive: `connector_googledrive`
660
+ # - Microsoft Teams: `connector_microsoftteams`
661
+ # - Outlook Calendar: `connector_outlookcalendar`
662
+ # - Outlook Email: `connector_outlookemail`
663
+ # - SharePoint: `connector_sharepoint`
664
+ module ConnectorID
665
+ extend OpenAI::Internal::Type::Enum
666
+
667
+ TaggedSymbol =
668
+ T.type_alias do
669
+ T.all(Symbol, OpenAI::Responses::Tool::Mcp::ConnectorID)
670
+ end
671
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
672
+
673
+ CONNECTOR_DROPBOX =
674
+ T.let(
675
+ :connector_dropbox,
676
+ OpenAI::Responses::Tool::Mcp::ConnectorID::TaggedSymbol
677
+ )
678
+ CONNECTOR_GMAIL =
679
+ T.let(
680
+ :connector_gmail,
681
+ OpenAI::Responses::Tool::Mcp::ConnectorID::TaggedSymbol
682
+ )
683
+ CONNECTOR_GOOGLECALENDAR =
684
+ T.let(
685
+ :connector_googlecalendar,
686
+ OpenAI::Responses::Tool::Mcp::ConnectorID::TaggedSymbol
687
+ )
688
+ CONNECTOR_GOOGLEDRIVE =
689
+ T.let(
690
+ :connector_googledrive,
691
+ OpenAI::Responses::Tool::Mcp::ConnectorID::TaggedSymbol
692
+ )
693
+ CONNECTOR_MICROSOFTTEAMS =
694
+ T.let(
695
+ :connector_microsoftteams,
696
+ OpenAI::Responses::Tool::Mcp::ConnectorID::TaggedSymbol
697
+ )
698
+ CONNECTOR_OUTLOOKCALENDAR =
699
+ T.let(
700
+ :connector_outlookcalendar,
701
+ OpenAI::Responses::Tool::Mcp::ConnectorID::TaggedSymbol
702
+ )
703
+ CONNECTOR_OUTLOOKEMAIL =
704
+ T.let(
705
+ :connector_outlookemail,
706
+ OpenAI::Responses::Tool::Mcp::ConnectorID::TaggedSymbol
707
+ )
708
+ CONNECTOR_SHAREPOINT =
709
+ T.let(
710
+ :connector_sharepoint,
711
+ OpenAI::Responses::Tool::Mcp::ConnectorID::TaggedSymbol
712
+ )
713
+
714
+ sig do
715
+ override.returns(
716
+ T::Array[
717
+ OpenAI::Responses::Tool::Mcp::ConnectorID::TaggedSymbol
718
+ ]
719
+ )
720
+ end
721
+ def self.values
722
+ end
723
+ end
724
+
212
725
  # Specify which of the MCP server's tools require approval.
213
726
  module RequireApproval
214
727
  extend OpenAI::Internal::Type::Union
@@ -230,7 +743,7 @@ module OpenAI
230
743
  )
231
744
  end
232
745
 
233
- # A list of tools that always require approval.
746
+ # A filter object to specify which tools are allowed.
234
747
  sig do
235
748
  returns(
236
749
  T.nilable(
@@ -248,7 +761,7 @@ module OpenAI
248
761
  end
249
762
  attr_writer :always
250
763
 
251
- # A list of tools that never require approval.
764
+ # A filter object to specify which tools are allowed.
252
765
  sig do
253
766
  returns(
254
767
  T.nilable(
@@ -266,6 +779,8 @@ module OpenAI
266
779
  end
267
780
  attr_writer :never
268
781
 
782
+ # Specify which of the MCP server's tools require approval. Can be `always`,
783
+ # `never`, or a filter object associated with tools that require approval.
269
784
  sig do
270
785
  params(
271
786
  always:
@@ -275,9 +790,9 @@ module OpenAI
275
790
  ).returns(T.attached_class)
276
791
  end
277
792
  def self.new(
278
- # A list of tools that always require approval.
793
+ # A filter object to specify which tools are allowed.
279
794
  always: nil,
280
- # A list of tools that never require approval.
795
+ # A filter object to specify which tools are allowed.
281
796
  never: nil
282
797
  )
283
798
  end
@@ -304,24 +819,46 @@ module OpenAI
304
819
  )
305
820
  end
306
821
 
307
- # List of tools that require approval.
822
+ # Indicates whether or not a tool modifies data or is read-only. If an MCP server
823
+ # is
824
+ # [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
825
+ # it will match this filter.
826
+ sig { returns(T.nilable(T::Boolean)) }
827
+ attr_reader :read_only
828
+
829
+ sig { params(read_only: T::Boolean).void }
830
+ attr_writer :read_only
831
+
832
+ # List of allowed tool names.
308
833
  sig { returns(T.nilable(T::Array[String])) }
309
834
  attr_reader :tool_names
310
835
 
311
836
  sig { params(tool_names: T::Array[String]).void }
312
837
  attr_writer :tool_names
313
838
 
314
- # A list of tools that always require approval.
839
+ # A filter object to specify which tools are allowed.
315
840
  sig do
316
- params(tool_names: T::Array[String]).returns(T.attached_class)
841
+ params(
842
+ read_only: T::Boolean,
843
+ tool_names: T::Array[String]
844
+ ).returns(T.attached_class)
317
845
  end
318
846
  def self.new(
319
- # List of tools that require approval.
847
+ # Indicates whether or not a tool modifies data or is read-only. If an MCP server
848
+ # is
849
+ # [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
850
+ # it will match this filter.
851
+ read_only: nil,
852
+ # List of allowed tool names.
320
853
  tool_names: nil
321
854
  )
322
855
  end
323
856
 
324
- sig { override.returns({ tool_names: T::Array[String] }) }
857
+ sig do
858
+ override.returns(
859
+ { read_only: T::Boolean, tool_names: T::Array[String] }
860
+ )
861
+ end
325
862
  def to_hash
326
863
  end
327
864
  end
@@ -335,24 +872,46 @@ module OpenAI
335
872
  )
336
873
  end
337
874
 
338
- # List of tools that do not require approval.
875
+ # Indicates whether or not a tool modifies data or is read-only. If an MCP server
876
+ # is
877
+ # [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
878
+ # it will match this filter.
879
+ sig { returns(T.nilable(T::Boolean)) }
880
+ attr_reader :read_only
881
+
882
+ sig { params(read_only: T::Boolean).void }
883
+ attr_writer :read_only
884
+
885
+ # List of allowed tool names.
339
886
  sig { returns(T.nilable(T::Array[String])) }
340
887
  attr_reader :tool_names
341
888
 
342
889
  sig { params(tool_names: T::Array[String]).void }
343
890
  attr_writer :tool_names
344
891
 
345
- # A list of tools that never require approval.
892
+ # A filter object to specify which tools are allowed.
346
893
  sig do
347
- params(tool_names: T::Array[String]).returns(T.attached_class)
894
+ params(
895
+ read_only: T::Boolean,
896
+ tool_names: T::Array[String]
897
+ ).returns(T.attached_class)
348
898
  end
349
899
  def self.new(
350
- # List of tools that do not require approval.
900
+ # Indicates whether or not a tool modifies data or is read-only. If an MCP server
901
+ # is
902
+ # [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
903
+ # it will match this filter.
904
+ read_only: nil,
905
+ # List of allowed tool names.
351
906
  tool_names: nil
352
907
  )
353
908
  end
354
909
 
355
- sig { override.returns({ tool_names: T::Array[String] }) }
910
+ sig do
911
+ override.returns(
912
+ { read_only: T::Boolean, tool_names: T::Array[String] }
913
+ )
914
+ end
356
915
  def to_hash
357
916
  end
358
917
  end