Skip to content

Commit bff4224

Browse files
feat(api): realtime 2
1 parent 1cf47e8 commit bff4224

44 files changed

Lines changed: 682 additions & 204 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 232
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-08cb8ed18dfe4a9fa518e278576d3cfe5710cb5c22789cf80826c900569bcf56.yml
3-
openapi_spec_hash: 20f820c94f54741b75d719f6a7371c12
4-
config_hash: f291a449469edfe61a28424e548899b2
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-371f497afe4d6070f6e252e5febbe8f453c7058a8dff0c26a01b4d88442a4ac2.yml
3+
openapi_spec_hash: d39f46e8fda45f77096448105efd175a
4+
config_hash: b64135fff1fe9cf4069b9ecf59ae8b07

lib/openai.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,8 @@
629629
require_relative "openai/models/realtime/realtime_mcp_protocol_error"
630630
require_relative "openai/models/realtime/realtime_mcp_tool_call"
631631
require_relative "openai/models/realtime/realtime_mcp_tool_execution_error"
632+
require_relative "openai/models/realtime/realtime_reasoning"
633+
require_relative "openai/models/realtime/realtime_reasoning_effort"
632634
require_relative "openai/models/realtime/realtime_response"
633635
require_relative "openai/models/realtime/realtime_response_create_audio_output"
634636
require_relative "openai/models/realtime/realtime_response_create_mcp_tool"
@@ -639,7 +641,6 @@
639641
require_relative "openai/models/realtime/realtime_response_usage_output_token_details"
640642
require_relative "openai/models/realtime/realtime_server_event"
641643
require_relative "openai/models/realtime/realtime_session"
642-
require_relative "openai/models/realtime/realtime_session_client_secret"
643644
require_relative "openai/models/realtime/realtime_session_create_response"
644645
require_relative "openai/models/realtime/realtime_tool_choice_config"
645646
require_relative "openai/models/realtime/realtime_tools_config"

lib/openai/models/realtime/audio_transcription.rb

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ module OpenAI
44
module Models
55
module Realtime
66
class AudioTranscription < OpenAI::Internal::Type::BaseModel
7+
# @!attribute delay
8+
# Controls how long the model waits before emitting transcription text. Higher
9+
# values can improve transcription accuracy at the cost of latency. Only supported
10+
# with `gpt-realtime-whisper` in GA Realtime sessions.
11+
#
12+
# @return [Symbol, OpenAI::Models::Realtime::AudioTranscription::Delay, nil]
13+
optional :delay, enum: -> { OpenAI::Realtime::AudioTranscription::Delay }
14+
715
# @!attribute language
816
# The language of the input audio. Supplying the input language in
917
# [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
@@ -15,8 +23,8 @@ class AudioTranscription < OpenAI::Internal::Type::BaseModel
1523
# @!attribute model
1624
# The model to use for transcription. Current options are `whisper-1`,
1725
# `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`,
18-
# `gpt-4o-transcribe`, and `gpt-4o-transcribe-diarize`. Use
19-
# `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.
26+
# `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`.
27+
# Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.
2028
#
2129
# @return [String, Symbol, OpenAI::Models::Realtime::AudioTranscription::Model, nil]
2230
optional :model, union: -> { OpenAI::Realtime::AudioTranscription::Model }
@@ -27,24 +35,45 @@ class AudioTranscription < OpenAI::Internal::Type::BaseModel
2735
# [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
2836
# For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the
2937
# prompt is a free text string, for example "expect words related to technology".
38+
# Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.
3039
#
3140
# @return [String, nil]
3241
optional :prompt, String
3342

34-
# @!method initialize(language: nil, model: nil, prompt: nil)
43+
# @!method initialize(delay: nil, language: nil, model: nil, prompt: nil)
3544
# Some parameter documentations has been truncated, see
3645
# {OpenAI::Models::Realtime::AudioTranscription} for more details.
3746
#
47+
# @param delay [Symbol, OpenAI::Models::Realtime::AudioTranscription::Delay] Controls how long the model waits before emitting transcription text.
48+
#
3849
# @param language [String] The language of the input audio. Supplying the input language in
3950
#
4051
# @param model [String, Symbol, OpenAI::Models::Realtime::AudioTranscription::Model] The model to use for transcription. Current options are `whisper-1`, `gpt-4o-min
4152
#
4253
# @param prompt [String] An optional text to guide the model's style or continue a previous audio
4354

