openai 0.8.0 → 0.10.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 (92) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -0
  3. data/README.md +115 -4
  4. data/lib/openai/errors.rb +22 -0
  5. data/lib/openai/internal/type/array_of.rb +6 -1
  6. data/lib/openai/internal/type/base_model.rb +76 -24
  7. data/lib/openai/internal/type/boolean.rb +7 -1
  8. data/lib/openai/internal/type/converter.rb +42 -34
  9. data/lib/openai/internal/type/enum.rb +10 -2
  10. data/lib/openai/internal/type/file_input.rb +6 -1
  11. data/lib/openai/internal/type/hash_of.rb +6 -1
  12. data/lib/openai/internal/type/union.rb +12 -7
  13. data/lib/openai/internal/type/unknown.rb +7 -1
  14. data/lib/openai/models/audio/speech_create_params.rb +23 -2
  15. data/lib/openai/models/audio/transcription.rb +118 -1
  16. data/lib/openai/models/audio/transcription_text_done_event.rb +80 -1
  17. data/lib/openai/models/audio/transcription_verbose.rb +31 -1
  18. data/lib/openai/models/chat/chat_completion.rb +1 -0
  19. data/lib/openai/models/chat/chat_completion_chunk.rb +1 -0
  20. data/lib/openai/models/chat/completion_create_params.rb +1 -0
  21. data/lib/openai/models/fine_tuning/job_create_params.rb +4 -2
  22. data/lib/openai/models/image_edit_params.rb +35 -1
  23. data/lib/openai/models/responses/response.rb +41 -6
  24. data/lib/openai/models/responses/response_code_interpreter_call_code_delta_event.rb +17 -8
  25. data/lib/openai/models/responses/response_code_interpreter_call_code_done_event.rb +14 -10
  26. data/lib/openai/models/responses/response_code_interpreter_call_completed_event.rb +11 -10
  27. data/lib/openai/models/responses/response_code_interpreter_call_in_progress_event.rb +11 -10
  28. data/lib/openai/models/responses/response_code_interpreter_call_interpreting_event.rb +11 -10
  29. data/lib/openai/models/responses/response_code_interpreter_tool_call.rb +49 -78
  30. data/lib/openai/models/responses/response_create_params.rb +41 -32
  31. data/lib/openai/models/responses/response_output_text.rb +18 -2
  32. data/lib/openai/models/responses/response_prompt.rb +63 -0
  33. data/lib/openai/models/responses/response_stream_event.rb +2 -2
  34. data/lib/openai/resources/audio/speech.rb +3 -1
  35. data/lib/openai/resources/chat/completions.rb +8 -0
  36. data/lib/openai/resources/fine_tuning/jobs.rb +2 -2
  37. data/lib/openai/resources/images.rb +5 -1
  38. data/lib/openai/resources/responses.rb +18 -14
  39. data/lib/openai/version.rb +1 -1
  40. data/lib/openai.rb +1 -0
  41. data/rbi/openai/errors.rbi +16 -0
  42. data/rbi/openai/internal/type/boolean.rbi +2 -0
  43. data/rbi/openai/internal/type/converter.rbi +15 -15
  44. data/rbi/openai/internal/type/union.rbi +5 -0
  45. data/rbi/openai/internal/type/unknown.rbi +2 -0
  46. data/rbi/openai/models/audio/speech_create_params.rbi +59 -2
  47. data/rbi/openai/models/audio/transcription.rbi +213 -3
  48. data/rbi/openai/models/audio/transcription_text_done_event.rbi +146 -1
  49. data/rbi/openai/models/audio/transcription_verbose.rbi +47 -0
  50. data/rbi/openai/models/chat/chat_completion.rbi +5 -0
  51. data/rbi/openai/models/chat/chat_completion_chunk.rbi +5 -0
  52. data/rbi/openai/models/chat/completion_create_params.rbi +5 -0
  53. data/rbi/openai/models/fine_tuning/job_create_params.rbi +8 -4
  54. data/rbi/openai/models/image_edit_params.rbi +51 -0
  55. data/rbi/openai/models/responses/response.rbi +66 -7
  56. data/rbi/openai/models/responses/response_code_interpreter_call_code_delta_event.rbi +17 -7
  57. data/rbi/openai/models/responses/response_code_interpreter_call_code_done_event.rbi +13 -5
  58. data/rbi/openai/models/responses/response_code_interpreter_call_completed_event.rbi +13 -21
  59. data/rbi/openai/models/responses/response_code_interpreter_call_in_progress_event.rbi +13 -21
  60. data/rbi/openai/models/responses/response_code_interpreter_call_interpreting_event.rbi +13 -21
  61. data/rbi/openai/models/responses/response_code_interpreter_tool_call.rbi +83 -125
  62. data/rbi/openai/models/responses/response_create_params.rbi +107 -64
  63. data/rbi/openai/models/responses/response_output_text.rbi +26 -4
  64. data/rbi/openai/models/responses/response_prompt.rbi +120 -0
  65. data/rbi/openai/resources/audio/speech.rbi +6 -1
  66. data/rbi/openai/resources/fine_tuning/jobs.rbi +6 -4
  67. data/rbi/openai/resources/images.rbi +11 -0
  68. data/rbi/openai/resources/responses.rbi +56 -50
  69. data/sig/openai/errors.rbs +9 -0
  70. data/sig/openai/internal/type/converter.rbs +7 -1
  71. data/sig/openai/models/audio/speech_create_params.rbs +21 -1
  72. data/sig/openai/models/audio/transcription.rbs +95 -3
  73. data/sig/openai/models/audio/transcription_text_done_event.rbs +72 -2
  74. data/sig/openai/models/audio/transcription_verbose.rbs +21 -0
  75. data/sig/openai/models/chat/chat_completion.rbs +2 -1
  76. data/sig/openai/models/chat/chat_completion_chunk.rbs +2 -1
  77. data/sig/openai/models/chat/completion_create_params.rbs +2 -1
  78. data/sig/openai/models/image_edit_params.rbs +22 -0
  79. data/sig/openai/models/responses/response.rbs +22 -5
  80. data/sig/openai/models/responses/response_code_interpreter_call_code_delta_event.rbs +5 -0
  81. data/sig/openai/models/responses/response_code_interpreter_call_code_done_event.rbs +5 -0
  82. data/sig/openai/models/responses/response_code_interpreter_call_completed_event.rbs +4 -4
  83. data/sig/openai/models/responses/response_code_interpreter_call_in_progress_event.rbs +4 -4
  84. data/sig/openai/models/responses/response_code_interpreter_call_interpreting_event.rbs +4 -4
  85. data/sig/openai/models/responses/response_code_interpreter_tool_call.rbs +31 -52
  86. data/sig/openai/models/responses/response_create_params.rbs +25 -11
  87. data/sig/openai/models/responses/response_output_text.rbs +15 -1
  88. data/sig/openai/models/responses/response_prompt.rbs +44 -0
  89. data/sig/openai/resources/audio/speech.rbs +1 -0
  90. data/sig/openai/resources/images.rbs +2 -0
  91. data/sig/openai/resources/responses.rbs +6 -4
  92. metadata +5 -2
