Skip to content

Commit 733ebfb

Browse files
feat(api): update api shapes for usage and code interpreter
1 parent aebd8eb commit 733ebfb

File tree

46 files changed

+1539
-510
lines changed

Some content is hidden

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

46 files changed

+1539
-510
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 109
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-f411a68f272b8be0ab0c266043da33228687b9b2d76896724e3cef797de9563d.yml
3-
openapi_spec_hash: 89bf866ea95ecfb3d76c8833237047d6
4-
config_hash: dc5515e257676a27cb1ace1784aa92b3
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-ef4ecb19eb61e24c49d77fef769ee243e5279bc0bdbaee8d0f8dba4da8722559.yml
3+
openapi_spec_hash: 1b8a9767c9f04e6865b06c41948cdc24
4+
config_hash: fd2af1d5eff0995bb7dc02ac9a34851d

lib/openai/models/audio/speech_create_params.rb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,19 @@ class SpeechCreateParams < OpenAI::Internal::Type::BaseModel
4646

4747
# @!attribute speed
4848
# The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is
49-
# the default. Does not work with `gpt-4o-mini-tts`.
49+
# the default.
5050
#
5151
# @return [Float, nil]
5252
optional :speed, Float
5353

54-
# @!method initialize(input:, model:, voice:, instructions: nil, response_format: nil, speed: nil, request_options: {})
54+
# @!attribute stream_format
55+
# The format to stream the audio in. Supported formats are `sse` and `audio`.
56+
# `sse` is not supported for `tts-1` or `tts-1-hd`.
57+
#
58+
# @return [Symbol, OpenAI::Models::Audio::SpeechCreateParams::StreamFormat, nil]
59+
optional :stream_format, enum: -> { OpenAI::Audio::SpeechCreateParams::StreamFormat }
60+
61+
# @!method initialize(input:, model:, voice:, instructions: nil, response_format: nil, speed: nil, stream_format: nil, request_options: {})
5562
# Some parameter documentations has been truncated, see
5663
# {OpenAI::Models::Audio::SpeechCreateParams} for more details.
5764
#
@@ -67,6 +74,8 @@ class SpeechCreateParams < OpenAI::Internal::Type::BaseModel
6774
#
6875
# @param speed [Float] The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is
6976
#
77+
# @param stream_format [Symbol, OpenAI::Models::Audio::SpeechCreateParams::StreamFormat] The format to stream the audio in. Supported formats are `sse` and `audio`. `sse
78+
#
7079
# @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
7180

7281
# One of the available [TTS models](https://platform.openai.com/docs/models#tts):
@@ -153,6 +162,18 @@ module ResponseFormat
153162
# @!method self.values
154163
# @return [Array<Symbol>]
155164
end
165+
166+
# The format to stream the audio in. Supported formats are `sse` and `audio`.
167+
# `sse` is not supported for `tts-1` or `tts-1-hd`.
168+
module StreamFormat
169+
extend OpenAI::Internal::Type::Enum
170+
171+
SSE = :sse
172+
AUDIO = :audio
173+
174+
# @!method self.values
175+
# @return [Array<Symbol>]
176+
end
156177
end
157178
end
158179
end

lib/openai/models/audio/transcription.rb

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ class Transcription < OpenAI::Internal::Type::BaseModel
1818
# @return [Array<OpenAI::Models::Audio::Transcription::Logprob>, nil]
1919
optional :logprobs, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Audio::Transcription::Logprob] }
2020

21-
# @!method initialize(text:, logprobs: nil)
21+
# @!attribute usage
22+
# Token usage statistics for the request.
23+
#
24+
# @return [OpenAI::Models::Audio::Transcription::Usage::Tokens, OpenAI::Models::Audio::Transcription::Usage::Duration, nil]
25+
optional :usage, union: -> { OpenAI::Audio::Transcription::Usage }
26+
27+
# @!method initialize(text:, logprobs: nil, usage: nil)
2228
# Some parameter documentations has been truncated, see
2329
# {OpenAI::Models::Audio::Transcription} for more details.
2430
#
@@ -28,6 +34,8 @@ class Transcription < OpenAI::Internal::Type::BaseModel
2834
# @param text [String] The transcribed text.
2935
#
3036
# @param logprobs [Array<OpenAI::Models::Audio::Transcription::Logprob>] The log probabilities of the tokens in the transcription. Only returned with the
37+
#
38+
# @param usage [OpenAI::Models::Audio::Transcription::Usage::Tokens, OpenAI::Models::Audio::Transcription::Usage::Duration] Token usage statistics for the request.
3139

