openai 0.40.0 → 0.42.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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -0
  3. data/README.md +1 -1
  4. data/lib/openai/internal/transport/pooled_net_requester.rb +12 -10
  5. data/lib/openai/internal/util.rb +7 -2
  6. data/lib/openai/models/audio/speech_create_params.rb +3 -3
  7. data/lib/openai/models/audio/speech_model.rb +1 -0
  8. data/lib/openai/models/audio/transcription_create_params.rb +10 -8
  9. data/lib/openai/models/audio_model.rb +1 -0
  10. data/lib/openai/models/graders/grader_input_item.rb +87 -0
  11. data/lib/openai/models/graders/grader_inputs.rb +0 -80
  12. data/lib/openai/models/image.rb +6 -6
  13. data/lib/openai/models/image_edit_completed_event.rb +5 -3
  14. data/lib/openai/models/image_edit_params.rb +34 -32
  15. data/lib/openai/models/image_gen_completed_event.rb +5 -3
  16. data/lib/openai/models/image_generate_params.rb +38 -36
  17. data/lib/openai/models/image_model.rb +1 -0
  18. data/lib/openai/models/images_response.rb +31 -1
  19. data/lib/openai/models/realtime/audio_transcription.rb +33 -10
  20. data/lib/openai/models/realtime/realtime_session.rb +46 -6
  21. data/lib/openai/models/realtime/realtime_session_create_request.rb +6 -0
  22. data/lib/openai/models/realtime/realtime_session_create_response.rb +6 -0
  23. data/lib/openai/models/responses/tool.rb +22 -8
  24. data/lib/openai/models/video.rb +3 -3
  25. data/lib/openai/models/video_create_params.rb +3 -3
  26. data/lib/openai/models/video_model.rb +23 -3
  27. data/lib/openai/resources/images.rb +6 -6
  28. data/lib/openai/resources/videos.rb +1 -1
  29. data/lib/openai/version.rb +1 -1
  30. data/lib/openai.rb +1 -0
  31. data/rbi/openai/models/audio/speech_create_params.rbi +3 -3
  32. data/rbi/openai/models/audio/speech_model.rbi +5 -0
  33. data/rbi/openai/models/audio/transcription_create_params.rbi +15 -12
  34. data/rbi/openai/models/audio_model.rbi +5 -0
  35. data/rbi/openai/models/graders/grader_input_item.rbi +112 -0
  36. data/rbi/openai/models/graders/grader_inputs.rbi +0 -105
  37. data/rbi/openai/models/image.rbi +10 -10
  38. data/rbi/openai/models/image_edit_completed_event.rbi +6 -3
  39. data/rbi/openai/models/image_edit_params.rbi +49 -46
  40. data/rbi/openai/models/image_gen_completed_event.rbi +6 -3
  41. data/rbi/openai/models/image_generate_params.rbi +54 -51
  42. data/rbi/openai/models/image_model.rbi +1 -0
  43. data/rbi/openai/models/images_response.rbi +61 -3
  44. data/rbi/openai/models/realtime/audio_transcription.rbi +52 -21
  45. data/rbi/openai/models/realtime/realtime_session.rbi +42 -12
  46. data/rbi/openai/models/realtime/realtime_session_create_request.rbi +10 -0
  47. data/rbi/openai/models/realtime/realtime_session_create_response.rbi +10 -0
  48. data/rbi/openai/models/responses/tool.rbi +38 -16
  49. data/rbi/openai/models/video.rbi +3 -3
  50. data/rbi/openai/models/video_create_params.rbi +4 -4
  51. data/rbi/openai/models/video_model.rbi +8 -5
  52. data/rbi/openai/resources/audio/speech.rbi +1 -1
  53. data/rbi/openai/resources/audio/transcriptions.rbi +12 -10
  54. data/rbi/openai/resources/images.rbi +72 -68
  55. data/rbi/openai/resources/videos.rbi +1 -1
  56. data/sig/openai/models/audio/speech_model.rbs +6 -1
  57. data/sig/openai/models/audio_model.rbs +2 -0
  58. data/sig/openai/models/graders/grader_input_item.rbs +55 -0
  59. data/sig/openai/models/graders/grader_inputs.rbs +0 -50
  60. data/sig/openai/models/image_model.rbs +6 -1
  61. data/sig/openai/models/images_response.rbs +25 -3
  62. data/sig/openai/models/realtime/audio_transcription.rbs +7 -4
  63. data/sig/openai/models/realtime/realtime_session.rbs +9 -4
  64. data/sig/openai/models/realtime/realtime_session_create_request.rbs +4 -0
  65. data/sig/openai/models/realtime/realtime_session_create_response.rbs +4 -0
  66. data/sig/openai/models/responses/tool.rbs +4 -4
  67. data/sig/openai/models/video_model.rbs +5 -4
  68. metadata +5 -2