@@ -28,12 +28,34 @@ module OpenAI
28
28
  end
29
29
  attr_writer :logprobs
30
30
 
31
+ # Token usage statistics for the request.
32
+ sig do
33
+ returns(T.nilable(OpenAI::Audio::Transcription::Usage::Variants))
34
+ end
35
+ attr_reader :usage
36
+
37
+ sig do
38
+ params(
39
+ usage:
40
+ T.any(
41
+ OpenAI::Audio::Transcription::Usage::Tokens::OrHash,
42
+ OpenAI::Audio::Transcription::Usage::Duration::OrHash
43
+ )
44
+ ).void
45
+ end
46
+ attr_writer :usage
47
+
31
48
  # Represents a transcription response returned by model, based on the provided
32
49
  # input.
33
50
  sig do
34
51
  params(
35
52
  text: String,
36
- logprobs: T::Array[OpenAI::Audio::Transcription::Logprob::OrHash]
53
+ logprobs: T::Array[OpenAI::Audio::Transcription::Logprob::OrHash],
54
+ usage:
55
+ T.any(
56
+ OpenAI::Audio::Transcription::Usage::Tokens::OrHash,
57
+ OpenAI::Audio::Transcription::Usage::Duration::OrHash
58
+ )
37
59
  ).returns(T.attached_class)