3240
class Logprob < OpenAI::Internal::Type::BaseModel
3341
# @!attribute token
@@ -55,6 +63,115 @@ class Logprob < OpenAI::Internal::Type::BaseModel
5563
#
5664
# @param logprob [Float] The log probability of the token.
5765
end
66+
67+
# Token usage statistics for the request.
68+
#
69+
# @see OpenAI::Models::Audio::Transcription#usage
70+
module Usage
71+
extend OpenAI::Internal::Type::Union
72+
73+
discriminator :type
74+
75+
# Usage statistics for models billed by token usage.
76+
variant :tokens, -> { OpenAI::Audio::Transcription::Usage::Tokens }
77+
78+
# Usage statistics for models billed by audio input duration.
79+
variant :duration, -> { OpenAI::Audio::Transcription::Usage::Duration }
80+
81+
class Tokens < OpenAI::Internal::Type::BaseModel
82+
# @!attribute input_tokens
83+
# Number of input tokens billed for this request.
84+
#
85+
# @return [Integer]
86+
required :input_tokens, Integer
87+
88+
# @!attribute output_tokens
89+
# Number of output tokens generated.
90+
#
91+
# @return [Integer]
92+
required :output_tokens, Integer
93+
94+
# @!attribute total_tokens
95+
# Total number of tokens used (input + output).
96+
#
97+
# @return [Integer]
98+
required :total_tokens, Integer
99+
100+
# @!attribute type
101+
# The type of the usage object. Always `tokens` for this variant.
102+
#
103+
# @return [Symbol, :tokens]
104+
required :type, const: :tokens
105+
106+
# @!attribute input_token_details
107+
# Details about the input tokens billed for this request.
108+
#
109+
# @return [OpenAI::Models::Audio::Transcription::Usage::Tokens::InputTokenDetails, nil]
110+
optional :input_token_details,
111+
-> {
112+
OpenAI::Audio::Transcription::Usage::Tokens::InputTokenDetails
113+
}
114+
115+
# @!method initialize(input_tokens:, output_tokens:, total_tokens:, input_token_details: nil, type: :tokens)
116+
# Usage statistics for models billed by token usage.
117+
#
118+
# @param input_tokens [Integer] Number of input tokens billed for this request.
119+
#
120+
# @param output_tokens [Integer] Number of output tokens generated.
121+
#
122+
# @param total_tokens [Integer] Total number of tokens used (input + output).
123+
#
124+
# @param input_token_details [OpenAI::Models::Audio::Transcription::Usage::Tokens::InputTokenDetails] Details about the input tokens billed for this request.
125+
#
126+
# @param type [Symbol, :tokens] The type of the usage object. Always `tokens` for this variant.
127+
128+
# @see OpenAI::Models::Audio::Transcription::Usage::Tokens#input_token_details
129+
class InputTokenDetails < OpenAI::Internal::Type::BaseModel
130+
# @!attribute audio_tokens
131+
# Number of audio tokens billed for this request.
132+
#
133+
# @return [Integer, nil]
134+
optional :audio_tokens, Integer
135+
136+
# @!attribute text_tokens
137+
# Number of text tokens billed for this request.
138+
#
139+
# @return [Integer, nil]
140+
optional :text_tokens, Integer
141+
142+
# @!method initialize(audio_tokens: nil, text_tokens: nil)
143+
# Details about the input tokens billed for this request.
144+
#
145+
# @param audio_tokens [Integer] Number of audio tokens billed for this request.
146+
#
147+
# @param text_tokens [Integer] Number of text tokens billed for this request.
148+
end
149+
end
150+
151+
class Duration < OpenAI::Internal::Type::BaseModel
152+
# @!attribute duration
153+
# Duration of the input audio in seconds.
154+
#
155+
# @return [Float]
156+
required :duration, Float
157+
158+
# @!attribute type
159+
# The type of the usage object. Always `duration` for this variant.
160+
#
161+
# @return [Symbol, :duration]
162+
required :type, const: :duration
163+
164+
# @!method initialize(duration:, type: :duration)
165+
# Usage statistics for models billed by audio input duration.
166+
#
167+
# @param duration [Float] Duration of the input audio in seconds.
168+
#
169+
# @param type [Symbol, :duration] The type of the usage object. Always `duration` for this variant.
170+
end
171+
172+
# @!method self.variants
173+
# @return [Array(OpenAI::Models::Audio::Transcription::Usage::Tokens, OpenAI::Models::Audio::Transcription::Usage::Duration)]
174+
end
58175
end
59176
end
60177
end

