openai 0.9.0 → 0.11.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +40 -0
- data/README.md +79 -1
- data/lib/openai/client.rb +11 -0
- data/lib/openai/errors.rb +25 -0
- data/lib/openai/internal/type/array_of.rb +6 -1
- data/lib/openai/internal/type/base_model.rb +76 -24
- data/lib/openai/internal/type/boolean.rb +7 -1
- data/lib/openai/internal/type/converter.rb +42 -34
- data/lib/openai/internal/type/enum.rb +10 -2
- data/lib/openai/internal/type/file_input.rb +6 -1
- data/lib/openai/internal/type/hash_of.rb +6 -1
- data/lib/openai/internal/type/union.rb +12 -7
- data/lib/openai/internal/type/unknown.rb +7 -1
- data/lib/openai/models/all_models.rb +4 -0
- data/lib/openai/models/audio/speech_create_params.rb +23 -2
- data/lib/openai/models/audio/transcription.rb +118 -1
- data/lib/openai/models/audio/transcription_text_done_event.rb +80 -1
- data/lib/openai/models/audio/transcription_verbose.rb +31 -1
- data/lib/openai/models/chat/chat_completion.rb +32 -31
- data/lib/openai/models/chat/chat_completion_chunk.rb +30 -29
- data/lib/openai/models/chat/completion_create_params.rb +34 -31
- data/lib/openai/models/fine_tuning/checkpoints/permission_retrieve_response.rb +60 -25
- data/lib/openai/models/images_response.rb +92 -1
- data/lib/openai/models/responses/response.rb +59 -35
- data/lib/openai/models/responses/response_code_interpreter_call_code_delta_event.rb +17 -8
- data/lib/openai/models/responses/response_code_interpreter_call_code_done_event.rb +14 -10
- data/lib/openai/models/responses/response_code_interpreter_call_completed_event.rb +11 -10
- data/lib/openai/models/responses/response_code_interpreter_call_in_progress_event.rb +11 -10
- data/lib/openai/models/responses/response_code_interpreter_call_interpreting_event.rb +11 -10
- data/lib/openai/models/responses/response_code_interpreter_tool_call.rb +49 -78
- data/lib/openai/models/responses/response_create_params.rb +92 -67
- data/lib/openai/models/responses/response_function_web_search.rb +115 -1
- data/lib/openai/models/responses/response_includable.rb +8 -6
- data/lib/openai/models/responses/response_output_text.rb +18 -2
- data/lib/openai/models/responses/response_stream_event.rb +2 -2
- data/lib/openai/models/responses/tool_choice_mcp.rb +40 -0
- data/lib/openai/models/responses/tool_choice_types.rb +0 -3
- data/lib/openai/models/responses_model.rb +4 -0
- data/lib/openai/models/webhooks/batch_cancelled_webhook_event.rb +84 -0
- data/lib/openai/models/webhooks/batch_completed_webhook_event.rb +84 -0
- data/lib/openai/models/webhooks/batch_expired_webhook_event.rb +84 -0
- data/lib/openai/models/webhooks/batch_failed_webhook_event.rb +84 -0
- data/lib/openai/models/webhooks/eval_run_canceled_webhook_event.rb +84 -0
- data/lib/openai/models/webhooks/eval_run_failed_webhook_event.rb +84 -0
- data/lib/openai/models/webhooks/eval_run_succeeded_webhook_event.rb +84 -0
- data/lib/openai/models/webhooks/fine_tuning_job_cancelled_webhook_event.rb +85 -0
- data/lib/openai/models/webhooks/fine_tuning_job_failed_webhook_event.rb +85 -0
- data/lib/openai/models/webhooks/fine_tuning_job_succeeded_webhook_event.rb +85 -0
- data/lib/openai/models/webhooks/response_cancelled_webhook_event.rb +85 -0
- data/lib/openai/models/webhooks/response_completed_webhook_event.rb +85 -0
- data/lib/openai/models/webhooks/response_failed_webhook_event.rb +84 -0
- data/lib/openai/models/webhooks/response_incomplete_webhook_event.rb +85 -0
- data/lib/openai/models/webhooks/unwrap_webhook_event.rb +59 -0
- data/lib/openai/models/webhooks/webhook_unwrap_params.rb +16 -0
- data/lib/openai/models.rb +2 -0
- data/lib/openai/resources/audio/speech.rb +3 -1
- data/lib/openai/resources/chat/completions.rb +10 -2
- data/lib/openai/resources/fine_tuning/checkpoints/permissions.rb +1 -2
- data/lib/openai/resources/responses.rb +24 -16
- data/lib/openai/resources/webhooks.rb +124 -0
- data/lib/openai/version.rb +1 -1
- data/lib/openai.rb +18 -0
- data/rbi/openai/client.rbi +3 -0
- data/rbi/openai/errors.rbi +16 -0
- data/rbi/openai/internal/type/boolean.rbi +2 -0
- data/rbi/openai/internal/type/converter.rbi +15 -15
- data/rbi/openai/internal/type/union.rbi +5 -0
- data/rbi/openai/internal/type/unknown.rbi +2 -0
- data/rbi/openai/models/all_models.rbi +20 -0
- data/rbi/openai/models/audio/speech_create_params.rbi +59 -2
- data/rbi/openai/models/audio/transcription.rbi +213 -3
- data/rbi/openai/models/audio/transcription_text_done_event.rbi +146 -1
- data/rbi/openai/models/audio/transcription_verbose.rbi +47 -0
- data/rbi/openai/models/chat/chat_completion.rbi +47 -42
- data/rbi/openai/models/chat/chat_completion_chunk.rbi +47 -42
- data/rbi/openai/models/chat/completion_create_params.rbi +51 -42
- data/rbi/openai/models/fine_tuning/checkpoints/permission_retrieve_response.rbi +95 -26
- data/rbi/openai/models/images_response.rbi +146 -0
- data/rbi/openai/models/responses/response.rbi +75 -44
- data/rbi/openai/models/responses/response_code_interpreter_call_code_delta_event.rbi +17 -7
- data/rbi/openai/models/responses/response_code_interpreter_call_code_done_event.rbi +13 -5
- data/rbi/openai/models/responses/response_code_interpreter_call_completed_event.rbi +13 -21
- data/rbi/openai/models/responses/response_code_interpreter_call_in_progress_event.rbi +13 -21
- data/rbi/openai/models/responses/response_code_interpreter_call_interpreting_event.rbi +13 -21
- data/rbi/openai/models/responses/response_code_interpreter_tool_call.rbi +83 -125
- data/rbi/openai/models/responses/response_create_params.rbi +174 -115
- data/rbi/openai/models/responses/response_function_web_search.rbi +163 -0
- data/rbi/openai/models/responses/response_includable.rbi +17 -11
- data/rbi/openai/models/responses/response_output_text.rbi +26 -4
- data/rbi/openai/models/responses/tool_choice_mcp.rbi +53 -0
- data/rbi/openai/models/responses/tool_choice_types.rbi +0 -5
- data/rbi/openai/models/responses_model.rbi +20 -0
- data/rbi/openai/models/webhooks/batch_cancelled_webhook_event.rbi +154 -0
- data/rbi/openai/models/webhooks/batch_completed_webhook_event.rbi +154 -0
- data/rbi/openai/models/webhooks/batch_expired_webhook_event.rbi +150 -0
- data/rbi/openai/models/webhooks/batch_failed_webhook_event.rbi +149 -0
- data/rbi/openai/models/webhooks/eval_run_canceled_webhook_event.rbi +154 -0
- data/rbi/openai/models/webhooks/eval_run_failed_webhook_event.rbi +151 -0
- data/rbi/openai/models/webhooks/eval_run_succeeded_webhook_event.rbi +154 -0
- data/rbi/openai/models/webhooks/fine_tuning_job_cancelled_webhook_event.rbi +158 -0
- data/rbi/openai/models/webhooks/fine_tuning_job_failed_webhook_event.rbi +156 -0
- data/rbi/openai/models/webhooks/fine_tuning_job_succeeded_webhook_event.rbi +158 -0
- data/rbi/openai/models/webhooks/response_cancelled_webhook_event.rbi +154 -0
- data/rbi/openai/models/webhooks/response_completed_webhook_event.rbi +154 -0
- data/rbi/openai/models/webhooks/response_failed_webhook_event.rbi +154 -0
- data/rbi/openai/models/webhooks/response_incomplete_webhook_event.rbi +155 -0
- data/rbi/openai/models/webhooks/unwrap_webhook_event.rbi +40 -0
- data/rbi/openai/models/webhooks/webhook_unwrap_params.rbi +32 -0
- data/rbi/openai/models.rbi +2 -0
- data/rbi/openai/resources/audio/speech.rbi +6 -1
- data/rbi/openai/resources/chat/completions.rbi +34 -30
- data/rbi/openai/resources/fine_tuning/checkpoints/permissions.rbi +1 -3
- data/rbi/openai/resources/responses.rbi +108 -84
- data/rbi/openai/resources/webhooks.rbi +68 -0
- data/sig/openai/client.rbs +2 -0
- data/sig/openai/errors.rbs +9 -0
- data/sig/openai/internal/type/converter.rbs +7 -1
- data/sig/openai/models/all_models.rbs +8 -0
- data/sig/openai/models/audio/speech_create_params.rbs +21 -1
- data/sig/openai/models/audio/transcription.rbs +95 -3
- data/sig/openai/models/audio/transcription_text_done_event.rbs +72 -2
- data/sig/openai/models/audio/transcription_verbose.rbs +21 -0
- data/sig/openai/models/chat/chat_completion.rbs +2 -1
- data/sig/openai/models/chat/chat_completion_chunk.rbs +2 -1
- data/sig/openai/models/chat/completion_create_params.rbs +2 -1
- data/sig/openai/models/fine_tuning/checkpoints/permission_retrieve_response.rbs +53 -16
- data/sig/openai/models/images_response.rbs +83 -0
- data/sig/openai/models/responses/response.rbs +13 -1
- data/sig/openai/models/responses/response_code_interpreter_call_code_delta_event.rbs +5 -0
- data/sig/openai/models/responses/response_code_interpreter_call_code_done_event.rbs +5 -0
- data/sig/openai/models/responses/response_code_interpreter_call_completed_event.rbs +4 -4
- data/sig/openai/models/responses/response_code_interpreter_call_in_progress_event.rbs +4 -4
- data/sig/openai/models/responses/response_code_interpreter_call_interpreting_event.rbs +4 -4
- data/sig/openai/models/responses/response_code_interpreter_tool_call.rbs +31 -52
- data/sig/openai/models/responses/response_create_params.rbs +31 -11
- data/sig/openai/models/responses/response_function_web_search.rbs +54 -0
- data/sig/openai/models/responses/response_includable.rbs +7 -5
- data/sig/openai/models/responses/response_output_text.rbs +15 -1
- data/sig/openai/models/responses/tool_choice_mcp.rbs +23 -0
- data/sig/openai/models/responses/tool_choice_types.rbs +0 -2
- data/sig/openai/models/responses_model.rbs +8 -0
- data/sig/openai/models/webhooks/batch_cancelled_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/batch_completed_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/batch_expired_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/batch_failed_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/eval_run_canceled_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/eval_run_failed_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/eval_run_succeeded_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/fine_tuning_job_cancelled_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/fine_tuning_job_failed_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/fine_tuning_job_succeeded_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/response_cancelled_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/response_completed_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/response_failed_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/response_incomplete_webhook_event.rbs +66 -0
- data/sig/openai/models/webhooks/unwrap_webhook_event.rbs +27 -0
- data/sig/openai/models/webhooks/webhook_unwrap_params.rbs +17 -0
- data/sig/openai/models.rbs +2 -0
- data/sig/openai/resources/audio/speech.rbs +1 -0
- data/sig/openai/resources/fine_tuning/checkpoints/permissions.rbs +1 -1
- data/sig/openai/resources/responses.rbs +8 -4
- data/sig/openai/resources/webhooks.rbs +33 -0
- metadata +56 -2
@@ -21,21 +21,22 @@ module OpenAI
|
|
21
21
|
# your own data as input for the model's response.
|
22
22
|
sig do
|
23
23
|
params(
|
24
|
-
input: OpenAI::Responses::ResponseCreateParams::Input::Variants,
|
25
|
-
model:
|
26
|
-
T.any(
|
27
|
-
String,
|
28
|
-
OpenAI::ChatModel::OrSymbol,
|
29
|
-
OpenAI::ResponsesModel::ResponsesOnlyModel::OrSymbol
|
30
|
-
),
|
31
24
|
background: T.nilable(T::Boolean),
|
32
25
|
include:
|
33
26
|
T.nilable(
|
34
27
|
T::Array[OpenAI::Responses::ResponseIncludable::OrSymbol]
|
35
28
|
),
|
29
|
+
input: OpenAI::Responses::ResponseCreateParams::Input::Variants,
|
36
30
|
instructions: T.nilable(String),
|
37
31
|
max_output_tokens: T.nilable(Integer),
|
32
|
+
max_tool_calls: T.nilable(Integer),
|
38
33
|
metadata: T.nilable(T::Hash[Symbol, String]),
|
34
|
+
model:
|
35
|
+
T.any(
|
36
|
+
String,
|
37
|
+
OpenAI::ChatModel::OrSymbol,
|
38
|
+
OpenAI::ResponsesModel::ResponsesOnlyModel::OrSymbol
|
39
|
+
),
|
39
40
|
parallel_tool_calls: T.nilable(T::Boolean),
|
40
41
|
previous_response_id: T.nilable(String),
|
41
42
|
prompt: T.nilable(OpenAI::Responses::ResponsePrompt::OrHash),
|
@@ -55,7 +56,8 @@ module OpenAI
|
|
55
56
|
T.any(
|
56
57
|
OpenAI::Responses::ToolChoiceOptions::OrSymbol,
|
57
58
|
OpenAI::Responses::ToolChoiceTypes::OrHash,
|
58
|
-
OpenAI::Responses::ToolChoiceFunction::OrHash
|
59
|
+
OpenAI::Responses::ToolChoiceFunction::OrHash,
|
60
|
+
OpenAI::Responses::ToolChoiceMcp::OrHash
|
59
61
|
),
|
60
62
|
tools:
|
61
63
|
T::Array[
|
@@ -70,6 +72,7 @@ module OpenAI
|
|
70
72
|
OpenAI::Responses::WebSearchTool::OrHash
|
71
73
|
)
|
72
74
|
],
|
75
|
+
top_logprobs: T.nilable(Integer),
|
73
76
|
top_p: T.nilable(Float),
|
74
77
|
truncation:
|
75
78
|
T.nilable(
|
@@ -81,41 +84,36 @@ module OpenAI
|
|
81
84
|
).returns(OpenAI::Responses::Response)
|
82
85
|
end
|
83
86
|
def create(
|
84
|
-
# Text, image, or file inputs to the model, used to generate a response.
|
85
|
-
#
|
86
|
-
# Learn more:
|
87
|
-
#
|
88
|
-
# - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
|
89
|
-
# - [Image inputs](https://platform.openai.com/docs/guides/images)
|
90
|
-
# - [File inputs](https://platform.openai.com/docs/guides/pdf-files)
|
91
|
-
# - [Conversation state](https://platform.openai.com/docs/guides/conversation-state)
|
92
|
-
# - [Function calling](https://platform.openai.com/docs/guides/function-calling)
|
93
|
-
input:,
|
94
|
-
# Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
|
95
|
-
# wide range of models with different capabilities, performance characteristics,
|
96
|
-
# and price points. Refer to the
|
97
|
-
# [model guide](https://platform.openai.com/docs/models) to browse and compare
|
98
|
-
# available models.
|
99
|
-
model:,
|
100
87
|
# Whether to run the model response in the background.
|
101
88
|
# [Learn more](https://platform.openai.com/docs/guides/background).
|
102
89
|
background: nil,
|
103
90
|
# Specify additional output data to include in the model response. Currently
|
104
91
|
# supported values are:
|
105
92
|
#
|
93
|
+
# - `code_interpreter_call.outputs`: Includes the outputs of python code execution
|
94
|
+
# in code interpreter tool call items.
|
95
|
+
# - `computer_call_output.output.image_url`: Include image urls from the computer
|
96
|
+
# call output.
|
106
97
|
# - `file_search_call.results`: Include the search results of the file search tool
|
107
98
|
# call.
|
108
99
|
# - `message.input_image.image_url`: Include image urls from the input message.
|
109
|
-
# - `
|
110
|
-
# call output.
|
100
|
+
# - `message.output_text.logprobs`: Include logprobs with assistant messages.
|
111
101
|
# - `reasoning.encrypted_content`: Includes an encrypted version of reasoning
|
112
102
|
# tokens in reasoning item outputs. This enables reasoning items to be used in
|
113
103
|
# multi-turn conversations when using the Responses API statelessly (like when
|
114
104
|
# the `store` parameter is set to `false`, or when an organization is enrolled
|
115
105
|
# in the zero data retention program).
|
116
|
-
# - `code_interpreter_call.outputs`: Includes the outputs of python code execution
|
117
|
-
# in code interpreter tool call items.
|
118
106
|
include: nil,
|
107
|
+
# Text, image, or file inputs to the model, used to generate a response.
|
108
|
+
#
|
109
|
+
# Learn more:
|
110
|
+
#
|
111
|
+
# - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
|
112
|
+
# - [Image inputs](https://platform.openai.com/docs/guides/images)
|
113
|
+
# - [File inputs](https://platform.openai.com/docs/guides/pdf-files)
|
114
|
+
# - [Conversation state](https://platform.openai.com/docs/guides/conversation-state)
|
115
|
+
# - [Function calling](https://platform.openai.com/docs/guides/function-calling)
|
116
|
+
input: nil,
|
119
117
|
# A system (or developer) message inserted into the model's context.
|
120
118
|
#
|
121
119
|
# When using along with `previous_response_id`, the instructions from a previous
|
@@ -126,6 +124,11 @@ module OpenAI
|
|
126
124
|
# including visible output tokens and
|
127
125
|
# [reasoning tokens](https://platform.openai.com/docs/guides/reasoning).
|
128
126
|
max_output_tokens: nil,
|
127
|
+
# The maximum number of total calls to built-in tools that can be processed in a
|
128
|
+
# response. This maximum number applies across all built-in tool calls, not per
|
129
|
+
# individual tool. Any further attempts to call a tool by the model will be
|
130
|
+
# ignored.
|
131
|
+
max_tool_calls: nil,
|
129
132
|
# Set of 16 key-value pairs that can be attached to an object. This can be useful
|
130
133
|
# for storing additional information about the object in a structured format, and
|
131
134
|
# querying for objects via API or the dashboard.
|
@@ -133,6 +136,12 @@ module OpenAI
|
|
133
136
|
# Keys are strings with a maximum length of 64 characters. Values are strings with
|
134
137
|
# a maximum length of 512 characters.
|
135
138
|
metadata: nil,
|
139
|
+
# Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
|
140
|
+
# wide range of models with different capabilities, performance characteristics,
|
141
|
+
# and price points. Refer to the
|
142
|
+
# [model guide](https://platform.openai.com/docs/models) to browse and compare
|
143
|
+
# available models.
|
144
|
+
model: nil,
|
136
145
|
# Whether to allow the model to run tool calls in parallel.
|
137
146
|
parallel_tool_calls: nil,
|
138
147
|
# The unique ID of the previous response to the model. Use this to create
|
@@ -147,23 +156,23 @@ module OpenAI
|
|
147
156
|
# Configuration options for
|
148
157
|
# [reasoning models](https://platform.openai.com/docs/guides/reasoning).
|
149
158
|
reasoning: nil,
|
150
|
-
# Specifies the
|
151
|
-
# relevant for customers subscribed to the scale tier service:
|
159
|
+
# Specifies the processing type used for serving the request.
|
152
160
|
#
|
153
|
-
# - If set to 'auto',
|
154
|
-
#
|
155
|
-
#
|
156
|
-
#
|
157
|
-
#
|
158
|
-
# - If set to '
|
159
|
-
#
|
160
|
-
# -
|
161
|
-
#
|
162
|
-
# [Learn more](https://platform.openai.com/docs/guides/flex-processing).
|
161
|
+
# - If set to 'auto', then the request will be processed with the service tier
|
162
|
+
# configured in the Project settings. Unless otherwise configured, the Project
|
163
|
+
# will use 'default'.
|
164
|
+
# - If set to 'default', then the requset will be processed with the standard
|
165
|
+
# pricing and performance for the selected model.
|
166
|
+
# - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
|
167
|
+
# 'priority', then the request will be processed with the corresponding service
|
168
|
+
# tier. [Contact sales](https://openai.com/contact-sales) to learn more about
|
169
|
+
# Priority processing.
|
163
170
|
# - When not set, the default behavior is 'auto'.
|
164
171
|
#
|
165
|
-
# When
|
166
|
-
#
|
172
|
+
# When the `service_tier` parameter is set, the response body will include the
|
173
|
+
# `service_tier` value based on the processing mode actually used to serve the
|
174
|
+
# request. This response value may be different from the value set in the
|
175
|
+
# parameter.
|
167
176
|
service_tier: nil,
|
168
177
|
# Whether to store the generated model response for later retrieval via API.
|
169
178
|
store: nil,
|
@@ -197,6 +206,9 @@ module OpenAI
|
|
197
206
|
# the model to call your own code. Learn more about
|
198
207
|
# [function calling](https://platform.openai.com/docs/guides/function-calling).
|
199
208
|
tools: nil,
|
209
|
+
# An integer between 0 and 20 specifying the number of most likely tokens to
|
210
|
+
# return at each token position, each with an associated log probability.
|
211
|
+
top_logprobs: nil,
|
200
212
|
# An alternative to sampling with temperature, called nucleus sampling, where the
|
201
213
|
# model considers the results of the tokens with top_p probability mass. So 0.1
|
202
214
|
# means only the tokens comprising the top 10% probability mass are considered.
|
@@ -237,21 +249,22 @@ module OpenAI
|
|
237
249
|
# your own data as input for the model's response.
|
238
250
|
sig do
|
239
251
|
params(
|
240
|
-
input: OpenAI::Responses::ResponseCreateParams::Input::Variants,
|
241
|
-
model:
|
242
|
-
T.any(
|
243
|
-
String,
|
244
|
-
OpenAI::ChatModel::OrSymbol,
|
245
|
-
OpenAI::ResponsesModel::ResponsesOnlyModel::OrSymbol
|
246
|
-
),
|
247
252
|
background: T.nilable(T::Boolean),
|
248
253
|
include:
|
249
254
|
T.nilable(
|
250
255
|
T::Array[OpenAI::Responses::ResponseIncludable::OrSymbol]
|
251
256
|
),
|
257
|
+
input: OpenAI::Responses::ResponseCreateParams::Input::Variants,
|
252
258
|
instructions: T.nilable(String),
|
253
259
|
max_output_tokens: T.nilable(Integer),
|
260
|
+
max_tool_calls: T.nilable(Integer),
|
254
261
|
metadata: T.nilable(T::Hash[Symbol, String]),
|
262
|
+
model:
|
263
|
+
T.any(
|
264
|
+
String,
|
265
|
+
OpenAI::ChatModel::OrSymbol,
|
266
|
+
OpenAI::ResponsesModel::ResponsesOnlyModel::OrSymbol
|
267
|
+
),
|
255
268
|
parallel_tool_calls: T.nilable(T::Boolean),
|
256
269
|
previous_response_id: T.nilable(String),
|
257
270
|
prompt: T.nilable(OpenAI::Responses::ResponsePrompt::OrHash),
|
@@ -267,7 +280,8 @@ module OpenAI
|
|
267
280
|
T.any(
|
268
281
|
OpenAI::Responses::ToolChoiceOptions::OrSymbol,
|
269
282
|
OpenAI::Responses::ToolChoiceTypes::OrHash,
|
270
|
-
OpenAI::Responses::ToolChoiceFunction::OrHash
|
283
|
+
OpenAI::Responses::ToolChoiceFunction::OrHash,
|
284
|
+
OpenAI::Responses::ToolChoiceMcp::OrHash
|
271
285
|
),
|
272
286
|
tools:
|
273
287
|
T::Array[
|
@@ -282,6 +296,7 @@ module OpenAI
|
|
282
296
|
OpenAI::Responses::WebSearchTool::OrHash
|
283
297
|
)
|
284
298
|
],
|
299
|
+
top_logprobs: T.nilable(Integer),
|
285
300
|
top_p: T.nilable(Float),
|
286
301
|
truncation:
|
287
302
|
T.nilable(
|
@@ -297,41 +312,36 @@ module OpenAI
|
|
297
312
|
)
|
298
313
|
end
|
299
314
|
def stream_raw(
|
300
|
-
# Text, image, or file inputs to the model, used to generate a response.
|
301
|
-
#
|
302
|
-
# Learn more:
|
303
|
-
#
|
304
|
-
# - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
|
305
|
-
# - [Image inputs](https://platform.openai.com/docs/guides/images)
|
306
|
-
# - [File inputs](https://platform.openai.com/docs/guides/pdf-files)
|
307
|
-
# - [Conversation state](https://platform.openai.com/docs/guides/conversation-state)
|
308
|
-
# - [Function calling](https://platform.openai.com/docs/guides/function-calling)
|
309
|
-
input:,
|
310
|
-
# Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
|
311
|
-
# wide range of models with different capabilities, performance characteristics,
|
312
|
-
# and price points. Refer to the
|
313
|
-
# [model guide](https://platform.openai.com/docs/models) to browse and compare
|
314
|
-
# available models.
|
315
|
-
model:,
|
316
315
|
# Whether to run the model response in the background.
|
317
316
|
# [Learn more](https://platform.openai.com/docs/guides/background).
|
318
317
|
background: nil,
|
319
318
|
# Specify additional output data to include in the model response. Currently
|
320
319
|
# supported values are:
|
321
320
|
#
|
321
|
+
# - `code_interpreter_call.outputs`: Includes the outputs of python code execution
|
322
|
+
# in code interpreter tool call items.
|
323
|
+
# - `computer_call_output.output.image_url`: Include image urls from the computer
|
324
|
+
# call output.
|
322
325
|
# - `file_search_call.results`: Include the search results of the file search tool
|
323
326
|
# call.
|
324
327
|
# - `message.input_image.image_url`: Include image urls from the input message.
|
325
|
-
# - `
|
326
|
-
# call output.
|
328
|
+
# - `message.output_text.logprobs`: Include logprobs with assistant messages.
|
327
329
|
# - `reasoning.encrypted_content`: Includes an encrypted version of reasoning
|
328
330
|
# tokens in reasoning item outputs. This enables reasoning items to be used in
|
329
331
|
# multi-turn conversations when using the Responses API statelessly (like when
|
330
332
|
# the `store` parameter is set to `false`, or when an organization is enrolled
|
331
333
|
# in the zero data retention program).
|
332
|
-
# - `code_interpreter_call.outputs`: Includes the outputs of python code execution
|
333
|
-
# in code interpreter tool call items.
|
334
334
|
include: nil,
|
335
|
+
# Text, image, or file inputs to the model, used to generate a response.
|
336
|
+
#
|
337
|
+
# Learn more:
|
338
|
+
#
|
339
|
+
# - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
|
340
|
+
# - [Image inputs](https://platform.openai.com/docs/guides/images)
|
341
|
+
# - [File inputs](https://platform.openai.com/docs/guides/pdf-files)
|
342
|
+
# - [Conversation state](https://platform.openai.com/docs/guides/conversation-state)
|
343
|
+
# - [Function calling](https://platform.openai.com/docs/guides/function-calling)
|
344
|
+
input: nil,
|
335
345
|
# A system (or developer) message inserted into the model's context.
|
336
346
|
#
|
337
347
|
# When using along with `previous_response_id`, the instructions from a previous
|
@@ -342,6 +352,11 @@ module OpenAI
|
|
342
352
|
# including visible output tokens and
|
343
353
|
# [reasoning tokens](https://platform.openai.com/docs/guides/reasoning).
|
344
354
|
max_output_tokens: nil,
|
355
|
+
# The maximum number of total calls to built-in tools that can be processed in a
|
356
|
+
# response. This maximum number applies across all built-in tool calls, not per
|
357
|
+
# individual tool. Any further attempts to call a tool by the model will be
|
358
|
+
# ignored.
|
359
|
+
max_tool_calls: nil,
|
345
360
|
# Set of 16 key-value pairs that can be attached to an object. This can be useful
|
346
361
|
# for storing additional information about the object in a structured format, and
|
347
362
|
# querying for objects via API or the dashboard.
|
@@ -349,6 +364,12 @@ module OpenAI
|
|
349
364
|
# Keys are strings with a maximum length of 64 characters. Values are strings with
|
350
365
|
# a maximum length of 512 characters.
|
351
366
|
metadata: nil,
|
367
|
+
# Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
|
368
|
+
# wide range of models with different capabilities, performance characteristics,
|
369
|
+
# and price points. Refer to the
|
370
|
+
# [model guide](https://platform.openai.com/docs/models) to browse and compare
|
371
|
+
# available models.
|
372
|
+
model: nil,
|
352
373
|
# Whether to allow the model to run tool calls in parallel.
|
353
374
|
parallel_tool_calls: nil,
|
354
375
|
# The unique ID of the previous response to the model. Use this to create
|
@@ -363,23 +384,23 @@ module OpenAI
|
|
363
384
|
# Configuration options for
|
364
385
|
# [reasoning models](https://platform.openai.com/docs/guides/reasoning).
|
365
386
|
reasoning: nil,
|
366
|
-
# Specifies the
|
367
|
-
# relevant for customers subscribed to the scale tier service:
|
387
|
+
# Specifies the processing type used for serving the request.
|
368
388
|
#
|
369
|
-
# - If set to 'auto',
|
370
|
-
#
|
371
|
-
#
|
372
|
-
#
|
373
|
-
#
|
374
|
-
# - If set to '
|
375
|
-
#
|
376
|
-
# -
|
377
|
-
#
|
378
|
-
# [Learn more](https://platform.openai.com/docs/guides/flex-processing).
|
389
|
+
# - If set to 'auto', then the request will be processed with the service tier
|
390
|
+
# configured in the Project settings. Unless otherwise configured, the Project
|
391
|
+
# will use 'default'.
|
392
|
+
# - If set to 'default', then the requset will be processed with the standard
|
393
|
+
# pricing and performance for the selected model.
|
394
|
+
# - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
|
395
|
+
# 'priority', then the request will be processed with the corresponding service
|
396
|
+
# tier. [Contact sales](https://openai.com/contact-sales) to learn more about
|
397
|
+
# Priority processing.
|
379
398
|
# - When not set, the default behavior is 'auto'.
|
380
399
|
#
|
381
|
-
# When
|
382
|
-
#
|
400
|
+
# When the `service_tier` parameter is set, the response body will include the
|
401
|
+
# `service_tier` value based on the processing mode actually used to serve the
|
402
|
+
# request. This response value may be different from the value set in the
|
403
|
+
# parameter.
|
383
404
|
service_tier: nil,
|
384
405
|
# Whether to store the generated model response for later retrieval via API.
|
385
406
|
store: nil,
|
@@ -413,6 +434,9 @@ module OpenAI
|
|
413
434
|
# the model to call your own code. Learn more about
|
414
435
|
# [function calling](https://platform.openai.com/docs/guides/function-calling).
|
415
436
|
tools: nil,
|
437
|
+
# An integer between 0 and 20 specifying the number of most likely tokens to
|
438
|
+
# return at each token position, each with an associated log probability.
|
439
|
+
top_logprobs: nil,
|
416
440
|
# An alternative to sampling with temperature, called nucleus sampling, where the
|
417
441
|
# model considers the results of the tokens with top_p probability mass. So 0.1
|
418
442
|
# means only the tokens comprising the top 10% probability mass are considered.
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module OpenAI
|
4
|
+
module Resources
|
5
|
+
class Webhooks
|
6
|
+
# Validates that the given payload was sent by OpenAI and parses the payload.
|
7
|
+
sig do
|
8
|
+
params(
|
9
|
+
payload: String,
|
10
|
+
headers: T.nilable(T::Hash[T.any(String, Symbol), String]),
|
11
|
+
webhook_secret: T.nilable(String)
|
12
|
+
).returns(
|
13
|
+
T.any(
|
14
|
+
OpenAI::Webhooks::BatchCancelledWebhookEvent,
|
15
|
+
OpenAI::Webhooks::BatchCompletedWebhookEvent,
|
16
|
+
OpenAI::Webhooks::BatchExpiredWebhookEvent,
|
17
|
+
OpenAI::Webhooks::BatchFailedWebhookEvent,
|
18
|
+
OpenAI::Webhooks::EvalRunCanceledWebhookEvent,
|
19
|
+
OpenAI::Webhooks::EvalRunFailedWebhookEvent,
|
20
|
+
OpenAI::Webhooks::EvalRunSucceededWebhookEvent,
|
21
|
+
OpenAI::Webhooks::FineTuningJobCancelledWebhookEvent,
|
22
|
+
OpenAI::Webhooks::FineTuningJobFailedWebhookEvent,
|
23
|
+
OpenAI::Webhooks::FineTuningJobSucceededWebhookEvent,
|
24
|
+
OpenAI::Webhooks::ResponseCancelledWebhookEvent,
|
25
|
+
OpenAI::Webhooks::ResponseCompletedWebhookEvent,
|
26
|
+
OpenAI::Webhooks::ResponseFailedWebhookEvent,
|
27
|
+
OpenAI::Webhooks::ResponseIncompleteWebhookEvent
|
28
|
+
)
|
29
|
+
)
|
30
|
+
end
|
31
|
+
def unwrap(
|
32
|
+
# The raw webhook payload as a string
|
33
|
+
payload,
|
34
|
+
# The webhook headers
|
35
|
+
headers = {},
|
36
|
+
# The webhook secret (optional, will use ENV["OPENAI_WEBHOOK_SECRET"] if not provided)
|
37
|
+
webhook_secret = nil
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Validates whether or not the webhook payload was sent by OpenAI.
|
42
|
+
sig do
|
43
|
+
params(
|
44
|
+
payload: String,
|
45
|
+
headers: T::Hash[T.any(String, Symbol), String],
|
46
|
+
webhook_secret: T.nilable(String),
|
47
|
+
tolerance: Integer
|
48
|
+
).void
|
49
|
+
end
|
50
|
+
def verify_signature(
|
51
|
+
# The webhook payload as a string
|
52
|
+
payload,
|
53
|
+
# The webhook headers
|
54
|
+
headers,
|
55
|
+
# The webhook secret (optional, will use ENV["OPENAI_WEBHOOK_SECRET"] if not provided)
|
56
|
+
webhook_secret = nil,
|
57
|
+
# Maximum age of the webhook in seconds (default: 300 = 5 minutes)
|
58
|
+
tolerance = 300
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
# @api private
|
63
|
+
sig { params(client: OpenAI::Client).returns(T.attached_class) }
|
64
|
+
def self.new(client:)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/sig/openai/client.rbs
CHANGED
data/sig/openai/errors.rbs
CHANGED
@@ -5,6 +5,15 @@ module OpenAI
|
|
5
5
|
end
|
6
6
|
|
7
7
|
class ConversionError < OpenAI::Errors::Error
|
8
|
+
def cause: -> StandardError?
|
9
|
+
|
10
|
+
def initialize: (
|
11
|
+
on: Class,
|
12
|
+
method: Symbol,
|
13
|
+
target: top,
|
14
|
+
value: top,
|
15
|
+
?cause: StandardError?
|
16
|
+
) -> void
|
8
17
|
end
|
9
18
|
|
10
19
|
class APIError < OpenAI::Errors::Error
|
@@ -8,8 +8,10 @@ module OpenAI
|
|
8
8
|
|
9
9
|
type coerce_state =
|
10
10
|
{
|
11
|
-
|
11
|
+
translate_names: bool,
|
12
|
+
strictness: bool,
|
12
13
|
exactness: { yes: Integer, no: Integer, maybe: Integer },
|
14
|
+
error: Class,
|
13
15
|
branched: Integer
|
14
16
|
}
|
15
17
|
|
@@ -37,6 +39,10 @@ module OpenAI
|
|
37
39
|
| OpenAI::Internal::Type::Converter::input spec
|
38
40
|
) -> (^-> top)
|
39
41
|
|
42
|
+
def self.new_coerce_state: (
|
43
|
+
?translate_names: bool
|
44
|
+
) -> OpenAI::Internal::Type::Converter::coerce_state
|
45
|
+
|
40
46
|
def self.coerce: (
|
41
47
|
OpenAI::Internal::Type::Converter::input target,
|
42
48
|
top value,
|
@@ -13,6 +13,10 @@ module OpenAI
|
|
13
13
|
| :"o1-pro-2025-03-19"
|
14
14
|
| :"o3-pro"
|
15
15
|
| :"o3-pro-2025-06-10"
|
16
|
+
| :"o3-deep-research"
|
17
|
+
| :"o3-deep-research-2025-06-26"
|
18
|
+
| :"o4-mini-deep-research"
|
19
|
+
| :"o4-mini-deep-research-2025-06-26"
|
16
20
|
| :"computer-use-preview"
|
17
21
|
| :"computer-use-preview-2025-03-11"
|
18
22
|
|
@@ -23,6 +27,10 @@ module OpenAI
|
|
23
27
|
O1_PRO_2025_03_19: :"o1-pro-2025-03-19"
|
24
28
|
O3_PRO: :"o3-pro"
|
25
29
|
O3_PRO_2025_06_10: :"o3-pro-2025-06-10"
|
30
|
+
O3_DEEP_RESEARCH: :"o3-deep-research"
|
31
|
+
O3_DEEP_RESEARCH_2025_06_26: :"o3-deep-research-2025-06-26"
|
32
|
+
O4_MINI_DEEP_RESEARCH: :"o4-mini-deep-research"
|
33
|
+
O4_MINI_DEEP_RESEARCH_2025_06_26: :"o4-mini-deep-research-2025-06-26"
|
26
34
|
COMPUTER_USE_PREVIEW: :"computer-use-preview"
|
27
35
|
COMPUTER_USE_PREVIEW_2025_03_11: :"computer-use-preview-2025-03-11"
|
28
36
|
|
@@ -8,7 +8,8 @@ module OpenAI
|
|
8
8
|
voice: OpenAI::Models::Audio::SpeechCreateParams::voice,
|
9
9
|
instructions: String,
|
10
10
|
response_format: OpenAI::Models::Audio::SpeechCreateParams::response_format,
|
11
|
-
speed: Float
|
11
|
+
speed: Float,
|
12
|
+
stream_format: OpenAI::Models::Audio::SpeechCreateParams::stream_format
|
12
13
|
}
|
13
14
|
& OpenAI::Internal::Type::request_parameters
|
14
15
|
|
@@ -36,6 +37,12 @@ module OpenAI
|
|
36
37
|
|
37
38
|
def speed=: (Float) -> Float
|
38
39
|
|
40
|
+
attr_reader stream_format: OpenAI::Models::Audio::SpeechCreateParams::stream_format?
|
41
|
+
|
42
|
+
def stream_format=: (
|
43
|
+
OpenAI::Models::Audio::SpeechCreateParams::stream_format
|
44
|
+
) -> OpenAI::Models::Audio::SpeechCreateParams::stream_format
|
45
|
+
|
39
46
|
def initialize: (
|
40
47
|
input: String,
|
41
48
|
model: OpenAI::Models::Audio::SpeechCreateParams::model,
|
@@ -43,6 +50,7 @@ module OpenAI
|
|
43
50
|
?instructions: String,
|
44
51
|
?response_format: OpenAI::Models::Audio::SpeechCreateParams::response_format,
|
45
52
|
?speed: Float,
|
53
|
+
?stream_format: OpenAI::Models::Audio::SpeechCreateParams::stream_format,
|
46
54
|
?request_options: OpenAI::request_opts
|
47
55
|
) -> void
|
48
56
|
|
@@ -53,6 +61,7 @@ module OpenAI
|
|
53
61
|
instructions: String,
|
54
62
|
response_format: OpenAI::Models::Audio::SpeechCreateParams::response_format,
|
55
63
|
speed: Float,
|
64
|
+
stream_format: OpenAI::Models::Audio::SpeechCreateParams::stream_format,
|
56
65
|
request_options: OpenAI::RequestOptions
|
57
66
|
}
|
58
67
|
|
@@ -110,6 +119,17 @@ module OpenAI
|
|
110
119
|
|
111
120
|
def self?.values: -> ::Array[OpenAI::Models::Audio::SpeechCreateParams::response_format]
|
112
121
|
end
|
122
|
+
|
123
|
+
type stream_format = :sse | :audio
|
124
|
+
|
125
|
+
module StreamFormat
|
126
|
+
extend OpenAI::Internal::Type::Enum
|
127
|
+
|
128
|
+
SSE: :sse
|
129
|
+
AUDIO: :audio
|
130
|
+
|
131
|
+
def self?.values: -> ::Array[OpenAI::Models::Audio::SpeechCreateParams::stream_format]
|
132
|
+
end
|
113
133
|
end
|
114
134
|
end
|
115
135
|
end
|
@@ -4,7 +4,8 @@ module OpenAI
|
|
4
4
|
type transcription =
|
5
5
|
{
|
6
6
|
text: String,
|
7
|
-
logprobs: ::Array[OpenAI::Audio::Transcription::Logprob]
|
7
|
+
logprobs: ::Array[OpenAI::Audio::Transcription::Logprob],
|
8
|
+
usage: OpenAI::Models::Audio::Transcription::usage
|
8
9
|
}
|
9
10
|
|
10
11
|
class Transcription < OpenAI::Internal::Type::BaseModel
|
@@ -16,14 +17,22 @@ module OpenAI
|
|
16
17
|
::Array[OpenAI::Audio::Transcription::Logprob]
|
17
18
|
) -> ::Array[OpenAI::Audio::Transcription::Logprob]
|
18
19
|
|
20
|
+
attr_reader usage: OpenAI::Models::Audio::Transcription::usage?
|
21
|
+
|
22
|
+
def usage=: (
|
23
|
+
OpenAI::Models::Audio::Transcription::usage
|
24
|
+
) -> OpenAI::Models::Audio::Transcription::usage
|
25
|
+
|
19
26
|
def initialize: (
|
20
27
|
text: String,
|
21
|
-
?logprobs: ::Array[OpenAI::Audio::Transcription::Logprob]
|
28
|
+
?logprobs: ::Array[OpenAI::Audio::Transcription::Logprob],
|
29
|
+
?usage: OpenAI::Models::Audio::Transcription::usage
|
22
30
|
) -> void
|
23
31
|
|
24
32
|
def to_hash: -> {
|
25
33
|
text: String,
|
26
|
-
logprobs: ::Array[OpenAI::Audio::Transcription::Logprob]
|
34
|
+
logprobs: ::Array[OpenAI::Audio::Transcription::Logprob],
|
35
|
+
usage: OpenAI::Models::Audio::Transcription::usage
|
27
36
|
}
|
28
37
|
|
29
38
|
type logprob = { token: String, bytes: ::Array[Float], logprob: Float }
|
@@ -53,6 +62,89 @@ module OpenAI
|
|
53
62
|
logprob: Float
|
54
63
|
}
|
55
64
|
end
|
65
|
+
|
66
|
+
type usage =
|
67
|
+
OpenAI::Audio::Transcription::Usage::Tokens
|
68
|
+
| OpenAI::Audio::Transcription::Usage::Duration
|
69
|
+
|
70
|
+
module Usage
|
71
|
+
extend OpenAI::Internal::Type::Union
|
72
|
+
|
73
|
+
type tokens =
|
74
|
+
{
|
75
|
+
input_tokens: Integer,
|
76
|
+
output_tokens: Integer,
|
77
|
+
total_tokens: Integer,
|
78
|
+
type: :tokens,
|
79
|
+
input_token_details: OpenAI::Audio::Transcription::Usage::Tokens::InputTokenDetails
|
80
|
+
}
|
81
|
+
|
82
|
+
class Tokens < OpenAI::Internal::Type::BaseModel
|
83
|
+
attr_accessor input_tokens: Integer
|
84
|
+
|
85
|
+
attr_accessor output_tokens: Integer
|
86
|
+
|
87
|
+
attr_accessor total_tokens: Integer
|
88
|
+
|
89
|
+
attr_accessor type: :tokens
|
90
|
+
|
91
|
+
attr_reader input_token_details: OpenAI::Audio::Transcription::Usage::Tokens::InputTokenDetails?
|
92
|
+
|
93
|
+
def input_token_details=: (
|
94
|
+
OpenAI::Audio::Transcription::Usage::Tokens::InputTokenDetails
|
95
|
+
) -> OpenAI::Audio::Transcription::Usage::Tokens::InputTokenDetails
|
96
|
+
|
97
|
+
def initialize: (
|
98
|
+
input_tokens: Integer,
|
99
|
+
output_tokens: Integer,
|
100
|
+
total_tokens: Integer,
|
101
|
+
?input_token_details: OpenAI::Audio::Transcription::Usage::Tokens::InputTokenDetails,
|
102
|
+
?type: :tokens
|
103
|
+
) -> void
|
104
|
+
|
105
|
+
def to_hash: -> {
|
106
|
+
input_tokens: Integer,
|
107
|
+
output_tokens: Integer,
|
108
|
+
total_tokens: Integer,
|
109
|
+
type: :tokens,
|
110
|
+
input_token_details: OpenAI::Audio::Transcription::Usage::Tokens::InputTokenDetails
|
111
|
+
}
|
112
|
+
|
113
|
+
type input_token_details =
|
114
|
+
{ audio_tokens: Integer, text_tokens: Integer }
|
115
|
+
|
116
|
+
class InputTokenDetails < OpenAI::Internal::Type::BaseModel
|
117
|
+
attr_reader audio_tokens: Integer?
|
118
|
+
|
119
|
+
def audio_tokens=: (Integer) -> Integer
|
120
|
+
|
121
|
+
attr_reader text_tokens: Integer?
|
122
|
+
|
123
|
+
def text_tokens=: (Integer) -> Integer
|
124
|
+
|
125
|
+
def initialize: (
|
126
|
+
?audio_tokens: Integer,
|
127
|
+
?text_tokens: Integer
|
128
|
+
) -> void
|
129
|
+
|
130
|
+
def to_hash: -> { audio_tokens: Integer, text_tokens: Integer }
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
type duration = { duration: Float, type: :duration }
|
135
|
+
|
136
|
+
class Duration < OpenAI::Internal::Type::BaseModel
|
137
|
+
attr_accessor duration: Float
|
138
|
+
|
139
|
+
attr_accessor type: :duration
|
140
|
+
|
141
|
+
def initialize: (duration: Float, ?type: :duration) -> void
|
142
|
+
|
143
|
+
def to_hash: -> { duration: Float, type: :duration }
|
144
|
+
end
|
145
|
+
|
146
|
+
def self?.variants: -> ::Array[OpenAI::Models::Audio::Transcription::usage]
|
147
|
+
end
|
56
148
|
end
|
57
149
|
end
|
58
150
|
end
|