38
60
  end
39
61
  def self.new(
@@ -42,7 +64,9 @@ module OpenAI
42
64
  # The log probabilities of the tokens in the transcription. Only returned with the
43
65
  # models `gpt-4o-transcribe` and `gpt-4o-mini-transcribe` if `logprobs` is added
44
66
  # to the `include` array.
45
- logprobs: nil
67
+ logprobs: nil,
68
+ # Token usage statistics for the request.
69
+ usage: nil
46
70
  )
47
71
  end
48
72
 
@@ -50,7 +74,8 @@ module OpenAI
50
74
  override.returns(
51
75
  {
52
76
  text: String,
53
- logprobs: T::Array[OpenAI::Audio::Transcription::Logprob]
77
+ logprobs: T::Array[OpenAI::Audio::Transcription::Logprob],
78
+ usage: OpenAI::Audio::Transcription::Usage::Variants
54
79
  }
55
80
  )
56
81
  end
@@ -112,6 +137,191 @@ module OpenAI
112
137
  def to_hash
113
138
  end
114
139
  end
140
+
141
+ # Token usage statistics for the request.
142
+ module Usage
143
+ extend OpenAI::Internal::Type::Union
144
+
145
+ Variants =
146
+ T.type_alias do
147
+ T.any(
148
+ OpenAI::Audio::Transcription::Usage::Tokens,
149
+ OpenAI::Audio::Transcription::Usage::Duration
150
+ )
151
+ end
152
+
153
+ class Tokens < OpenAI::Internal::Type::BaseModel
154
+ OrHash =
155
+ T.type_alias do
156
+ T.any(
157
+ OpenAI::Audio::Transcription::Usage::Tokens,
158
+ OpenAI::Internal::AnyHash
159
+ )
160
+ end
161
+
162
+ # Number of input tokens billed for this request.
163
+ sig { returns(Integer) }
164
+ attr_accessor :input_tokens
165
+
166
+ # Number of output tokens generated.
167
+ sig { returns(Integer) }
168
+ attr_accessor :output_tokens
169
+
170
+ # Total number of tokens used (input + output).
171
+ sig { returns(Integer) }
172
+ attr_accessor :total_tokens
173
+
174
+ # The type of the usage object. Always `tokens` for this variant.
175
+ sig { returns(Symbol) }
176
+ attr_accessor :type
177
+
178
+ # Details about the input tokens billed for this request.
179
+ sig do
180
+ returns(
181
+ T.nilable(
182
+ OpenAI::Audio::Transcription::Usage::Tokens::InputTokenDetails
183
+ )
184
+ )
185
+ end
186
+ attr_reader :input_token_details
187
+
188
+ sig do
189
+ params(
190
+ input_token_details:
191
+ OpenAI::Audio::Transcription::Usage::Tokens::InputTokenDetails::OrHash
192
+ ).void
193
+ end
194
+ attr_writer :input_token_details
195
+
196
+ # Usage statistics for models billed by token usage.
197
+ sig do
198
+ params(
199
+ input_tokens: Integer,
200
+ output_tokens: Integer,
201
+ total_tokens: Integer,
202
+ input_token_details:
203
+ OpenAI::Audio::Transcription::Usage::Tokens::InputTokenDetails::OrHash,
204
+ type: Symbol
205
+ ).returns(T.attached_class)
206
+ end
207
+ def self.new(
208
+ # Number of input tokens billed for this request.
209
+ input_tokens:,
210
+ # Number of output tokens generated.
211
+ output_tokens:,
212
+ # Total number of tokens used (input + output).
213
+ total_tokens:,
214
+ # Details about the input tokens billed for this request.
215
+ input_token_details: nil,
216
+ # The type of the usage object. Always `tokens` for this variant.
217
+ type: :tokens
218
+ )
219
+ end
220
+
221
+ sig do
222
+ override.returns(
223
+ {
224
+ input_tokens: Integer,
225
+ output_tokens: Integer,
226
+ total_tokens: Integer,
227
+ type: Symbol,
228
+ input_token_details:
229
+ OpenAI::Audio::Transcription::Usage::Tokens::InputTokenDetails
230
+ }
231
+ )
232
+ end
233
+ def to_hash
234
+ end
235
+
236
+ class InputTokenDetails < OpenAI::Internal::Type::BaseModel
237
+ OrHash =
238
+ T.type_alias do
239
+ T.any(
240
+ OpenAI::Audio::Transcription::Usage::Tokens::InputTokenDetails,
241
+ OpenAI::Internal::AnyHash
242
+ )
243
+ end
244
+
245
+ # Number of audio tokens billed for this request.
246
+ sig { returns(T.nilable(Integer)) }
247
+ attr_reader :audio_tokens
248
+
249
+ sig { params(audio_tokens: Integer).void }
250
+ attr_writer :audio_tokens
251
+
252
+ # Number of text tokens billed for this request.
253
+ sig { returns(T.nilable(Integer)) }
254
+ attr_reader :text_tokens
255
+
256
+ sig { params(text_tokens: Integer).void }
257
+ attr_writer :text_tokens
258
+
259
+ # Details about the input tokens billed for this request.
260
+ sig do
261
+ params(audio_tokens: Integer, text_tokens: Integer).returns(
262
+ T.attached_class
263
+ )
264
+ end
265
+ def self.new(
266
+ # Number of audio tokens billed for this request.
267
+ audio_tokens: nil,
268
+ # Number of text tokens billed for this request.
269
+ text_tokens: nil
270
+ )
271
+ end
272
+
273
+ sig do
274
+ override.returns(
275
+ { audio_tokens: Integer, text_tokens: Integer }
276
+ )
277
+ end
278
+ def to_hash
279
+ end
280
+ end
281
+ end
282
+
283
+ class Duration < OpenAI::Internal::Type::BaseModel
284
+ OrHash =
285
+ T.type_alias do
286
+ T.any(
287
+ OpenAI::Audio::Transcription::Usage::Duration,
288
+ OpenAI::Internal::AnyHash
289
+ )
290
+ end
291
+
292
+ # Duration of the input audio in seconds.
293
+ sig { returns(Float) }
294
+ attr_accessor :duration
295
+
296
+ # The type of the usage object. Always `duration` for this variant.
297
+ sig { returns(Symbol) }
298
+ attr_accessor :type
299
+
300
+ # Usage statistics for models billed by audio input duration.
301
+ sig do
302
+ params(duration: Float, type: Symbol).returns(T.attached_class)
303
+ end
304
+ def self.new(
305
+ # Duration of the input audio in seconds.
306
+ duration:,
307
+ # The type of the usage object. Always `duration` for this variant.
308
+ type: :duration
309
+ )
310
+ end
311
+
312
+ sig { override.returns({ duration: Float, type: Symbol }) }
313
+ def to_hash
314
+ end
315
+ end
316
+
317
+ sig do
318
+ override.returns(
319
+ T::Array[OpenAI::Audio::Transcription::Usage::Variants]
320
+ )
321
+ end
322
+ def self.variants
323
+ end
324
+ end
115
325
  end
