Audio
Domain Types
Audio Model
-
type AudioModel string-
const AudioModelWhisper1 AudioModel = "whisper-1" -
const AudioModelGPT4oTranscribe AudioModel = "gpt-4o-transcribe" -
const AudioModelGPT4oMiniTranscribe AudioModel = "gpt-4o-mini-transcribe" -
const AudioModelGPT4oMiniTranscribe2025_12_15 AudioModel = "gpt-4o-mini-transcribe-2025-12-15" -
const AudioModelGPT4oTranscribeDiarize AudioModel = "gpt-4o-transcribe-diarize"
-
Audio Response Format
-
type AudioResponseFormat stringThe 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.-
const AudioResponseFormatJSON AudioResponseFormat = "json" -
const AudioResponseFormatText AudioResponseFormat = "text" -
const AudioResponseFormatSRT AudioResponseFormat = "srt" -
const AudioResponseFormatVerboseJSON AudioResponseFormat = "verbose_json" -
const AudioResponseFormatVTT AudioResponseFormat = "vtt" -
const AudioResponseFormatDiarizedJSON AudioResponseFormat = "diarized_json"
-
Transcriptions
Create transcription
client.Audio.Transcriptions.New(ctx, body) (*AudioTranscriptionNewResponseUnion, error)
post /audio/transcriptions
Create transcription
Parameters
-
body AudioTranscriptionNewParams-
File param.Field[Reader]The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
-
Model param.Field[AudioModel]ID 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 -
type AudioModel string-
const AudioModelWhisper1 AudioModel = "whisper-1" -
const AudioModelGPT4oTranscribe AudioModel = "gpt-4o-transcribe" -
const AudioModelGPT4oMiniTranscribe AudioModel = "gpt-4o-mini-transcribe" -
const AudioModelGPT4oMiniTranscribe2025_12_15 AudioModel = "gpt-4o-mini-transcribe-2025-12-15" -
const AudioModelGPT4oTranscribeDiarize AudioModel = "gpt-4o-transcribe-diarize"
-
-
-
ChunkingStrategy param.Field[any] -
Include param.Field[[]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.const TranscriptionIncludeLogprobs TranscriptionInclude = "logprobs"
-
KnownSpeakerNames param.Field[[]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. -
KnownSpeakerReferences param.Field[[]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 param.Field[string]The language of the input audio. Supplying the input language in ISO-639-1 (e.g.
en) format will improve accuracy and latency. -
Prompt param.Field[string]An 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. -
ResponseFormat param.Field[AudioResponseFormat]The 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. -
``
-
Temperature param.Field[float64]The 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.
-
TimestampGranularities param.Field[[]string]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.-
const AudioTranscriptionNewParamsTimestampGranularityWord AudioTranscriptionNewParamsTimestampGranularity = "word" -
const AudioTranscriptionNewParamsTimestampGranularitySegment AudioTranscriptionNewParamsTimestampGranularity = "segment"
-
-
Returns
-
type AudioTranscriptionNewResponseUnion interface{…}Represents a transcription response returned by model, based on the provided input.
-
type Transcription struct{…}Represents a transcription response returned by model, based on the provided input.
-
Text stringThe transcribed text.
-
Logprobs []TranscriptionLogprobThe 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 []float64The bytes of the token.
-
Logprob float64The log probability of the token.
-
-
Usage TranscriptionUsageUnionToken usage statistics for the request.
-
type TranscriptionUsageTokens struct{…}Usage statistics for models billed by token usage.
-
InputTokens int64Number of input tokens billed for this request.
-
OutputTokens int64Number of output tokens generated.
-
TotalTokens int64Total number of tokens used (input + output).
-
Type TokensThe type of the usage object. Always
tokensfor this variant.const TokensTokens Tokens = "tokens"
-
InputTokenDetails TranscriptionUsageTokensInputTokenDetailsDetails about the input tokens billed for this request.
-
AudioTokens int64Number of audio tokens billed for this request.
-
TextTokens int64Number of text tokens billed for this request.
-
-
-
type TranscriptionUsageDuration struct{…}Usage statistics for models billed by audio input duration.
-
Seconds float64Duration of the input audio in seconds.
-
Type DurationThe type of the usage object. Always
durationfor this variant.const DurationDuration Duration = "duration"
-
-
-
-
type TranscriptionVerbose struct{…}Represents a verbose json transcription response returned by model, based on the provided input.
-
Duration float64The duration of the input audio.
-
Language stringThe language of the input audio.
-
Text stringThe transcribed text.
-
Segments []TranscriptionSegmentSegments of the transcribed text and their corresponding details.
-
ID int64Unique identifier of the segment.
-
AvgLogprob float64Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.
-
CompressionRatio float64Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
-
End float64End time of the segment in seconds.
-
NoSpeechProb float64Probability 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 int64Seek offset of the segment.
-
Start float64Start time of the segment in seconds.
-
Temperature float64Temperature parameter used for generating the segment.
-
Text stringText content of the segment.
-
Tokens []int64Array of token IDs for the text content.
-
-
Usage TranscriptionVerboseUsageUsage statistics for models billed by audio input duration.
-
Seconds float64Duration of the input audio in seconds.
-
Type DurationThe type of the usage object. Always
durationfor this variant.const DurationDuration Duration = "duration"
-
-
Words []TranscriptionWordExtracted words and their corresponding timestamps.
-
End float64End time of the word in seconds.
-
Start float64Start time of the word in seconds.
-
Word stringThe text content of the word.
-
-
-
Example
package main
import (
"bytes"
"context"
"fmt"
"io"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("My API Key"),
)
transcription, err := client.Audio.Transcriptions.New(context.TODO(), openai.AudioTranscriptionNewParams{
File: io.Reader(bytes.NewBuffer([]byte("Example data"))),
Model: openai.AudioModelGPT4oTranscribe,
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", 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
-
type Transcription struct{…}Represents a transcription response returned by model, based on the provided input.
-
Text stringThe transcribed text.
-
Logprobs []TranscriptionLogprobThe 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 []float64The bytes of the token.
-
Logprob float64The log probability of the token.
-
-
Usage TranscriptionUsageUnionToken usage statistics for the request.
-
type TranscriptionUsageTokens struct{…}Usage statistics for models billed by token usage.
-
InputTokens int64Number of input tokens billed for this request.
-
OutputTokens int64Number of output tokens generated.
-
TotalTokens int64Total number of tokens used (input + output).
-
Type TokensThe type of the usage object. Always
tokensfor this variant.const TokensTokens Tokens = "tokens"
-
InputTokenDetails TranscriptionUsageTokensInputTokenDetailsDetails about the input tokens billed for this request.
-
AudioTokens int64Number of audio tokens billed for this request.
-
TextTokens int64Number of text tokens billed for this request.
-
-
-
type TranscriptionUsageDuration struct{…}Usage statistics for models billed by audio input duration.
-
Seconds float64Duration of the input audio in seconds.
-
Type DurationThe type of the usage object. Always
durationfor this variant.const DurationDuration Duration = "duration"
-
-
-
Transcription Diarized
-
type TranscriptionDiarized struct{…}Represents a diarized transcription response returned by the model, including the combined transcript and speaker-segment annotations.
-
Duration float64Duration of the input audio in seconds.
-
Segments []TranscriptionDiarizedSegmentSegments of the transcript annotated with timestamps and speaker labels.
-
ID stringUnique identifier for the segment.
-
End float64End 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 float64Start timestamp of the segment in seconds.
-
Text stringTranscript text for this segment.
-
Type TranscriptTextSegmentThe type of the segment. Always
transcript.text.segment.const TranscriptTextSegmentTranscriptTextSegment TranscriptTextSegment = "transcript.text.segment"
-
-
Task TranscribeThe type of task that was run. Always
transcribe.const TranscribeTranscribe Transcribe = "transcribe"
-
Text stringThe concatenated transcript text for the entire audio input.
-
Usage TranscriptionDiarizedUsageUnionToken or duration usage statistics for the request.
-
TranscriptionDiarizedUsageTokens-
InputTokens int64Number of input tokens billed for this request.
-
OutputTokens int64Number of output tokens generated.
-
TotalTokens int64Total number of tokens used (input + output).
-
Type TokensThe type of the usage object. Always
tokensfor this variant.const TokensTokens Tokens = "tokens"
-
InputTokenDetails TranscriptionDiarizedUsageTokensInputTokenDetailsDetails about the input tokens billed for this request.
-
AudioTokens int64Number of audio tokens billed for this request.
-
TextTokens int64Number of text tokens billed for this request.
-
-
-
TranscriptionDiarizedUsageDuration-
Seconds float64Duration of the input audio in seconds.
-
Type DurationThe type of the usage object. Always
durationfor this variant.const DurationDuration Duration = "duration"
-
-
-
Transcription Diarized Segment
-
type TranscriptionDiarizedSegment struct{…}A segment of diarized transcript text with speaker metadata.
-
ID stringUnique identifier for the segment.
-
End float64End 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 float64Start timestamp of the segment in seconds.
-
Text stringTranscript text for this segment.
-
Type TranscriptTextSegmentThe type of the segment. Always
transcript.text.segment.const TranscriptTextSegmentTranscriptTextSegment TranscriptTextSegment = "transcript.text.segment"
-
Transcription Include
-
type TranscriptionInclude stringconst TranscriptionIncludeLogprobs TranscriptionInclude = "logprobs"
Transcription Segment
-
type TranscriptionSegment struct{…}-
ID int64Unique identifier of the segment.
-
AvgLogprob float64Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.
-
CompressionRatio float64Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
-
End float64End time of the segment in seconds.
-
NoSpeechProb float64Probability 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 int64Seek offset of the segment.
-
Start float64Start time of the segment in seconds.
-
Temperature float64Temperature parameter used for generating the segment.
-
Text stringText content of the segment.
-
Tokens []int64Array of token IDs for the text content.
-
Transcription Stream Event
-
type TranscriptionStreamEventUnion interface{…}Emitted when a diarized transcription returns a completed segment with speaker information. Only emitted when you create a transcription with
streamset totrueandresponse_formatset todiarized_json.-
type TranscriptionTextSegmentEvent struct{…}Emitted 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 float64End timestamp of the segment in seconds.
-
Speaker stringSpeaker label for this segment.
-
Start float64Start timestamp of the segment in seconds.
-
Text stringTranscript text for this segment.
-
Type TranscriptTextSegmentThe type of the event. Always
transcript.text.segment.const TranscriptTextSegmentTranscriptTextSegment TranscriptTextSegment = "transcript.text.segment"
-
-
type TranscriptionTextDeltaEvent struct{…}Emitted 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 TranscriptTextDeltaThe type of the event. Always
transcript.text.delta.const TranscriptTextDeltaTranscriptTextDelta TranscriptTextDelta = "transcript.text.delta"
-
Logprobs []TranscriptionTextDeltaEventLogprobThe 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 []int64The bytes that were used to generate the log probability.
-
Logprob float64The log probability of the token.
-
-
SegmentID stringIdentifier of the diarized segment that this delta belongs to. Only present when using
gpt-4o-transcribe-diarize.
-
-
type TranscriptionTextDoneEvent struct{…}Emitted 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 TranscriptTextDoneThe type of the event. Always
transcript.text.done.const TranscriptTextDoneTranscriptTextDone TranscriptTextDone = "transcript.text.done"
-
Logprobs []TranscriptionTextDoneEventLogprobThe 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 []int64The bytes that were used to generate the log probability.
-
Logprob float64The log probability of the token.
-
-
Usage TranscriptionTextDoneEventUsageUsage statistics for models billed by token usage.
-
InputTokens int64Number of input tokens billed for this request.
-
OutputTokens int64Number of output tokens generated.
-
TotalTokens int64Total number of tokens used (input + output).
-
Type TokensThe type of the usage object. Always
tokensfor this variant.const TokensTokens Tokens = "tokens"
-
InputTokenDetails TranscriptionTextDoneEventUsageInputTokenDetailsDetails about the input tokens billed for this request.
-
AudioTokens int64Number of audio tokens billed for this request.
-
TextTokens int64Number of text tokens billed for this request.
-
-
-
-
Transcription Text Delta Event
-
type TranscriptionTextDeltaEvent struct{…}Emitted 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 TranscriptTextDeltaThe type of the event. Always
transcript.text.delta.const TranscriptTextDeltaTranscriptTextDelta TranscriptTextDelta = "transcript.text.delta"
-
Logprobs []TranscriptionTextDeltaEventLogprobThe 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 []int64The bytes that were used to generate the log probability.
-
Logprob float64The log probability of the token.
-
-
SegmentID stringIdentifier of the diarized segment that this delta belongs to. Only present when using
gpt-4o-transcribe-diarize.
-
Transcription Text Done Event
-
type TranscriptionTextDoneEvent struct{…}Emitted 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 TranscriptTextDoneThe type of the event. Always
transcript.text.done.const TranscriptTextDoneTranscriptTextDone TranscriptTextDone = "transcript.text.done"
-
Logprobs []TranscriptionTextDoneEventLogprobThe 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 []int64The bytes that were used to generate the log probability.
-
Logprob float64The log probability of the token.
-
-
Usage TranscriptionTextDoneEventUsageUsage statistics for models billed by token usage.
-
InputTokens int64Number of input tokens billed for this request.
-
OutputTokens int64Number of output tokens generated.
-
TotalTokens int64Total number of tokens used (input + output).
-
Type TokensThe type of the usage object. Always
tokensfor this variant.const TokensTokens Tokens = "tokens"
-
InputTokenDetails TranscriptionTextDoneEventUsageInputTokenDetailsDetails about the input tokens billed for this request.
-
AudioTokens int64Number of audio tokens billed for this request.
-
TextTokens int64Number of text tokens billed for this request.
-
-
-
Transcription Text Segment Event
-
type TranscriptionTextSegmentEvent struct{…}Emitted 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 float64End timestamp of the segment in seconds.
-
Speaker stringSpeaker label for this segment.
-
Start float64Start timestamp of the segment in seconds.
-
Text stringTranscript text for this segment.
-
Type TranscriptTextSegmentThe type of the event. Always
transcript.text.segment.const TranscriptTextSegmentTranscriptTextSegment TranscriptTextSegment = "transcript.text.segment"
-
Transcription Verbose
-
type TranscriptionVerbose struct{…}Represents a verbose json transcription response returned by model, based on the provided input.
-
Duration float64The duration of the input audio.
-
Language stringThe language of the input audio.
-
Text stringThe transcribed text.
-
Segments []TranscriptionSegmentSegments of the transcribed text and their corresponding details.
-
ID int64Unique identifier of the segment.
-
AvgLogprob float64Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.
-
CompressionRatio float64Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
-
End float64End time of the segment in seconds.
-
NoSpeechProb float64Probability 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 int64Seek offset of the segment.
-
Start float64Start time of the segment in seconds.
-
Temperature float64Temperature parameter used for generating the segment.
-
Text stringText content of the segment.
-
Tokens []int64Array of token IDs for the text content.
-
-
Usage TranscriptionVerboseUsageUsage statistics for models billed by audio input duration.
-
Seconds float64Duration of the input audio in seconds.
-
Type DurationThe type of the usage object. Always
durationfor this variant.const DurationDuration Duration = "duration"
-
-
Words []TranscriptionWordExtracted words and their corresponding timestamps.
-
End float64End time of the word in seconds.
-
Start float64Start time of the word in seconds.
-
Word stringThe text content of the word.
-
-
Transcription Word
-
type TranscriptionWord struct{…}-
End float64End time of the word in seconds.
-
Start float64Start time of the word in seconds.
-
Word stringThe text content of the word.
-
Translations
Create translation
client.Audio.Translations.New(ctx, body) (*Translation, error)
post /audio/translations
Create translation
Parameters
-
body AudioTranslationNewParams-
File param.Field[Reader]The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
-
Model param.Field[AudioModel]ID of the model to use. Only
whisper-1(which is powered by our open source Whisper V2 model) is currently available.-
string -
type AudioModel string-
const AudioModelWhisper1 AudioModel = "whisper-1" -
const AudioModelGPT4oTranscribe AudioModel = "gpt-4o-transcribe" -
const AudioModelGPT4oMiniTranscribe AudioModel = "gpt-4o-mini-transcribe" -
const AudioModelGPT4oMiniTranscribe2025_12_15 AudioModel = "gpt-4o-mini-transcribe-2025-12-15" -
const AudioModelGPT4oTranscribeDiarize AudioModel = "gpt-4o-transcribe-diarize"
-
-
-
Prompt param.Field[string]An optional text to guide the model's style or continue a previous audio segment. The prompt should be in English.
-
ResponseFormat param.Field[AudioTranslationNewParamsResponseFormat]The format of the output, in one of these options:
json,text,srt,verbose_json, orvtt.-
const AudioTranslationNewParamsResponseFormatJSON AudioTranslationNewParamsResponseFormat = "json" -
const AudioTranslationNewParamsResponseFormatText AudioTranslationNewParamsResponseFormat = "text" -
const AudioTranslationNewParamsResponseFormatSRT AudioTranslationNewParamsResponseFormat = "srt" -
const AudioTranslationNewParamsResponseFormatVerboseJSON AudioTranslationNewParamsResponseFormat = "verbose_json" -
const AudioTranslationNewParamsResponseFormatVTT AudioTranslationNewParamsResponseFormat = "vtt"
-
-
Temperature param.Field[float64]The 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
-
type AudioTranslationNewResponse interface{…}-
type Translation struct{…}Text string
-
Example
package main
import (
"bytes"
"context"
"fmt"
"io"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("My API Key"),
)
translation, err := client.Audio.Translations.New(context.TODO(), openai.AudioTranslationNewParams{
File: io.Reader(bytes.NewBuffer([]byte("Example data"))),
Model: openai.AudioModelWhisper1,
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", translation)
}
Response
{
"text": "text"
}
Domain Types
Translation
-
type Translation struct{…}Text string
Translation Verbose
-
type TranslationVerbose struct{…}-
Duration float64The duration of the input audio.
-
Language stringThe language of the output translation (always
english). -
Text stringThe translated text.
-
Segments []TranscriptionSegmentSegments of the translated text and their corresponding details.
-
ID int64Unique identifier of the segment.
-
AvgLogprob float64Average logprob of the segment. If the value is lower than -1, consider the logprobs failed.
-
CompressionRatio float64Compression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
-
End float64End time of the segment in seconds.
-
NoSpeechProb float64Probability 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 int64Seek offset of the segment.
-
Start float64Start time of the segment in seconds.
-
Temperature float64Temperature parameter used for generating the segment.
-
Text stringText content of the segment.
-
Tokens []int64Array of token IDs for the text content.
-
-
Speech
Create speech
client.Audio.Speech.New(ctx, body) (*Response, error)
post /audio/speech
Create speech
Parameters
-
body AudioSpeechNewParams-
Input param.Field[string]The text to generate audio for. The maximum length is 4096 characters.
-
Model param.Field[SpeechModel]One of the available TTS models:
tts-1,tts-1-hd,gpt-4o-mini-tts, orgpt-4o-mini-tts-2025-12-15.-
string -
type SpeechModel string-
const SpeechModelTTS1 SpeechModel = "tts-1" -
const SpeechModelTTS1HD SpeechModel = "tts-1-hd" -
const SpeechModelGPT4oMiniTTS SpeechModel = "gpt-4o-mini-tts" -
const SpeechModelGPT4oMiniTTS2025_12_15 SpeechModel = "gpt-4o-mini-tts-2025-12-15"
-
-
-
Voice param.Field[AudioSpeechNewParamsVoiceUnion]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 -
type AudioSpeechNewParamsVoiceString2 string-
const AudioSpeechNewParamsVoiceString2Alloy AudioSpeechNewParamsVoiceString2 = "alloy" -
const AudioSpeechNewParamsVoiceString2Ash AudioSpeechNewParamsVoiceString2 = "ash" -
const AudioSpeechNewParamsVoiceString2Ballad AudioSpeechNewParamsVoiceString2 = "ballad" -
const AudioSpeechNewParamsVoiceString2Coral AudioSpeechNewParamsVoiceString2 = "coral" -
const AudioSpeechNewParamsVoiceString2Echo AudioSpeechNewParamsVoiceString2 = "echo" -
const AudioSpeechNewParamsVoiceString2Sage AudioSpeechNewParamsVoiceString2 = "sage" -
const AudioSpeechNewParamsVoiceString2Shimmer AudioSpeechNewParamsVoiceString2 = "shimmer" -
const AudioSpeechNewParamsVoiceString2Verse AudioSpeechNewParamsVoiceString2 = "verse" -
const AudioSpeechNewParamsVoiceString2Marin AudioSpeechNewParamsVoiceString2 = "marin" -
const AudioSpeechNewParamsVoiceString2Cedar AudioSpeechNewParamsVoiceString2 = "cedar"
-
-
type AudioSpeechNewParamsVoiceID struct{…}Custom voice reference.
-
ID stringThe custom voice ID, e.g.
voice_1234.
-
-
-
Instructions param.Field[string]Control the voice of your generated audio with additional instructions. Does not work with
tts-1ortts-1-hd. -
ResponseFormat param.Field[AudioSpeechNewParamsResponseFormat]The format to audio in. Supported formats are
mp3,opus,aac,flac,wav, andpcm.-
const AudioSpeechNewParamsResponseFormatMP3 AudioSpeechNewParamsResponseFormat = "mp3" -
const AudioSpeechNewParamsResponseFormatOpus AudioSpeechNewParamsResponseFormat = "opus" -
const AudioSpeechNewParamsResponseFormatAAC AudioSpeechNewParamsResponseFormat = "aac" -
const AudioSpeechNewParamsResponseFormatFLAC AudioSpeechNewParamsResponseFormat = "flac" -
const AudioSpeechNewParamsResponseFormatWAV AudioSpeechNewParamsResponseFormat = "wav" -
const AudioSpeechNewParamsResponseFormatPCM AudioSpeechNewParamsResponseFormat = "pcm"
-
-
Speed param.Field[float64]The speed of the generated audio. Select a value from
0.25to4.0.1.0is the default. -
StreamFormat param.Field[AudioSpeechNewParamsStreamFormat]The format to stream the audio in. Supported formats are
sseandaudio.sseis not supported fortts-1ortts-1-hd.-
const AudioSpeechNewParamsStreamFormatSSE AudioSpeechNewParamsStreamFormat = "sse" -
const AudioSpeechNewParamsStreamFormatAudio AudioSpeechNewParamsStreamFormat = "audio"
-
-
Returns
type AudioSpeechNewResponse interface{…}
Example
package main
import (
"context"
"fmt"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("My API Key"),
)
speech, err := client.Audio.Speech.New(context.TODO(), openai.AudioSpeechNewParams{
Input: "input",
Model: openai.SpeechModelTTS1,
Voice: openai.AudioSpeechNewParamsVoiceUnion{
OfAudioSpeechNewsVoiceString2: openai.String("alloy"),
},
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", speech)
}
Domain Types
Speech Model
-
type SpeechModel string-
const SpeechModelTTS1 SpeechModel = "tts-1" -
const SpeechModelTTS1HD SpeechModel = "tts-1-hd" -
const SpeechModelGPT4oMiniTTS SpeechModel = "gpt-4o-mini-tts" -
const SpeechModelGPT4oMiniTTS2025_12_15 SpeechModel = "gpt-4o-mini-tts-2025-12-15"
-