55+
# Controls how long the model waits before emitting transcription text. Higher
56+
# values can improve transcription accuracy at the cost of latency. Only supported
57+
# with `gpt-realtime-whisper` in GA Realtime sessions.
58+
#
59+
# @see OpenAI::Models::Realtime::AudioTranscription#delay
60+
module Delay
61+
extend OpenAI::Internal::Type::Enum
62+
63+
MINIMAL = :minimal
64+
LOW = :low
65+
MEDIUM = :medium
66+
HIGH = :high
67+
XHIGH = :xhigh
68+
69+
# @!method self.values
70+
# @return [Array<Symbol>]
71+
end
72+
4473
# The model to use for transcription. Current options are `whisper-1`,
4574
# `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`,
46-
# `gpt-4o-transcribe`, and `gpt-4o-transcribe-diarize`. Use
47-
# `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.
75+
# `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`.
76+
# Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.
4877
#
4978
# @see OpenAI::Models::Realtime::AudioTranscription#model
5079
module Model
@@ -62,6 +91,8 @@ module Model
6291

6392
variant const: -> { OpenAI::Models::Realtime::AudioTranscription::Model::GPT_4O_TRANSCRIBE_DIARIZE }
6493

94+
variant const: -> { OpenAI::Models::Realtime::AudioTranscription::Model::GPT_REALTIME_WHISPER }
95+
6596
# @!method self.variants
6697
# @return [Array(String, Symbol)]
6798

@@ -76,6 +107,7 @@ module Model
76107
GPT_4O_MINI_TRANSCRIBE_2025_12_15 = :"gpt-4o-mini-transcribe-2025-12-15"
77108
GPT_4O_TRANSCRIBE = :"gpt-4o-transcribe"
78109
GPT_4O_TRANSCRIBE_DIARIZE = :"gpt-4o-transcribe-diarize"
110+
GPT_REALTIME_WHISPER = :"gpt-realtime-whisper"
79111

80112
# @!endgroup
81113
end

lib/openai/models/realtime/client_secret_create_response.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ module Session
4343

4444
discriminator :type
4545

46-
# A new Realtime session configuration, with an ephemeral key. Default TTL
47-
# for keys is one minute.
46+
# A Realtime session configuration object.
4847
variant :realtime, -> { OpenAI::Realtime::RealtimeSessionCreateResponse }
4948

5049
# A Realtime transcription session configuration object.

lib/openai/models/realtime/realtime_audio_config_input.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ class RealtimeAudioConfigInput < OpenAI::Internal::Type::BaseModel
4848
# wait longer for the user to continue speaking. This can be useful for more
4949
# natural conversations, but may have a higher latency.
5050
#
51+
# For `gpt-realtime-whisper` transcription sessions, turn detection must be set to
52+
# `null`; VAD is not supported.
53+
#
5154
# @return [OpenAI::Models::Realtime::RealtimeAudioInputTurnDetection::ServerVad, OpenAI::Models::Realtime::RealtimeAudioInputTurnDetection::SemanticVad, nil]
5255
optional :turn_detection, union: -> { OpenAI::Realtime::RealtimeAudioInputTurnDetection }, nil?: true
5356

lib/openai/models/realtime/realtime_audio_input_turn_detection.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ module Realtime
1616
# trails off with "uhhm", the model will score a low probability of turn end and
1717
# wait longer for the user to continue speaking. This can be useful for more
1818
# natural conversations, but may have a higher latency.
19+
#
20+
# For `gpt-realtime-whisper` transcription sessions, turn detection must be set to
21+
# `null`; VAD is not supported.
1922
module RealtimeAudioInputTurnDetection
2023
extend OpenAI::Internal::Type::Union
2124

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# frozen_string_literal: true
2+
3+
module OpenAI
4+
module Models
5+
module Realtime
6+
class RealtimeReasoning < OpenAI::Internal::Type::BaseModel
7+
# @!attribute effort
8+
# Constrains effort on reasoning for reasoning-capable Realtime models such as
9+
# `gpt-realtime-2`.
10+
#
11+
# @return [Symbol, OpenAI::Models::Realtime::RealtimeReasoningEffort, nil]
12+
optional :effort, enum: -> { OpenAI::Realtime::RealtimeReasoningEffort }
13+
14+
# @!method initialize(effort: nil)
15+
# Some parameter documentations has been truncated, see
16+
# {OpenAI::Models::Realtime::RealtimeReasoning} for more details.
17+
#
18+
# Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.
19+
#
20+
# @param effort [Symbol, OpenAI::Models::Realtime::RealtimeReasoningEffort] Constrains effort on reasoning for reasoning-capable Realtime models such as
21+
end
22+
end
23+
end
24+
end
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
module OpenAI
4+
module Models
5+
module Realtime
6+
# Constrains effort on reasoning for reasoning-capable Realtime models such as
7+
# `gpt-realtime-2`.
8+
module RealtimeReasoningEffort
9+
extend OpenAI::Internal::Type::Enum
10+
11+
MINIMAL = :minimal
12+
LOW = :low
13+
MEDIUM = :medium
14+
HIGH = :high
15+
XHIGH = :xhigh
16+
17+
# @!method self.values
18+
# @return [Array<Symbol>]
19+
end
20+
end
21+
end
22+
end