116
326
  end
117
327
  end
@@ -43,6 +43,19 @@ module OpenAI
43
43
  end
44
44
  attr_writer :logprobs
45
45
 
46
+ # Usage statistics for models billed by token usage.
47
+ sig do
48
+ returns(T.nilable(OpenAI::Audio::TranscriptionTextDoneEvent::Usage))
49
+ end
50
+ attr_reader :usage
51
+
52
+ sig do
53
+ params(
54
+ usage: OpenAI::Audio::TranscriptionTextDoneEvent::Usage::OrHash
55
+ ).void
56
+ end
57
+ attr_writer :usage
58
+
46
59
  # Emitted when the transcription is complete. Contains the complete transcription
47
60
  # text. Only emitted when you
48
61
  # [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
@@ -54,6 +67,7 @@ module OpenAI
54
67
  T::Array[
55
68
  OpenAI::Audio::TranscriptionTextDoneEvent::Logprob::OrHash
56
69
  ],
70
+ usage: OpenAI::Audio::TranscriptionTextDoneEvent::Usage::OrHash,
57
71
  type: Symbol
58
72
  ).returns(T.attached_class)
59
73
  end
@@ -65,6 +79,8 @@ module OpenAI
65
79
  # [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
66
80
  # with the `include[]` parameter set to `logprobs`.