@@ -14,7 +14,7 @@ module OpenAI
14
14
  #
15
15
  # @param input_reference [Pathname, StringIO, IO, String, OpenAI::FilePart] Optional image reference that guides generation.
16
16
  #
17
- # @param model [Symbol, OpenAI::Models::VideoModel] The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults
17
+ # @param model [String, Symbol, OpenAI::Models::VideoModel] The video generation model to use (allowed values: sora-2, sora-2-pro). Defaults
18
18
  #
19
19
  # @param seconds [Symbol, OpenAI::Models::VideoSeconds] Clip duration in seconds (allowed values: 4, 8, 12). Defaults to 4 seconds.
20
20
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenAI
4
- VERSION = "0.40.0"
4
+ VERSION = "0.42.0"
5
5
  end
data/lib/openai.rb CHANGED
@@ -385,6 +385,7 @@ require_relative "openai/models/fine_tuning/supervised_hyperparameters"
385
385
  require_relative "openai/models/fine_tuning/supervised_method"
386
386
  require_relative "openai/models/function_definition"
387
387
  require_relative "openai/models/function_parameters"
388
+ require_relative "openai/models/graders/grader_input_item"
388
389
  require_relative "openai/models/graders/grader_inputs"
389
390
  require_relative "openai/models/graders/label_model_grader"
390
391
  require_relative "openai/models/graders/multi_grader"
@@ -17,7 +17,7 @@ module OpenAI
17
17
  attr_accessor :input
18
18
 
19
19
  # One of the available [TTS models](https://platform.openai.com/docs/models#tts):
20
- # `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`.
20
+ # `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, or `gpt-4o-mini-tts-2025-12-15`.
21
21
  sig { returns(T.any(String, OpenAI::Audio::SpeechModel::OrSymbol)) }
22
22
  attr_accessor :model
23
23
 
@@ -103,7 +103,7 @@ module OpenAI
103
103
  # The text to generate audio for. The maximum length is 4096 characters.
104
104
  input:,
105
105
  # One of the available [TTS models](https://platform.openai.com/docs/models#tts):
106
- # `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`.
106
+ # `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, or `gpt-4o-mini-tts-2025-12-15`.
107
107
  model:,
108
108
  # The voice to use when generating the audio. Supported voices are `alloy`, `ash`,
109
109
  # `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and
@@ -150,7 +150,7 @@ module OpenAI
150
150
  end
151
151
 
152
152
  # One of the available [TTS models](https://platform.openai.com/docs/models#tts):
153
- # `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`.
153
+ # `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, or `gpt-4o-mini-tts-2025-12-15`.
154
154
  module Model
155
155
  extend OpenAI::Internal::Type::Union
156
156
 
@@ -14,6 +14,11 @@ module OpenAI
14
14
  TTS_1_HD = T.let(:"tts-1-hd", OpenAI::Audio::SpeechModel::TaggedSymbol)
15
15
  GPT_4O_MINI_TTS =
16
16
  T.let(:"gpt-4o-mini-tts", OpenAI::Audio::SpeechModel::TaggedSymbol)
