Audio
Domain Types
Audio Model
-
AudioModel = :"whisper-1" | :"gpt-4o-transcribe" | :"gpt-4o-mini-transcribe" | 2 more-
:"whisper-1" -
:"gpt-4o-transcribe" -
:"gpt-4o-mini-transcribe" -
:"gpt-4o-mini-transcribe-2025-12-15" -
:"gpt-4o-transcribe-diarize"
-
Audio Response Format
-
AudioResponseFormat = :json | :text | :srt | 3 moreThe format of the output, in one of these options:
json,text,srt,verbose_json,vtt, ordiarized_json. Forgpt-4o-transcribeandgpt-4o-mini-transcribe, the only supported format isjson. Forgpt-4o-transcribe-diarize, the supported formats arejson,text, anddiarized_json, withdiarized_jsonrequired to receive speaker annotations.-
:json -
:text -
:srt -
:verbose_json -
:vtt -
:diarized_json
-
Transcriptions
Create transcription
audio.transcriptions.create(**kwargs) -> TranscriptionCreateResponse
post /audio/transcriptions
Transcribes audio into the input language.
Returns a transcription object in json, diarized_json, or verbose_json
format, or a stream of transcript events.
Parameters
-
file: StringThe audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
-
model: String | AudioModelID of the model to use. The options are
gpt-4o-transcribe,gpt-4o-mini-transcribe,gpt-4o-mini-transcribe-2025-12-15,whisper-1(which is powered by our open source Whisper V2 model), andgpt-4o-transcribe-diarize.-
String = String -
AudioModel = :"whisper-1" | :"gpt-4o-transcribe" | :"gpt-4o-mini-transcribe" | 2 more-
:"whisper-1" -
:"gpt-4o-transcribe" -
:"gpt-4o-mini-transcribe" -
:"gpt-4o-mini-transcribe-2025-12-15" -
:"gpt-4o-transcribe-diarize"
-
-
-
chunking_strategy: :auto | VadConfig{ type, prefix_padding_ms, silence_duration_ms, threshold}Controls how the audio is cut into chunks. When set to
"auto", the server first normalizes loudness and then uses voice activity detection (VAD) to choose boundaries.server_vadobject can be provided to tweak VAD detection parameters manually. If unset, the audio is transcribed as a single block. Required when usinggpt-4o-transcribe-diarizefor inputs longer than 30 seconds.-
ChunkingStrategy = :autoAutomatically set chunking parameters based on the audio. Must be set to
"auto".:auto
-
class VadConfig-
type: :server_vadMust be set to
server_vadto enable manual chunking using server side VAD.:server_vad
-
prefix_padding_ms: IntegerAmount of audio to include before the VAD detected speech (in milliseconds).
-
silence_duration_ms: IntegerDuration of silence to detect speech stop (in milliseconds). With shorter values the model will respond more quickly, but may jump in on short pauses from the user.
-
threshold: FloatSensitivity threshold (0.0 to 1.0) for voice activity detection. A higher threshold will require louder audio to activate the model, and thus might perform better in noisy environments.
-
-
-
include: Array[TranscriptionInclude]Additional information to include in the transcription response.
logprobswill return the log probabilities of the tokens in the response to understand the model's confidence in the transcription.logprobsonly works with response_format set tojsonand only with the modelsgpt-4o-transcribe,gpt-4o-mini-transcribe, andgpt-4o-mini-transcribe-2025-12-15. This field is not supported when usinggpt-4o-transcribe-diarize.:logprobs
-
known_speaker_names: Array[String]Optional list of speaker names that correspond to the audio samples provided in
known_speaker_references[]. Each entry should be a short identifier (for examplecustomeroragent). Up to 4 speakers are supported. -
known_speaker_references: Array[String]Optional list of audio samples (as data URLs) that contain known speaker references matching
known_speaker_names[]. Each sample must be between 2 and 10 seconds, and can use any of the same input audio formats supported byfile. -
language: StringThe language of the input audio. Supplying the input language in ISO-639-1 (e.g.
en) format will improve accuracy and latency. -
prompt: StringAn optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language. This field is not supported when using
gpt-4o-transcribe-diarize. -
response_format: AudioResponseFormatThe format of the output, in one of these options:
json,text,srt,verbose_json,vtt, ordiarized_json. Forgpt-4o-transcribeandgpt-4o-mini-transcribe, the only supported format isjson. Forgpt-4o-transcribe-diarize, the supported formats arejson,text, anddiarized_json, withdiarized_jsonrequired to receive speaker annotations.-
:json -
:text -
:srt -
:verbose_json -
:vtt -
:diarized_json
-
-
stream: boolIf set to true, the model response data will be streamed to the client as it is generated using server-sent events. See the Streaming section of the Speech-to-Text guide for more information.
Note: Streaming is not supported for the
whisper-1model and will be ignored. -
temperature: FloatThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.
-
timestamp_granularities: Array[:word | :segment]The timestamp granularities to populate for this transcription.
response_formatmust be setverbose_jsonto use timestamp granularities. Either or both of these options are supported:word, orsegment. Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency. This option is not available forgpt-4o-transcribe-diarize.-
:word -
:segment
-
Returns
-
TranscriptionCreateResponse = Transcription | TranscriptionDiarized | TranscriptionVerboseRepresents a transcription response returned by model, based on the provided input.
-
class TranscriptionRepresents a transcription response returned by model, based on the provided input.
-
text: StringThe transcribed text.
-
logprobs: Array[Logprob{ token, bytes, logprob}]The log probabilities of the tokens in the transcription. Only returned with the models
gpt-4o-transcribeandgpt-4o-mini-transcribeiflogprobsis added to theincludearray.-
token: StringThe token in the transcription.
-
bytes: Array[Float]The bytes of the token.
-
logprob: FloatThe log probability of the token.
-
-
usage: Tokens{ input_tokens, output_tokens, total_tokens, 2 more} | Duration{ seconds, type}Token usage statistics for the request.
-
class TokensUsage statistics for models billed by token usage.
-
input_tokens: IntegerNumber of input tokens billed for this request.
-
output_tokens: IntegerNumber of output tokens generated.
-
total_tokens: IntegerTotal number of tokens used (input + output).
-
type: :tokensThe type of the usage object. Always
tokensfor this variant.:tokens
-
input_token_details: InputTokenDetails{ audio_tokens, text_tokens}Details about the input tokens billed for this request.
-
audio_tokens: IntegerNumber of audio tokens billed for this request.
-
text_tokens: IntegerNumber of text tokens billed for this request.
-
-
-
class DurationUsage statistics for models billed by audio input duration.
-
seconds: FloatDuration of the input audio in seconds.
-
type: :durationThe type of the usage object. Always
durationfor this variant.:duration
-
-
-
-
class TranscriptionDiarizedRepresents a diarized transcription response returned by the model, including the combined transcript and speaker-segment annotations.
-
duration: FloatDuration of the input audio in seconds.
-
segments: Array[TranscriptionDiarizedSegment]Segments of the transcript annotated with timestamps and speaker labels.
-
id: StringUnique identifier for the segment.
-
end_: FloatEnd timestamp of the segment in seconds.
-
speaker: StringSpeaker label for this segment. When known speakers are provided, the label matches
known_speaker_names[]. Otherwise speakers are labeled sequentially using capital letters (A,B, ...). -
start: FloatStart timestamp of the segment in seconds.
-
text: StringTranscript text for this segment.
-
type: :"transcript.text.segment"The type of the segment. Always
transcript.text.segment.:"transcript.text.segment"
-
-
task: :transcribeThe type of task that was run. Always
transcribe.:transcribe
-
text: StringThe concatenated transcript text for the entire audio input.
-
usage: Tokens{ input_tokens, output_tokens, total_tokens, 2 more} | Duration{ seconds, type}Token or duration usage statistics for the request.
-
class TokensUsage statistics for models billed by token usage.
-
input_tokens: IntegerNumber of input tokens billed for this request.
-
output_tokens: IntegerNumber of output tokens generated.
-
total_tokens: IntegerTotal number of tokens used (input + output).
-
type: :tokensThe type of the usage object. Always
tokensfor this variant.:tokens
-
input_token_details: InputTokenDetails{ audio_tokens, text_tokens}Details about the input tokens billed for this request.
-
audio_tokens: IntegerNumber of audio tokens billed for this request.
-
text_tokens: IntegerNumber of text tokens billed for this request.
-
-
-
class DurationUsage statistics for models billed by audio input duration.
-
seconds: FloatDuration of the input audio in seconds.
-
type: :durationThe type of the usage object. Always
durationfor this variant.:duration
-
-
-
-
class TranscriptionVerboseRepresents a verbose json transcription response returned by model, based on the provided input.
-
duration: FloatThe duration of the input audio.
-
language: StringThe language of the input audio.
-
text: StringThe transcribed text.
-
segments: Array[TranscriptionSegment]Segments of the transcribed text and their corresponding details.
-
id: IntegerUnique identifier of the segment.
-
avg_logprob: FloatAverage logprob of the segment. If the value is lower than -1, consider the logprobs failed.
-
compression_ratio: FloatCompression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
-
end_: FloatEnd time of the segment in seconds.
-
no_speech_prob: FloatProbability of no speech in the segment. If the value is higher than 1.0 and the
avg_logprobis below -1, consider this segment silent. -
seek: IntegerSeek offset of the segment.
-
start: FloatStart time of the segment in seconds.
-
temperature: FloatTemperature parameter used for generating the segment.
-
text: StringText content of the segment.
-
tokens: Array[Integer]Array of token IDs for the text content.
-
-
usage: Usage{ seconds, type}Usage statistics for models billed by audio input duration.
-
seconds: FloatDuration of the input audio in seconds.
-
type: :durationThe type of the usage object. Always
durationfor this variant.:duration
-
-
words: Array[TranscriptionWord]Extracted words and their corresponding timestamps.
-
end_: FloatEnd time of the word in seconds.
-
start: FloatStart time of the word in seconds.
-
word: StringThe text content of the word.
-
-
-
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
transcription = openai.audio.transcriptions.create(file: StringIO.new("Example data"), model: :"gpt-4o-transcribe")
puts(transcription)
Response
{
"text": "text",
"logprobs": [
{
"token": "token",
"bytes": [
0
],
"logprob": 0
}
],
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"total_tokens": 0,
"type": "tokens",
"input_token_details": {
"audio_tokens": 0,
"text_tokens": 0
}
}
}
Domain Types
Transcription
-
class TranscriptionRepresents a transcription response returned by model, based on the provided input.
-
text: StringThe transcribed text.
-
logprobs: Array[Logprob{ token, bytes, logprob}]The log probabilities of the tokens in the transcription. Only returned with the models
gpt-4o-transcribeandgpt-4o-mini-transcribeiflogprobsis added to theincludearray.-
token: StringThe token in the transcription.
-
bytes: Array[Float]The bytes of the token.
-
logprob: FloatThe log probability of the token.
-
-
usage: Tokens{ input_tokens, output_tokens, total_tokens, 2 more} | Duration{ seconds, type}Token usage statistics for the request.
-
class TokensUsage statistics for models billed by token usage.
-
input_tokens: IntegerNumber of input tokens billed for this request.
-
output_tokens: IntegerNumber of output tokens generated.
-
total_tokens: IntegerTotal number of tokens used (input + output).
-
type: :tokensThe type of the usage object. Always
tokensfor this variant.:tokens
-
input_token_details: InputTokenDetails{ audio_tokens, text_tokens}Details about the input tokens billed for this request.
-
audio_tokens: IntegerNumber of audio tokens billed for this request.
-
text_tokens: IntegerNumber of text tokens billed for this request.
-
-
-
class DurationUsage statistics for models billed by audio input duration.
-
seconds: FloatDuration of the input audio in seconds.
-
type: :durationThe type of the usage object. Always
durationfor this variant.:duration
-
-
-
Transcription Diarized
-
class TranscriptionDiarizedRepresents a diarized transcription response returned by the model, including the combined transcript and speaker-segment annotations.
-
duration: FloatDuration of the input audio in seconds.
-
segments: Array[TranscriptionDiarizedSegment]Segments of the transcript annotated with timestamps and speaker labels.
-
id: StringUnique identifier for the segment.
-
end_: FloatEnd timestamp of the segment in seconds.
-
speaker: StringSpeaker label for this segment. When known speakers are provided, the label matches
known_speaker_names[]. Otherwise speakers are labeled sequentially using capital letters (A,B, ...). -
start: FloatStart timestamp of the segment in seconds.
-
text: StringTranscript text for this segment.
-
type: :"transcript.text.segment"The type of the segment. Always
transcript.text.segment.:"transcript.text.segment"
-
-
task: :transcribeThe type of task that was run. Always
transcribe.:transcribe
-
text: StringThe concatenated transcript text for the entire audio input.
-
usage: Tokens{ input_tokens, output_tokens, total_tokens, 2 more} | Duration{ seconds, type}Token or duration usage statistics for the request.
-
class TokensUsage statistics for models billed by token usage.
-
input_tokens: IntegerNumber of input tokens billed for this request.
-
output_tokens: IntegerNumber of output tokens generated.
-
total_tokens: IntegerTotal number of tokens used (input + output).
-
type: :tokensThe type of the usage object. Always
tokensfor this variant.:tokens
-
input_token_details: InputTokenDetails{ audio_tokens, text_tokens}Details about the input tokens billed for this request.
-
audio_tokens: IntegerNumber of audio tokens billed for this request.
-
text_tokens: IntegerNumber of text tokens billed for this request.
-
-
-
class DurationUsage statistics for models billed by audio input duration.
-
seconds: FloatDuration of the input audio in seconds.
-
type: :durationThe type of the usage object. Always
durationfor this variant.:duration
-
-
-
Transcription Diarized Segment
-
class TranscriptionDiarizedSegmentA segment of diarized transcript text with speaker metadata.
-
id: StringUnique identifier for the segment.
-
end_: FloatEnd timestamp of the segment in seconds.
-
speaker: StringSpeaker label for this segment. When known speakers are provided, the label matches
known_speaker_names[]. Otherwise speakers are labeled sequentially using capital letters (A,B, ...). -
start: FloatStart timestamp of the segment in seconds.
-
text: StringTranscript text for this segment.
-
type: :"transcript.text.segment"The type of the segment. Always
transcript.text.segment.:"transcript.text.segment"
-
Transcription Include
-
TranscriptionInclude = :logprobs:logprobs
Transcription Segment
-
class TranscriptionSegment-
id: IntegerUnique identifier of the segment.
-
avg_logprob: FloatAverage logprob of the segment. If the value is lower than -1, consider the logprobs failed.
-
compression_ratio: FloatCompression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
-
end_: FloatEnd time of the segment in seconds.
-
no_speech_prob: FloatProbability of no speech in the segment. If the value is higher than 1.0 and the
avg_logprobis below -1, consider this segment silent. -
seek: IntegerSeek offset of the segment.
-
start: FloatStart time of the segment in seconds.
-
temperature: FloatTemperature parameter used for generating the segment.
-
text: StringText content of the segment.
-
tokens: Array[Integer]Array of token IDs for the text content.
-
Transcription Stream Event
-
TranscriptionStreamEvent = TranscriptionTextSegmentEvent | TranscriptionTextDeltaEvent | TranscriptionTextDoneEventEmitted when a diarized transcription returns a completed segment with speaker information. Only emitted when you create a transcription with
streamset totrueandresponse_formatset todiarized_json.-
class TranscriptionTextSegmentEventEmitted when a diarized transcription returns a completed segment with speaker information. Only emitted when you create a transcription with
streamset totrueandresponse_formatset todiarized_json.-
id: StringUnique identifier for the segment.
-
end_: FloatEnd timestamp of the segment in seconds.
-
speaker: StringSpeaker label for this segment.
-
start: FloatStart timestamp of the segment in seconds.
-
text: StringTranscript text for this segment.
-
type: :"transcript.text.segment"The type of the event. Always
transcript.text.segment.:"transcript.text.segment"
-
-
class TranscriptionTextDeltaEventEmitted when there is an additional text delta. This is also the first event emitted when the transcription starts. Only emitted when you create a transcription with the
Streamparameter set totrue.-
delta: StringThe text delta that was additionally transcribed.
-
type: :"transcript.text.delta"The type of the event. Always
transcript.text.delta.:"transcript.text.delta"
-
logprobs: Array[Logprob{ token, bytes, logprob}]The log probabilities of the delta. Only included if you create a transcription with the
include[]parameter set tologprobs.-
token: StringThe token that was used to generate the log probability.
-
bytes: Array[Integer]The bytes that were used to generate the log probability.
-
logprob: FloatThe log probability of the token.
-
-
segment_id: StringIdentifier of the diarized segment that this delta belongs to. Only present when using
gpt-4o-transcribe-diarize.
-
-
class TranscriptionTextDoneEventEmitted when the transcription is complete. Contains the complete transcription text. Only emitted when you create a transcription with the
Streamparameter set totrue.-
text: StringThe text that was transcribed.
-
type: :"transcript.text.done"The type of the event. Always
transcript.text.done.:"transcript.text.done"
-
logprobs: Array[Logprob{ token, bytes, logprob}]The log probabilities of the individual tokens in the transcription. Only included if you create a transcription with the
include[]parameter set tologprobs.-
token: StringThe token that was used to generate the log probability.
-
bytes: Array[Integer]The bytes that were used to generate the log probability.
-
logprob: FloatThe log probability of the token.
-
-
usage: Usage{ input_tokens, output_tokens, total_tokens, 2 more}Usage statistics for models billed by token usage.
-
input_tokens: IntegerNumber of input tokens billed for this request.
-
output_tokens: IntegerNumber of output tokens generated.
-
total_tokens: IntegerTotal number of tokens used (input + output).
-
type: :tokensThe type of the usage object. Always
tokensfor this variant.:tokens
-
input_token_details: InputTokenDetails{ audio_tokens, text_tokens}Details about the input tokens billed for this request.
-
audio_tokens: IntegerNumber of audio tokens billed for this request.
-
text_tokens: IntegerNumber of text tokens billed for this request.
-
-
-
-
Transcription Text Delta Event
-
class TranscriptionTextDeltaEventEmitted when there is an additional text delta. This is also the first event emitted when the transcription starts. Only emitted when you create a transcription with the
Streamparameter set totrue.-
delta: StringThe text delta that was additionally transcribed.
-
type: :"transcript.text.delta"The type of the event. Always
transcript.text.delta.:"transcript.text.delta"
-
logprobs: Array[Logprob{ token, bytes, logprob}]The log probabilities of the delta. Only included if you create a transcription with the
include[]parameter set tologprobs.-
token: StringThe token that was used to generate the log probability.
-
bytes: Array[Integer]The bytes that were used to generate the log probability.
-
logprob: FloatThe log probability of the token.
-
-
segment_id: StringIdentifier of the diarized segment that this delta belongs to. Only present when using
gpt-4o-transcribe-diarize.
-
Transcription Text Done Event
-
class TranscriptionTextDoneEventEmitted when the transcription is complete. Contains the complete transcription text. Only emitted when you create a transcription with the
Streamparameter set totrue.-
text: StringThe text that was transcribed.
-
type: :"transcript.text.done"The type of the event. Always
transcript.text.done.:"transcript.text.done"
-
logprobs: Array[Logprob{ token, bytes, logprob}]The log probabilities of the individual tokens in the transcription. Only included if you create a transcription with the
include[]parameter set tologprobs.-
token: StringThe token that was used to generate the log probability.
-
bytes: Array[Integer]The bytes that were used to generate the log probability.
-
logprob: FloatThe log probability of the token.
-
-
usage: Usage{ input_tokens, output_tokens, total_tokens, 2 more}Usage statistics for models billed by token usage.
-
input_tokens: IntegerNumber of input tokens billed for this request.
-
output_tokens: IntegerNumber of output tokens generated.
-
total_tokens: IntegerTotal number of tokens used (input + output).
-
type: :tokensThe type of the usage object. Always
tokensfor this variant.:tokens
-
input_token_details: InputTokenDetails{ audio_tokens, text_tokens}Details about the input tokens billed for this request.
-
audio_tokens: IntegerNumber of audio tokens billed for this request.
-
text_tokens: IntegerNumber of text tokens billed for this request.
-
-
-
Transcription Text Segment Event
-
class TranscriptionTextSegmentEventEmitted when a diarized transcription returns a completed segment with speaker information. Only emitted when you create a transcription with
streamset totrueandresponse_formatset todiarized_json.-
id: StringUnique identifier for the segment.
-
end_: FloatEnd timestamp of the segment in seconds.
-
speaker: StringSpeaker label for this segment.
-
start: FloatStart timestamp of the segment in seconds.
-
text: StringTranscript text for this segment.
-
type: :"transcript.text.segment"The type of the event. Always
transcript.text.segment.:"transcript.text.segment"
-
Transcription Verbose
-
class TranscriptionVerboseRepresents a verbose json transcription response returned by model, based on the provided input.
-
duration: FloatThe duration of the input audio.
-
language: StringThe language of the input audio.
-
text: StringThe transcribed text.
-
segments: Array[TranscriptionSegment]Segments of the transcribed text and their corresponding details.
-
id: IntegerUnique identifier of the segment.
-
avg_logprob: FloatAverage logprob of the segment. If the value is lower than -1, consider the logprobs failed.
-
compression_ratio: FloatCompression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
-
end_: FloatEnd time of the segment in seconds.
-
no_speech_prob: FloatProbability of no speech in the segment. If the value is higher than 1.0 and the
avg_logprobis below -1, consider this segment silent. -
seek: IntegerSeek offset of the segment.
-
start: FloatStart time of the segment in seconds.
-
temperature: FloatTemperature parameter used for generating the segment.
-
text: StringText content of the segment.
-
tokens: Array[Integer]Array of token IDs for the text content.
-
-
usage: Usage{ seconds, type}Usage statistics for models billed by audio input duration.
-
seconds: FloatDuration of the input audio in seconds.
-
type: :durationThe type of the usage object. Always
durationfor this variant.:duration
-
-
words: Array[TranscriptionWord]Extracted words and their corresponding timestamps.
-
end_: FloatEnd time of the word in seconds.
-
start: FloatStart time of the word in seconds.
-
word: StringThe text content of the word.
-
-
Transcription Word
-
class TranscriptionWord-
end_: FloatEnd time of the word in seconds.
-
start: FloatStart time of the word in seconds.
-
word: StringThe text content of the word.
-
Transcription Create Response
-
TranscriptionCreateResponse = Transcription | TranscriptionDiarized | TranscriptionVerboseRepresents a transcription response returned by model, based on the provided input.
-
class TranscriptionRepresents a transcription response returned by model, based on the provided input.
-
text: StringThe transcribed text.
-
logprobs: Array[Logprob{ token, bytes, logprob}]The log probabilities of the tokens in the transcription. Only returned with the models
gpt-4o-transcribeandgpt-4o-mini-transcribeiflogprobsis added to theincludearray.-
token: StringThe token in the transcription.
-
bytes: Array[Float]The bytes of the token.
-
logprob: FloatThe log probability of the token.
-
-
usage: Tokens{ input_tokens, output_tokens, total_tokens, 2 more} | Duration{ seconds, type}Token usage statistics for the request.
-
class TokensUsage statistics for models billed by token usage.
-
input_tokens: IntegerNumber of input tokens billed for this request.
-
output_tokens: IntegerNumber of output tokens generated.
-
total_tokens: IntegerTotal number of tokens used (input + output).
-
type: :tokensThe type of the usage object. Always
tokensfor this variant.:tokens
-
input_token_details: InputTokenDetails{ audio_tokens, text_tokens}Details about the input tokens billed for this request.
-
audio_tokens: IntegerNumber of audio tokens billed for this request.
-
text_tokens: IntegerNumber of text tokens billed for this request.
-
-
-
class DurationUsage statistics for models billed by audio input duration.
-
seconds: FloatDuration of the input audio in seconds.
-
type: :durationThe type of the usage object. Always
durationfor this variant.:duration
-
-
-
-
class TranscriptionDiarizedRepresents a diarized transcription response returned by the model, including the combined transcript and speaker-segment annotations.
-
duration: FloatDuration of the input audio in seconds.
-
segments: Array[TranscriptionDiarizedSegment]Segments of the transcript annotated with timestamps and speaker labels.
-
id: StringUnique identifier for the segment.
-
end_: FloatEnd timestamp of the segment in seconds.
-
speaker: StringSpeaker label for this segment. When known speakers are provided, the label matches
known_speaker_names[]. Otherwise speakers are labeled sequentially using capital letters (A,B, ...). -
start: FloatStart timestamp of the segment in seconds.
-
text: StringTranscript text for this segment.
-
type: :"transcript.text.segment"The type of the segment. Always
transcript.text.segment.:"transcript.text.segment"
-
-
task: :transcribeThe type of task that was run. Always
transcribe.:transcribe
-
text: StringThe concatenated transcript text for the entire audio input.
-
usage: Tokens{ input_tokens, output_tokens, total_tokens, 2 more} | Duration{ seconds, type}Token or duration usage statistics for the request.
-
class TokensUsage statistics for models billed by token usage.
-
input_tokens: IntegerNumber of input tokens billed for this request.
-
output_tokens: IntegerNumber of output tokens generated.
-
total_tokens: IntegerTotal number of tokens used (input + output).
-
type: :tokensThe type of the usage object. Always
tokensfor this variant.:tokens
-
input_token_details: InputTokenDetails{ audio_tokens, text_tokens}Details about the input tokens billed for this request.
-
audio_tokens: IntegerNumber of audio tokens billed for this request.
-
text_tokens: IntegerNumber of text tokens billed for this request.
-
-
-
class DurationUsage statistics for models billed by audio input duration.
-
seconds: FloatDuration of the input audio in seconds.
-
type: :durationThe type of the usage object. Always
durationfor this variant.:duration
-
-
-
-
class TranscriptionVerboseRepresents a verbose json transcription response returned by model, based on the provided input.
-
duration: FloatThe duration of the input audio.
-
language: StringThe language of the input audio.
-
text: StringThe transcribed text.
-
segments: Array[TranscriptionSegment]Segments of the transcribed text and their corresponding details.
-
id: IntegerUnique identifier of the segment.
-
avg_logprob: FloatAverage logprob of the segment. If the value is lower than -1, consider the logprobs failed.
-
compression_ratio: FloatCompression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
-
end_: FloatEnd time of the segment in seconds.
-
no_speech_prob: FloatProbability of no speech in the segment. If the value is higher than 1.0 and the
avg_logprobis below -1, consider this segment silent. -
seek: IntegerSeek offset of the segment.
-
start: FloatStart time of the segment in seconds.
-
temperature: FloatTemperature parameter used for generating the segment.
-
text: StringText content of the segment.
-
tokens: Array[Integer]Array of token IDs for the text content.
-
-
usage: Usage{ seconds, type}Usage statistics for models billed by audio input duration.
-
seconds: FloatDuration of the input audio in seconds.
-
type: :durationThe type of the usage object. Always
durationfor this variant.:duration
-
-
words: Array[TranscriptionWord]Extracted words and their corresponding timestamps.
-
end_: FloatEnd time of the word in seconds.
-
start: FloatStart time of the word in seconds.
-
word: StringThe text content of the word.
-
-
-
Translations
Create translation
audio.translations.create(**kwargs) -> TranslationCreateResponse
post /audio/translations
Translates audio into English.
Parameters
-
file: StringThe audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
-
model: String | AudioModelID of the model to use. Only
whisper-1(which is powered by our open source Whisper V2 model) is currently available.-
String = String -
AudioModel = :"whisper-1" | :"gpt-4o-transcribe" | :"gpt-4o-mini-transcribe" | 2 more-
:"whisper-1" -
:"gpt-4o-transcribe" -
:"gpt-4o-mini-transcribe" -
:"gpt-4o-mini-transcribe-2025-12-15" -
:"gpt-4o-transcribe-diarize"
-
-
-
prompt: StringAn optional text to guide the model's style or continue a previous audio segment. The prompt should be in English.
-
response_format: :json | :text | :srt | 2 moreThe format of the output, in one of these options:
json,text,srt,verbose_json, orvtt.-
:json -
:text -
:srt -
:verbose_json -
:vtt
-
-
temperature: FloatThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.
Returns
-
TranslationCreateResponse = Translation | TranslationVerbose-
class Translationtext: String
-
class TranslationVerbose-
duration: FloatThe duration of the input audio.
-
language: StringThe language of the output translation (always
english). -
text: StringThe translated text.
-
segments: Array[TranscriptionSegment]Segments of the translated text and their corresponding details.
-
id: IntegerUnique identifier of the segment.
-
avg_logprob: FloatAverage logprob of the segment. If the value is lower than -1, consider the logprobs failed.
-
compression_ratio: FloatCompression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
-
end_: FloatEnd time of the segment in seconds.
-
no_speech_prob: FloatProbability of no speech in the segment. If the value is higher than 1.0 and the
avg_logprobis below -1, consider this segment silent. -
seek: IntegerSeek offset of the segment.
-
start: FloatStart time of the segment in seconds.
-
temperature: FloatTemperature parameter used for generating the segment.
-
text: StringText content of the segment.
-
tokens: Array[Integer]Array of token IDs for the text content.
-
-
-
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
translation = openai.audio.translations.create(file: StringIO.new("Example data"), model: :"whisper-1")
puts(translation)
Response
{
"text": "text"
}
Domain Types
Translation
-
class Translationtext: String
Translation Verbose
-
class TranslationVerbose-
duration: FloatThe duration of the input audio.
-
language: StringThe language of the output translation (always
english). -
text: StringThe translated text.
-
segments: Array[TranscriptionSegment]Segments of the translated text and their corresponding details.
-
id: IntegerUnique identifier of the segment.
-
avg_logprob: FloatAverage logprob of the segment. If the value is lower than -1, consider the logprobs failed.
-
compression_ratio: FloatCompression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
-
end_: FloatEnd time of the segment in seconds.
-
no_speech_prob: FloatProbability of no speech in the segment. If the value is higher than 1.0 and the
avg_logprobis below -1, consider this segment silent. -
seek: IntegerSeek offset of the segment.
-
start: FloatStart time of the segment in seconds.
-
temperature: FloatTemperature parameter used for generating the segment.
-
text: StringText content of the segment.
-
tokens: Array[Integer]Array of token IDs for the text content.
-
-
Translation Create Response
-
TranslationCreateResponse = Translation | TranslationVerbose-
class Translationtext: String
-
class TranslationVerbose-
duration: FloatThe duration of the input audio.
-
language: StringThe language of the output translation (always
english). -
text: StringThe translated text.
-
segments: Array[TranscriptionSegment]Segments of the translated text and their corresponding details.
-
id: IntegerUnique identifier of the segment.
-
avg_logprob: FloatAverage logprob of the segment. If the value is lower than -1, consider the logprobs failed.
-
compression_ratio: FloatCompression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
-
end_: FloatEnd time of the segment in seconds.
-
no_speech_prob: FloatProbability of no speech in the segment. If the value is higher than 1.0 and the
avg_logprobis below -1, consider this segment silent. -
seek: IntegerSeek offset of the segment.
-
start: FloatStart time of the segment in seconds.
-
temperature: FloatTemperature parameter used for generating the segment.
-
text: StringText content of the segment.
-
tokens: Array[Integer]Array of token IDs for the text content.
-
-
-
Speech
Create speech
audio.speech.create(**kwargs) -> StringIO
post /audio/speech
Generates audio from the input text.
Returns the audio file content, or a stream of audio events.
Parameters
-
input: StringThe text to generate audio for. The maximum length is 4096 characters.
-
model: String | SpeechModelOne of the available TTS models:
tts-1,tts-1-hd,gpt-4o-mini-tts, orgpt-4o-mini-tts-2025-12-15.-
String = String -
SpeechModel = :"tts-1" | :"tts-1-hd" | :"gpt-4o-mini-tts" | :"gpt-4o-mini-tts-2025-12-15"-
:"tts-1" -
:"tts-1-hd" -
:"gpt-4o-mini-tts" -
:"gpt-4o-mini-tts-2025-12-15"
-
-
-
voice: String | :alloy | :ash | :ballad | 7 more | ID{ id}The voice to use when generating the audio. Supported built-in voices are
alloy,ash,ballad,coral,echo,fable,onyx,nova,sage,shimmer,verse,marin, andcedar. You may also provide a custom voice object with anid, for example{ "id": "voice_1234" }. Previews of the voices are available in the Text to speech guide.-
String = String -
Voice = :alloy | :ash | :ballad | 7 more-
:alloy -
:ash -
:ballad -
:coral -
:echo -
:sage -
:shimmer -
:verse -
:marin -
:cedar
-
-
class IDCustom voice reference.
-
id: StringThe custom voice ID, e.g.
voice_1234.
-
-
-
instructions: StringControl the voice of your generated audio with additional instructions. Does not work with
tts-1ortts-1-hd. -
response_format: :mp3 | :opus | :aac | 3 moreThe format to audio in. Supported formats are
mp3,opus,aac,flac,wav, andpcm.-
:mp3 -
:opus -
:aac -
:flac -
:wav -
:pcm
-
-
speed: FloatThe speed of the generated audio. Select a value from
0.25to4.0.1.0is the default. -
stream_format: :sse | :audioThe format to stream the audio in. Supported formats are
sseandaudio.sseis not supported fortts-1ortts-1-hd.-
:sse -
:audio
-
Returns
StringIO
Example
require "openai"
openai = OpenAI::Client.new(api_key: "My API Key")
speech = openai.audio.speech.create(input: "input", model: :"tts-1", voice: :alloy)
puts(speech)
Domain Types
Speech Model
-
SpeechModel = :"tts-1" | :"tts-1-hd" | :"gpt-4o-mini-tts" | :"gpt-4o-mini-tts-2025-12-15"-
:"tts-1" -
:"tts-1-hd" -
:"gpt-4o-mini-tts" -
:"gpt-4o-mini-tts-2025-12-15"
-