67
81
  logprobs: nil,
82
+ # Usage statistics for models billed by token usage.
83
+ usage: nil,
68
84
  # The type of the event. Always `transcript.text.done`.
69
85
  type: :"transcript.text.done"
70
86
  )
@@ -76,7 +92,8 @@ module OpenAI
76
92
  text: String,
77
93
  type: Symbol,
78
94
  logprobs:
79
- T::Array[OpenAI::Audio::TranscriptionTextDoneEvent::Logprob]
95
+ T::Array[OpenAI::Audio::TranscriptionTextDoneEvent::Logprob],
96
+ usage: OpenAI::Audio::TranscriptionTextDoneEvent::Usage
80
97
  }
81
98
  )
82
99
  end
@@ -138,6 +155,134 @@ module OpenAI
138
155
  def to_hash
139
156
  end
140
157
  end
158
+
159
+ class Usage < OpenAI::Internal::Type::BaseModel
160
+ OrHash =
161
+ T.type_alias do
162
+ T.any(
163
+ OpenAI::Audio::TranscriptionTextDoneEvent::Usage,
164
+ OpenAI::Internal::AnyHash
165
+ )
166
+ end
167
+
168
+ # Number of input tokens billed for this request.
169
+ sig { returns(Integer) }
170
+ attr_accessor :input_tokens
171
+
172
+ # Number of output tokens generated.
173
+ sig { returns(Integer) }
174
+ attr_accessor :output_tokens
175
+
176
+ # Total number of tokens used (input + output).
177
+ sig { returns(Integer) }
178
+ attr_accessor :total_tokens
179
+
180
+ # The type of the usage object. Always `tokens` for this variant.
181
+ sig { returns(Symbol) }
182
+ attr_accessor :type
183
+
184
+ # Details about the input tokens billed for this request.
185
+ sig do
186
+ returns(
187
+ T.nilable(
188
+ OpenAI::Audio::TranscriptionTextDoneEvent::Usage::InputTokenDetails
189
+ )
190
+ )
191
+ end
192
+ attr_reader :input_token_details
193
+
194
+ sig do
195
+ params(
196
+ input_token_details:
197
+ OpenAI::Audio::TranscriptionTextDoneEvent::Usage::InputTokenDetails::OrHash
198
+ ).void
199
+ end
200
+ attr_writer :input_token_details
201
+
202
+ # Usage statistics for models billed by token usage.
203
+ sig do
204
+ params(
205
+ input_tokens: Integer,
206
+ output_tokens: Integer,
207
+ total_tokens: Integer,
208
+ input_token_details:
209
+ OpenAI::Audio::TranscriptionTextDoneEvent::Usage::InputTokenDetails::OrHash,
210
+ type: Symbol
211
+ ).returns(T.attached_class)
212
+ end
213
+ def self.new(
214
+ # Number of input tokens billed for this request.
215
+ input_tokens:,
216
+ # Number of output tokens generated.
217
+ output_tokens:,
218
+ # Total number of tokens used (input + output).
219
+ total_tokens:,
220
+ # Details about the input tokens billed for this request.
221
+ input_token_details: nil,
222
+ # The type of the usage object. Always `tokens` for this variant.
223
+ type: :tokens
224
+ )
225
+ end
226
+
227
+ sig do
228
+ override.returns(
229
+ {
230
+ input_tokens: Integer,
231
+ output_tokens: Integer,
232
+ total_tokens: Integer,
233
+ type: Symbol,
234
+ input_token_details:
235
+ OpenAI::Audio::TranscriptionTextDoneEvent::Usage::InputTokenDetails
236
+ }
237
+ )
238
+ end
239
+ def to_hash
240
+ end
241
+
242
+ class InputTokenDetails < OpenAI::Internal::Type::BaseModel
243
+ OrHash =
244
+ T.type_alias do
245
+ T.any(
246
+ OpenAI::Audio::TranscriptionTextDoneEvent::Usage::InputTokenDetails,
247
+ OpenAI::Internal::AnyHash
248
+ )
249
+ end
250
+
251
+ # Number of audio tokens billed for this request.
252
+ sig { returns(T.nilable(Integer)) }
253
+ attr_reader :audio_tokens
254
+
255
+ sig { params(audio_tokens: Integer).void }
256
+ attr_writer :audio_tokens
257
+
258
+ # Number of text tokens billed for this request.
259
+ sig { returns(T.nilable(Integer)) }
260
+ attr_reader :text_tokens
261
+
262
+ sig { params(text_tokens: Integer).void }
263
+ attr_writer :text_tokens
264
+
265
+ # Details about the input tokens billed for this request.
266
+ sig do
267
+ params(audio_tokens: Integer, text_tokens: Integer).returns(
268
+ T.attached_class
269
+ )
270
+ end
271
+ def self.new(
272
+ # Number of audio tokens billed for this request.
273
+ audio_tokens: nil,
274
+ # Number of text tokens billed for this request.
275
+ text_tokens: nil
276
+ )
277
+ end
278
+
279
+ sig do
280
+ override.returns({ audio_tokens: Integer, text_tokens: Integer })
281
+ end
282
+ def to_hash
283
+ end
284
+ end
285
+ end
141
286
  end