lib/openai/models/audio/transcription_text_done_event.rb

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ class TranscriptionTextDoneEvent < OpenAI::Internal::Type::BaseModel
2626
optional :logprobs,
2727
-> { OpenAI::Internal::Type::ArrayOf[OpenAI::Audio::TranscriptionTextDoneEvent::Logprob] }
2828

29-
# @!method initialize(text:, logprobs: nil, type: :"transcript.text.done")
29+
# @!attribute usage
30+
# Usage statistics for models billed by token usage.
31+
#
32+
# @return [OpenAI::Models::Audio::TranscriptionTextDoneEvent::Usage, nil]
33+
optional :usage, -> { OpenAI::Audio::TranscriptionTextDoneEvent::Usage }
34+
35+
# @!method initialize(text:, logprobs: nil, usage: nil, type: :"transcript.text.done")
3036
# Some parameter documentations has been truncated, see
3137
# {OpenAI::Models::Audio::TranscriptionTextDoneEvent} for more details.
3238
#
@@ -39,6 +45,8 @@ class TranscriptionTextDoneEvent < OpenAI::Internal::Type::BaseModel
3945
#
4046
# @param logprobs [Array<OpenAI::Models::Audio::TranscriptionTextDoneEvent::Logprob>] The log probabilities of the individual tokens in the transcription. Only includ
4147
#
48+
# @param usage [OpenAI::Models::Audio::TranscriptionTextDoneEvent::Usage] Usage statistics for models billed by token usage.
49+
#
4250
# @param type [Symbol, :"transcript.text.done"] The type of the event. Always `transcript.text.done`.
4351

4452
class Logprob < OpenAI::Internal::Type::BaseModel
@@ -70,6 +78,77 @@ class Logprob < OpenAI::Internal::Type::BaseModel
7078
#
7179
# @param logprob [Float] The log probability of the token.
7280
end
81+
82+
# @see OpenAI::Models::Audio::TranscriptionTextDoneEvent#usage
83+
class Usage < OpenAI::Internal::Type::BaseModel
84+
# @!attribute input_tokens
85+
# Number of input tokens billed for this request.
86+
#
87+
# @return [Integer]
88+
required :input_tokens, Integer
89+
90+
# @!attribute output_tokens
91+
# Number of output tokens generated.
92+
#
93+
# @return [Integer]
94+
required :output_tokens, Integer
95+
96+
# @!attribute total_tokens
97+
# Total number of tokens used (input + output).
98+
#
99+
# @return [Integer]
100+
required :total_tokens, Integer
101+
102+
# @!attribute type
103+
# The type of the usage object. Always `tokens` for this variant.
104+
#
105+
# @return [Symbol, :tokens]
106+
required :type, const: :tokens
107+
108+
# @!attribute input_token_details
109+
# Details about the input tokens billed for this request.
110+
#
111+
# @return [OpenAI::Models::Audio::TranscriptionTextDoneEvent::Usage::InputTokenDetails, nil]
112+
optional :input_token_details,
113+
-> {
114+
OpenAI::Audio::TranscriptionTextDoneEvent::Usage::InputTokenDetails
115+
}
116+
117+
# @!method initialize(input_tokens:, output_tokens:, total_tokens:, input_token_details: nil, type: :tokens)
118+
# Usage statistics for models billed by token usage.
119+
#
120+
# @param input_tokens [Integer] Number of input tokens billed for this request.
121+
#
122+
# @param output_tokens [Integer] Number of output tokens generated.
123+
#
124+
# @param total_tokens [Integer] Total number of tokens used (input + output).
125+
#
126+
# @param input_token_details [OpenAI::Models::Audio::TranscriptionTextDoneEvent::Usage::InputTokenDetails] Details about the input tokens billed for this request.
127+
#
128+
# @param type [Symbol, :tokens] The type of the usage object. Always `tokens` for this variant.
129+
130+
# @see OpenAI::Models::Audio::TranscriptionTextDoneEvent::Usage#input_token_details
131+
class InputTokenDetails < OpenAI::Internal::Type::BaseModel
132+
# @!attribute audio_tokens
133+
# Number of audio tokens billed for this request.
134+
#
135+
# @return [Integer, nil]
136+
optional :audio_tokens, Integer
137+
138+
# @!attribute text_tokens
139+
# Number of text tokens billed for this request.
140+
#
141+
# @return [Integer, nil]
142+
optional :text_tokens, Integer
143+
144+
# @!method initialize(audio_tokens: nil, text_tokens: nil)
145+
# Details about the input tokens billed for this request.
146+
#
147+
# @param audio_tokens [Integer] Number of audio tokens billed for this request.
148+
#
149+
# @param text_tokens [Integer] Number of text tokens billed for this request.
150+
end
151+
end
73152
end
74153
end
75154
end