lib/openai/models/realtime/realtime_response_create_params.rb

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,26 @@ class RealtimeResponseCreateParams < OpenAI::Internal::Type::BaseModel
7373
optional :output_modalities,
7474
-> { OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Realtime::RealtimeResponseCreateParams::OutputModality] }
7575

76+
# @!attribute parallel_tool_calls
77+
# Whether the model may call multiple tools in parallel. Only supported by
78+
# reasoning Realtime models such as `gpt-realtime-2`.
79+
#
80+
# @return [Boolean, nil]
81+
optional :parallel_tool_calls, OpenAI::Internal::Type::Boolean
82+
7683
# @!attribute prompt
7784
# Reference to a prompt template and its variables.
7885
# [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
7986
#
8087
# @return [OpenAI::Models::Responses::ResponsePrompt, nil]
8188
optional :prompt, -> { OpenAI::Responses::ResponsePrompt }, nil?: true
8289

90+
# @!attribute reasoning
91+
# Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.
92+
#
93+
# @return [OpenAI::Models::Realtime::RealtimeReasoning, nil]
94+
optional :reasoning, -> { OpenAI::Realtime::RealtimeReasoning }
95+
8396
# @!attribute tool_choice
8497
# How the model chooses tools. Provide one of the string modes or force a specific
8598
# function/MCP tool.
@@ -94,7 +107,7 @@ class RealtimeResponseCreateParams < OpenAI::Internal::Type::BaseModel
94107
optional :tools,
95108
-> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Realtime::RealtimeResponseCreateParams::Tool] }
96109

97-
# @!method initialize(audio: nil, conversation: nil, input: nil, instructions: nil, max_output_tokens: nil, metadata: nil, output_modalities: nil, prompt: nil, tool_choice: nil, tools: nil)
110+
# @!method initialize(audio: nil, conversation: nil, input: nil, instructions: nil, max_output_tokens: nil, metadata: nil, output_modalities: nil, parallel_tool_calls: nil, prompt: nil, reasoning: nil, tool_choice: nil, tools: nil)
98111
# Some parameter documentations has been truncated, see
99112
# {OpenAI::Models::Realtime::RealtimeResponseCreateParams} for more details.
100113
#
@@ -114,8 +127,12 @@ class RealtimeResponseCreateParams < OpenAI::Internal::Type::BaseModel
114127
#
115128
# @param output_modalities [Array<Symbol, OpenAI::Models::Realtime::RealtimeResponseCreateParams::OutputModality>] The set of modalities the model used to respond, currently the only possible val
116129
#
130+
# @param parallel_tool_calls [Boolean] Whether the model may call multiple tools in parallel. Only supported by
131+
#
117132
# @param prompt [OpenAI::Models::Responses::ResponsePrompt, nil] Reference to a prompt template and its variables.
118133
#
134+
# @param reasoning [OpenAI::Models::Realtime::RealtimeReasoning] Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.
135+
#
119136
# @param tool_choice [Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceFunction, OpenAI::Models::Responses::ToolChoiceMcp] How the model chooses tools. Provide one of the string modes or force a specific
120137
#
121138
# @param tools [Array<OpenAI::Models::Realtime::RealtimeFunctionTool, OpenAI::Models::Realtime::RealtimeResponseCreateMcpTool>] Tools available to the model.

lib/openai/models/realtime/realtime_session.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ class RealtimeSession < OpenAI::Internal::Type::BaseModel
170170
# wait longer for the user to continue speaking. This can be useful for more
171171
# natural conversations, but may have a higher latency.
172172
#
173+
# For `gpt-realtime-whisper` transcription sessions, turn detection must be set to
174+
# `null`; VAD is not supported.
175+
#
173176
# @return [OpenAI::Models::Realtime::RealtimeSession::TurnDetection::ServerVad, OpenAI::Models::Realtime::RealtimeSession::TurnDetection::SemanticVad, nil]
174177
optional :turn_detection, union: -> { OpenAI::Realtime::RealtimeSession::TurnDetection }, nil?: true
175178

@@ -468,6 +471,9 @@ class TracingConfiguration < OpenAI::Internal::Type::BaseModel
468471
# wait longer for the user to continue speaking. This can be useful for more
469472
# natural conversations, but may have a higher latency.
470473
#
474+
# For `gpt-realtime-whisper` transcription sessions, turn detection must be set to
475+
# `null`; VAD is not supported.
476+
#
471477
# @see OpenAI::Models::Realtime::RealtimeSession#turn_detection
472478
module TurnDetection
473479
extend OpenAI::Internal::Type::Union

0 commit comments

Comments
 (0)