142
287
  end
143
288
  end
@@ -37,6 +37,15 @@ module OpenAI
37
37
  end
38
38
  attr_writer :segments
39
39
 
40
+ # Usage statistics for models billed by audio input duration.
41
+ sig { returns(T.nilable(OpenAI::Audio::TranscriptionVerbose::Usage)) }
42
+ attr_reader :usage
43
+
44
+ sig do
45
+ params(usage: OpenAI::Audio::TranscriptionVerbose::Usage::OrHash).void
46
+ end
47
+ attr_writer :usage
48
+
40
49
  # Extracted words and their corresponding timestamps.
41
50
  sig { returns(T.nilable(T::Array[OpenAI::Audio::TranscriptionWord])) }
42
51
  attr_reader :words
@@ -54,6 +63,7 @@ module OpenAI
54
63
  language: String,
55
64
  text: String,
56
65
  segments: T::Array[OpenAI::Audio::TranscriptionSegment::OrHash],
66
+ usage: OpenAI::Audio::TranscriptionVerbose::Usage::OrHash,
57
67
  words: T::Array[OpenAI::Audio::TranscriptionWord::OrHash]
58
68
  ).returns(T.attached_class)
59
69
  end
@@ -66,6 +76,8 @@ module OpenAI
66
76
  text:,
67
77
  # Segments of the transcribed text and their corresponding details.
68
78
  segments: nil,
79
+ # Usage statistics for models billed by audio input duration.
80
+ usage: nil,
69
81
  # Extracted words and their corresponding timestamps.
70
82
  words: nil
71
83
  )
@@ -78,12 +90,47 @@ module OpenAI
78
90
  language: String,
79
91
  text: String,
80
92
  segments: T::Array[OpenAI::Audio::TranscriptionSegment],
93
+ usage: OpenAI::Audio::TranscriptionVerbose::Usage,
81
94
  words: T::Array[OpenAI::Audio::TranscriptionWord]
82
95
  }
83
96
  )
84
97
  end
85
98
  def to_hash
86
99
  end
100
+
101
+ class Usage < OpenAI::Internal::Type::BaseModel
102
+ OrHash =
103
+ T.type_alias do
104
+ T.any(
105
+ OpenAI::Audio::TranscriptionVerbose::Usage,
106
+ OpenAI::Internal::AnyHash
107
+ )
108
+ end
109
+
110
+ # Duration of the input audio in seconds.
111
+ sig { returns(Float) }
112
+ attr_accessor :duration
113
+
114
+ # The type of the usage object. Always `duration` for this variant.
115
+ sig { returns(Symbol) }
116
+ attr_accessor :type
117
+
118
+ # Usage statistics for models billed by audio input duration.
119
+ sig do
120
+ params(duration: Float, type: Symbol).returns(T.attached_class)
121
+ end
122
+ def self.new(
123
+ # Duration of the input audio in seconds.
124
+ duration:,
125
+ # The type of the usage object. Always `duration` for this variant.
126
+ type: :duration
127
+ )
128
+ end
129
+
130
+ sig { override.returns({ duration: Float, type: Symbol }) }
131
+ def to_hash
132
+ end
133
+ end
87
134
  end