17
+ GPT_4O_MINI_TTS_2025_12_15 =
18
+ T.let(
19
+ :"gpt-4o-mini-tts-2025-12-15",
20
+ OpenAI::Audio::SpeechModel::TaggedSymbol
21
+ )
17
22
 
18
23
  sig do
19
24
  override.returns(T::Array[OpenAI::Audio::SpeechModel::TaggedSymbol])
@@ -21,8 +21,9 @@ module OpenAI
21
21
  attr_accessor :file
22
22
 
23
23
  # ID of the model to use. The options are `gpt-4o-transcribe`,
24
- # `gpt-4o-mini-transcribe`, `whisper-1` (which is powered by our open source
25
- # Whisper V2 model), and `gpt-4o-transcribe-diarize`.
24
+ # `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `whisper-1`
25
+ # (which is powered by our open source Whisper V2 model), and
26
+ # `gpt-4o-transcribe-diarize`.
26
27
  sig { returns(T.any(String, OpenAI::AudioModel::OrSymbol)) }
27
28
  attr_accessor :model
28
29
 
@@ -47,9 +48,9 @@ module OpenAI
47
48
  # Additional information to include in the transcription response. `logprobs` will
48
49
  # return the log probabilities of the tokens in the response to understand the
49
50
  # model's confidence in the transcription. `logprobs` only works with
50
- # response_format set to `json` and only with the models `gpt-4o-transcribe` and
51
- # `gpt-4o-mini-transcribe`. This field is not supported when using
52
- # `gpt-4o-transcribe-diarize`.
51
+ # response_format set to `json` and only with the models `gpt-4o-transcribe`,
52
+ # `gpt-4o-mini-transcribe`, and `gpt-4o-mini-transcribe-2025-12-15`. This field is
53
+ # not supported when using `gpt-4o-transcribe-diarize`.
53
54
  sig do