lib/openai/models/audio/transcription_verbose.rb

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,19 @@ class TranscriptionVerbose < OpenAI::Internal::Type::BaseModel
2828
# @return [Array<OpenAI::Models::Audio::TranscriptionSegment>, nil]
2929
optional :segments, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Audio::TranscriptionSegment] }
3030

31+
# @!attribute usage
32+
# Usage statistics for models billed by audio input duration.
33+
#
34+
# @return [OpenAI::Models::Audio::TranscriptionVerbose::Usage, nil]
35+
optional :usage, -> { OpenAI::Audio::TranscriptionVerbose::Usage }
36+
3137
# @!attribute words
3238
# Extracted words and their corresponding timestamps.
3339
#
3440
# @return [Array<OpenAI::Models::Audio::TranscriptionWord>, nil]
3541
optional :words, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Audio::TranscriptionWord] }
3642

37-
# @!method initialize(duration:, language:, text:, segments: nil, words: nil)
43+
# @!method initialize(duration:, language:, text:, segments: nil, usage: nil, words: nil)
3844
# Represents a verbose json transcription response returned by model, based on the
3945
# provided input.
4046
#
@@ -46,7 +52,31 @@ class TranscriptionVerbose < OpenAI::Internal::Type::BaseModel
4652
#
4753
# @param segments [Array<OpenAI::Models::Audio::TranscriptionSegment>] Segments of the transcribed text and their corresponding details.
4854
#
55+
# @param usage [OpenAI::Models::Audio::TranscriptionVerbose::Usage] Usage statistics for models billed by audio input duration.
56+
#
4957
# @param words [Array<OpenAI::Models::Audio::TranscriptionWord>] Extracted words and their corresponding timestamps.
58+
59+
# @see OpenAI::Models::Audio::TranscriptionVerbose#usage
60+
class Usage < OpenAI::Internal::Type::BaseModel
61+
# @!attribute duration
62+
# Duration of the input audio in seconds.
63+
#
64+
# @return [Float]
65+
required :duration, Float
66+
67+
# @!attribute type
68+
# The type of the usage object. Always `duration` for this variant.
69+
#
70+
# @return [Symbol, :duration]
71+
required :type, const: :duration
72+
73+
# @!method initialize(duration:, type: :duration)
74+
# Usage statistics for models billed by audio input duration.
75+
#
76+
# @param duration [Float] Duration of the input audio in seconds.
77+
#
78+
# @param type [Symbol, :duration] The type of the usage object. Always `duration` for this variant.
79+
end
5080
end
5181
end
5282
end

0 commit comments

Comments
 (0)