88
135
  end
89
136
  end
@@ -404,6 +404,11 @@ module OpenAI
404
404
  :flex,
405
405
  OpenAI::Chat::ChatCompletion::ServiceTier::TaggedSymbol
406
406
  )
407
+ SCALE =
408
+ T.let(
409
+ :scale,
410
+ OpenAI::Chat::ChatCompletion::ServiceTier::TaggedSymbol
411
+ )
407
412
 
408
413
  sig do
409
414
  override.returns(
@@ -824,6 +824,11 @@ module OpenAI
824
824
  :flex,
825
825
  OpenAI::Chat::ChatCompletionChunk::ServiceTier::TaggedSymbol
826
826
  )
827
+ SCALE =
828
+ T.let(
829
+ :scale,
830
+ OpenAI::Chat::ChatCompletionChunk::ServiceTier::TaggedSymbol
831
+ )
827
832
 
828
833
  sig do
829
834
  override.returns(
@@ -1049,6 +1049,11 @@ module OpenAI
1049
1049
  :flex,
1050
1050
  OpenAI::Chat::CompletionCreateParams::ServiceTier::TaggedSymbol
1051
1051
  )
1052
+ SCALE =
1053
+ T.let(
1054
+ :scale,
1055
+ OpenAI::Chat::CompletionCreateParams::ServiceTier::TaggedSymbol
1056
+ )
1052
1057
 
1053
1058
  sig do