54
55
  returns(
55
56
  T.nilable(T::Array[OpenAI::Audio::TranscriptionInclude::OrSymbol])
@@ -185,8 +186,9 @@ module OpenAI
185
186
  # flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
186
187
  file:,
187
188
  # ID of the model to use. The options are `gpt-4o-transcribe`,
188
- # `gpt-4o-mini-transcribe`, `whisper-1` (which is powered by our open source
189
- # Whisper V2 model), and `gpt-4o-transcribe-diarize`.
189
+ # `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `whisper-1`
190
+ # (which is powered by our open source Whisper V2 model), and
191
+ # `gpt-4o-transcribe-diarize`.
190
192
  model:,
191
193
  # Controls how the audio is cut into chunks. When set to `"auto"`, the server
192
194
  # first normalizes loudness and then uses voice activity detection (VAD) to choose
@@ -198,9 +200,9 @@ module OpenAI
198
200
  # Additional information to include in the transcription response. `logprobs` will
199
201
  # return the log probabilities of the tokens in the response to understand the
200
202
  # model's confidence in the transcription. `logprobs` only works with
201
- # response_format set to `json` and only with the models `gpt-4o-transcribe` and
202
- # `gpt-4o-mini-transcribe`. This field is not supported when using
203
- # `gpt-4o-transcribe-diarize`.
203
+ # response_format set to `json` and only with the models `gpt-4o-transcribe`,
204
+ # `gpt-4o-mini-transcribe`, and `gpt-4o-mini-transcribe-2025-12-15`. This field is
205
+ # not supported when using `gpt-4o-transcribe-diarize`.
204
206
  include: nil,
205
207
  # Optional list of speaker names that correspond to the audio samples provided in
206
208
  # `known_speaker_references[]`. Each entry should be a short identifier (for
@@ -276,8 +278,9 @@ module OpenAI
276
278
  end
277
279
 
278
280
  # ID of the model to use. The options are `gpt-4o-transcribe`,
279
- # `gpt-4o-mini-transcribe`, `whisper-1` (which is powered by our open source
280
- # Whisper V2 model), and `gpt-4o-transcribe-diarize`.
281
+ # `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `whisper-1`
282
+ # (which is powered by our open source Whisper V2 model), and
283
+ # `gpt-4o-transcribe-diarize`.
281
284
  module Model
282
285
  extend OpenAI::Internal::Type::Union
283
286
 
@@ -13,6 +13,11 @@ module OpenAI
13
13
  T.let(:"gpt-4o-transcribe", OpenAI::AudioModel::TaggedSymbol)
14
14
  GPT_4O_MINI_TRANSCRIBE =
15
15
  T.let(:"gpt-4o-mini-transcribe", OpenAI::AudioModel::TaggedSymbol)
16
+ GPT_4O_MINI_TRANSCRIBE_2025_12_15 =
17
+ T.let(
18
+ :"gpt-4o-mini-transcribe-2025-12-15",
19
+ OpenAI::AudioModel::TaggedSymbol
20
+ )
16
21
  GPT_4O_TRANSCRIBE_DIARIZE =
17
22
  T.let(:"gpt-4o-transcribe-diarize", OpenAI::AudioModel::TaggedSymbol)
18
23
 
@@ -0,0 +1,112 @@
1
+ # typed: strong
2
+
3
+ module OpenAI
4
+ module Models
5
+ module Graders
6
+ # A single content item: input text, output text, input image, or input audio.
7
+ module GraderInputItem
8
+ extend OpenAI::Internal::Type::Union
9
+
10
+ Variants =
11
+ T.type_alias do
12
+ T.any(
13
+ String,
14
+ OpenAI::Responses::ResponseInputText,
15
+ OpenAI::Graders::GraderInputItem::OutputText,
16
+ OpenAI::Graders::GraderInputItem::InputImage,
17
+ OpenAI::Responses::ResponseInputAudio
18
+ )
19
+ end
20
+
21
+ class OutputText < OpenAI::Internal::Type::BaseModel
22
+ OrHash =
23
+ T.type_alias do
24
+ T.any(
25
+ OpenAI::Graders::GraderInputItem::OutputText,
26
+ OpenAI::Internal::AnyHash
27
+ )
28
+ end
29
+
30
+ # The text output from the model.
31
+ sig { returns(String) }
32
+ attr_accessor :text
33
+
34
+ # The type of the output text. Always `output_text`.
35
+ sig { returns(Symbol) }
36
+ attr_accessor :type
37
+
38
+ # A text output from the model.
39
+ sig { params(text: String, type: Symbol).returns(T.attached_class) }
40
+ def self.new(
41
+ # The text output from the model.
42
+ text:,
43
+ # The type of the output text. Always `output_text`.
44
+ type: :output_text
45
+ )
46
+ end
47
+
48
+ sig { override.returns({ text: String, type: Symbol }) }
49
+ def to_hash
50
+ end
51
+ end
52
+
53
+ class InputImage < OpenAI::Internal::Type::BaseModel
54
+ OrHash =
55
+ T.type_alias do
56
+ T.any(
57
+ OpenAI::Graders::GraderInputItem::InputImage,
58
+ OpenAI::Internal::AnyHash
59
+ )
60
+ end
61
+
62
+ # The URL of the image input.
63
+ sig { returns(String) }
64
+ attr_accessor :image_url
65
+
66
+ # The type of the image input. Always `input_image`.
67
+ sig { returns(Symbol) }
68
+ attr_accessor :type
69
+
70
+ # The detail level of the image to be sent to the model. One of `high`, `low`, or
71
+ # `auto`. Defaults to `auto`.
72
+ sig { returns(T.nilable(String)) }
73
+ attr_reader :detail
74
+
75
+ sig { params(detail: String).void }
76
+ attr_writer :detail
77
+
78
+ # An image input block used within EvalItem content arrays.
79
+ sig do
80
+ params(image_url: String, detail: String, type: Symbol).returns(
81
+ T.attached_class
82
+ )
83
+ end
84
+ def self.new(
85
+ # The URL of the image input.
86
+ image_url:,
87
+ # The detail level of the image to be sent to the model. One of `high`, `low`, or
88
+ # `auto`. Defaults to `auto`.
89
+ detail: nil,
90
+ # The type of the image input. Always `input_image`.
91
+ type: :input_image
92
+ )
93
+ end
94
+
95
+ sig do
96
+ override.returns(
97
+ { image_url: String, type: Symbol, detail: String }
98
+ )
99
+ end
100
+ def to_hash
101
+ end
102
+ end
103
+
104
+ sig do
105
+ override.returns(T::Array[OpenAI::Graders::GraderInputItem::Variants])
106
+ end
107
+ def self.variants
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
@@ -6,111 +6,6 @@ module OpenAI
6
6
  T.let(Graders::GraderInputs, OpenAI::Internal::Type::Converter)
7
7
 
8
8
  module Graders
9
- # A single content item: input text, output text, input image, or input audio.
10
- module GraderInputItem
11
- extend OpenAI::Internal::Type::Union
12
-
13
- Variants =
14
- T.type_alias do
15
- T.any(
16
- String,
17
- OpenAI::Responses::ResponseInputText,
18
- OpenAI::Graders::GraderInputItem::OutputText,
19
- OpenAI::Graders::GraderInputItem::InputImage,
20
- OpenAI::Responses::ResponseInputAudio
21
- )
22
- end
23
-
24
- class OutputText < OpenAI::Internal::Type::BaseModel
25
- OrHash =
26
- T.type_alias do
27
- T.any(
28
- OpenAI::Graders::GraderInputItem::OutputText,
29
- OpenAI::Internal::AnyHash
30
- )
31
- end
32
-
33
- # The text output from the model.
34
- sig { returns(String) }
35
- attr_accessor :text
36
-
37
- # The type of the output text. Always `output_text`.
38
- sig { returns(Symbol) }
39
- attr_accessor :type
40
-
41
- # A text output from the model.
42
- sig { params(text: String, type: Symbol).returns(T.attached_class) }
43
- def self.new(
44
- # The text output from the model.
45
- text:,
46
- # The type of the output text. Always `output_text`.
47
- type: :output_text
48
- )
49
- end
50
-
51
- sig { override.returns({ text: String, type: Symbol }) }
52
- def to_hash
53
- end
54
- end
55
-
56
- class InputImage < OpenAI::Internal::Type::BaseModel
57
- OrHash =
58
- T.type_alias do
59
- T.any(
60
- OpenAI::Graders::GraderInputItem::InputImage,
61
- OpenAI::Internal::AnyHash
62
- )
63
- end
64
-
65
- # The URL of the image input.
66
- sig { returns(String) }
67
- attr_accessor :image_url
68
-
69
- # The type of the image input. Always `input_image`.
70
- sig { returns(Symbol) }
71
- attr_accessor :type
72
-
73
- # The detail level of the image to be sent to the model. One of `high`, `low`, or
74
- # `auto`. Defaults to `auto`.
75
- sig { returns(T.nilable(String)) }
76
- attr_reader :detail
77
-
78
- sig { params(detail: String).void }
79
- attr_writer :detail
80
-
81
- # An image input block used within EvalItem content arrays.
82
- sig do
83
- params(image_url: String, detail: String, type: Symbol).returns(
84
- T.attached_class
85
- )
86
- end
87
- def self.new(
88
- # The URL of the image input.
89
- image_url:,
90
- # The detail level of the image to be sent to the model. One of `high`, `low`, or
91
- # `auto`. Defaults to `auto`.
92
- detail: nil,
93
- # The type of the image input. Always `input_image`.
94
- type: :input_image
95
- )
96
- end
97
-
98
- sig do
99
- override.returns(
100
- { image_url: String, type: Symbol, detail: String }
101
- )
102
- end
103
- def to_hash
104
- end
105
- end
106
-
107
- sig do
108
- override.returns(T::Array[OpenAI::Graders::GraderInputItem::Variants])
109
- end
110
- def self.variants
111
- end
112
- end
113
-
114
9
  GraderInputs =
115
10
  T.let(
116
11
  OpenAI::Internal::Type::ArrayOf[
@@ -5,9 +5,9 @@ module OpenAI
5
5
  class Image < OpenAI::Internal::Type::BaseModel
6
6
  OrHash = T.type_alias { T.any(OpenAI::Image, OpenAI::Internal::AnyHash) }
7
7
 
8
- # The base64-encoded JSON of the generated image. Default value for `gpt-image-1`,
9
- # and only present if `response_format` is set to `b64_json` for `dall-e-2` and
10
- # `dall-e-3`.
8
+ # The base64-encoded JSON of the generated image. Returned by default for the GPT
9
+ # image models, and only present if `response_format` is set to `b64_json` for
10
+ # `dall-e-2` and `dall-e-3`.
11
11
  sig { returns(T.nilable(String)) }
12
12
  attr_reader :b64_json
13
13
 
@@ -22,8 +22,8 @@ module OpenAI
22
22
  attr_writer :revised_prompt
23
23
 
24
24
  # When using `dall-e-2` or `dall-e-3`, the URL of the generated image if
25
- # `response_format` is set to `url` (default value). Unsupported for
26
- # `gpt-image-1`.
25
+ # `response_format` is set to `url` (default value). Unsupported for the GPT image
26
+ # models.
27
27
  sig { returns(T.nilable(String)) }
28
28
  attr_reader :url
29
29
 
@@ -37,15 +37,15 @@ module OpenAI
37
37
  )
38
38
  end
39
39
  def self.new(
40
- # The base64-encoded JSON of the generated image. Default value for `gpt-image-1`,
41
- # and only present if `response_format` is set to `b64_json` for `dall-e-2` and
42
- # `dall-e-3`.
40
+ # The base64-encoded JSON of the generated image. Returned by default for the GPT
41
+ # image models, and only present if `response_format` is set to `b64_json` for
42
+ # `dall-e-2` and `dall-e-3`.
43
43
  b64_json: nil,
44
44
  # For `dall-e-3` only, the revised prompt that was used to generate the image.
45
45
  revised_prompt: nil,
46
46
  # When using `dall-e-2` or `dall-e-3`, the URL of the generated image if
47
- # `response_format` is set to `url` (default value). Unsupported for
48
- # `gpt-image-1`.
47
+ # `response_format` is set to `url` (default value). Unsupported for the GPT image
48
+ # models.
49
49
  url: nil
50
50
  )
51
51
  end
@@ -38,7 +38,8 @@ module OpenAI
38
38
  sig { returns(Symbol) }
39
39
  attr_accessor :type
40
40
 
41
- # For `gpt-image-1` only, the token usage information for the image generation.
41
+ # For the GPT image models only, the token usage information for the image
42
+ # generation.
42
43
  sig { returns(OpenAI::ImageEditCompletedEvent::Usage) }
43
44
  attr_reader :usage
44
45
 
@@ -72,7 +73,8 @@ module OpenAI
72
73
  quality:,
73
74
  # The size of the edited image.
74
75
  size:,
75
- # For `gpt-image-1` only, the token usage information for the image generation.
76
+ # For the GPT image models only, the token usage information for the image
77
+ # generation.
76
78
  usage:,
77
79
  # The type of the event. Always `image_edit.completed`.
78
80
  type: :"image_edit.completed"
@@ -267,7 +269,8 @@ module OpenAI
267
269
  sig { returns(Integer) }
268
270
  attr_accessor :total_tokens
269
271
 
270
- # For `gpt-image-1` only, the token usage information for the image generation.
272
+ # For the GPT image models only, the token usage information for the image
273
+ # generation.
271
274
  sig do
272
275
  params(
273
276
  input_tokens: Integer,