1054
1059
  override.returns(
@@ -39,7 +39,8 @@ module OpenAI
39
39
  # [preference](https://platform.openai.com/docs/api-reference/fine-tuning/preference-input)
40
40
  # format.
41
41
  #
42
- # See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning)
42
+ # See the
43
+ # [fine-tuning guide](https://platform.openai.com/docs/guides/model-optimization)
43
44
  # for more details.
44
45
  sig { returns(String) }
45
46
  attr_accessor :training_file
@@ -115,7 +116,8 @@ module OpenAI
115
116
  # Your dataset must be formatted as a JSONL file. You must upload your file with
116
117
  # the purpose `fine-tune`.
117
118
  #
118
- # See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning)
119
+ # See the
120
+ # [fine-tuning guide](https://platform.openai.com/docs/guides/model-optimization)
119
121
  # for more details.
120
122
  sig { returns(T.nilable(String)) }
121
123
  attr_accessor :validation_file
@@ -163,7 +165,8 @@ module OpenAI
163
165
  # [preference](https://platform.openai.com/docs/api-reference/fine-tuning/preference-input)
164
166
  # format.
165
167
  #
166
- # See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning)
168
+ # See the
169
+ # [fine-tuning guide](https://platform.openai.com/docs/guides/model-optimization)
167
170
  # for more details.
168
171
  training_file:,
169
172
  # The hyperparameters used for the fine-tuning job. This value is now deprecated
@@ -200,7 +203,8 @@ module OpenAI
200
203
  # Your dataset must be formatted as a JSONL file. You must upload your file with
201
204
  # the purpose `fine-tune`.
202
205
  #
203
- # See the [fine-tuning guide](https://platform.openai.com/docs/guides/fine-tuning)
206
+ # See the
207
+ # [fine-tuning guide](https://platform.openai.com/docs/guides/model-optimization)
204
208
  # for more details.
205
209
  validation_file: nil,
206
210
  request_options: {}
@@ -56,6 +56,20 @@ module OpenAI
56
56
  sig { returns(T.nilable(Integer)) }
57
57
  attr_accessor :n
58
58
 
59
+ # The compression level (0-100%) for the generated images. This parameter is only
60
+ # supported for `gpt-image-1` with the `webp` or `jpeg` output formats, and
61
+ # defaults to 100.
62
+ sig { returns(T.nilable(Integer)) }
63
+ attr_accessor :output_compression
64
+
65
+ # The format in which the generated images are returned. This parameter is only
66
+ # supported for `gpt-image-1`. Must be one of `png`, `jpeg`, or `webp`. The
67
+ # default value is `png`.
68
+ sig do
69
+ returns(T.nilable(OpenAI::ImageEditParams::OutputFormat::OrSymbol))
70
+ end
71
+ attr_accessor :output_format
72
+
59
73
  # The quality of the image that will be generated. `high`, `medium` and `low` are
60
74
  # only supported for `gpt-image-1`. `dall-e-2` only supports `standard` quality.
61
75
  # Defaults to `auto`.
@@ -94,6 +108,9 @@ module OpenAI
94
108
  mask: OpenAI::Internal::FileInput,
95
109
  model: T.nilable(T.any(String, OpenAI::ImageModel::OrSymbol)),
96
110
  n: T.nilable(Integer),
111
+ output_compression: T.nilable(Integer),
112
+ output_format:
113
+ T.nilable(OpenAI::ImageEditParams::OutputFormat::OrSymbol),
97
114
  quality: T.nilable(OpenAI::ImageEditParams::Quality::OrSymbol),
98
115
  response_format:
99
116
  T.nilable(OpenAI::ImageEditParams::ResponseFormat::OrSymbol),
@@ -133,6 +150,14 @@ module OpenAI
133
150
  model: nil,
134
151
  # The number of images to generate. Must be between 1 and 10.
135
152
  n: nil,
153
+ # The compression level (0-100%) for the generated images. This parameter is only
154
+ # supported for `gpt-image-1` with the `webp` or `jpeg` output formats, and
155
+ # defaults to 100.
156
+ output_compression: nil,
157
+ # The format in which the generated images are returned. This parameter is only
158
+ # supported for `gpt-image-1`. Must be one of `png`, `jpeg`, or `webp`. The
159
+ # default value is `png`.
160
+ output_format: nil,
136
161
  # The quality of the image that will be generated. `high`, `medium` and `low` are
137
162
  # only supported for `gpt-image-1`. `dall-e-2` only supports `standard` quality.
138
163
  # Defaults to `auto`.
@@ -164,6 +189,9 @@ module OpenAI
164
189
  mask: OpenAI::Internal::FileInput,
165
190
  model: T.nilable(T.any(String, OpenAI::ImageModel::OrSymbol)),
166
191
  n: T.nilable(Integer),
192
+ output_compression: T.nilable(Integer),
193
+ output_format:
194
+ T.nilable(OpenAI::ImageEditParams::OutputFormat::OrSymbol),
167
195
  quality: T.nilable(OpenAI::ImageEditParams::Quality::OrSymbol),
168
196
  response_format:
169
197
  T.nilable(OpenAI::ImageEditParams::ResponseFormat::OrSymbol),
@@ -246,6 +274,29 @@ module OpenAI
246
274
  end
247
275
  end
248
276
 
277
+ # The format in which the generated images are returned. This parameter is only
278
+ # supported for `gpt-image-1`. Must be one of `png`, `jpeg`, or `webp`. The
279
+ # default value is `png`.
280
+ module OutputFormat
281
+ extend OpenAI::Internal::Type::Enum
282
+
283
+ TaggedSymbol =
284
+ T.type_alias { T.all(Symbol, OpenAI::ImageEditParams::OutputFormat) }
285
+ OrSymbol = T.type_alias { T.any(Symbol, String) }
286
+
287
+ PNG = T.let(:png, OpenAI::ImageEditParams::OutputFormat::TaggedSymbol)
288
+ JPEG = T.let(:jpeg, OpenAI::ImageEditParams::OutputFormat::TaggedSymbol)
289
+ WEBP = T.let(:webp, OpenAI::ImageEditParams::OutputFormat::TaggedSymbol)
290
+
291
+ sig do
292
+ override.returns(
293
+ T::Array[OpenAI::ImageEditParams::OutputFormat::TaggedSymbol]
294
+ )
295
+ end
296
+ def self.values
297
+ end
298
+ end
299
+
249
300
  # The quality of the image that will be generated. `high`, `medium` and `low` are
250
301
  # only supported for `gpt-image-1`. `dall-e-2` only supports `standard` quality.
251
302
  # Defaults to `auto`.