Audio
Domain Types
Audio Model
-
enum AudioModel:-
WHISPER_1("whisper-1") -
GPT_4O_TRANSCRIBE("gpt-4o-transcribe") -
GPT_4O_MINI_TRANSCRIBE("gpt-4o-mini-transcribe") -
GPT_4O_MINI_TRANSCRIBE_2025_12_15("gpt-4o-mini-transcribe-2025-12-15") -
GPT_4O_TRANSCRIBE_DIARIZE("gpt-4o-transcribe-diarize")
-
Audio Response Format
-
enum 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.-
JSON("json") -
TEXT("text") -
SRT("srt") -
VERBOSE_JSON("verbose_json") -
VTT("vtt") -
DIARIZED_JSON("diarized_json")
-
Transcriptions
Create transcription
TranscriptionCreateResponse audio().transcriptions().create(TranscriptionCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
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
-
TranscriptionCreateParams params-
String fileThe audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
-
AudioModel modelID 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. -
Optional<ChunkingStrategy> chunkingStrategyControls 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.-
JsonValue;AUTO("auto")
-
class VadConfig:-
Type typeMust be set to
server_vadto enable manual chunking using server side VAD.SERVER_VAD("server_vad")
-
Optional<Long> prefixPaddingMsAmount of audio to include before the VAD detected speech (in milliseconds).
-
Optional<Long> silenceDurationMsDuration 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.
-
Optional<Double> thresholdSensitivity 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.
-
-
-
Optional<List<TranscriptionInclude>> includeAdditional 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("logprobs")
-
Optional<List<String>> knownSpeakerNamesOptional 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. -
Optional<List<String>> knownSpeakerReferencesOptional 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. -
Optional<String> languageThe language of the input audio. Supplying the input language in ISO-639-1 (e.g.
en) format will improve accuracy and latency. -
Optional<String> promptAn 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. -
Optional<AudioResponseFormat> responseFormatThe 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. -
Optional<Double> temperatureThe 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.
-
Optional<List<TimestampGranularity>> timestampGranularitiesThe 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("word") -
SEGMENT("segment")
-
-
Returns
-
class TranscriptionCreateResponse: A class that can be one of several variants.unionRepresents a transcription response returned by model, based on the provided input.
-
class Transcription:Represents a transcription response returned by model, based on the provided input.
-
String textThe transcribed text.
-
Optional<List<Logprob>> logprobsThe log probabilities of the tokens in the transcription. Only returned with the models
gpt-4o-transcribeandgpt-4o-mini-transcribeiflogprobsis added to theincludearray.-
Optional<String> tokenThe token in the transcription.
-
Optional<List<Double>> bytesThe bytes of the token.
-
Optional<Double> logprobThe log probability of the token.
-
-
Optional<Usage> usageToken usage statistics for the request.
-
class Tokens:Usage statistics for models billed by token usage.
-
long inputTokensNumber of input tokens billed for this request.
-
long outputTokensNumber of output tokens generated.
-
long totalTokensTotal number of tokens used (input + output).
-
JsonValue; type "tokens"constantThe type of the usage object. Always
tokensfor this variant.TOKENS("tokens")
-
Optional<InputTokenDetails> inputTokenDetailsDetails about the input tokens billed for this request.
-
Optional<Long> audioTokensNumber of audio tokens billed for this request.
-
Optional<Long> textTokensNumber of text tokens billed for this request.
-
-
-
class Duration:Usage statistics for models billed by audio input duration.
-
double secondsDuration of the input audio in seconds.
-
JsonValue; type "duration"constantThe type of the usage object. Always
durationfor this variant.DURATION("duration")
-
-
-
-
class TranscriptionDiarized:Represents a diarized transcription response returned by the model, including the combined transcript and speaker-segment annotations.
-
double durationDuration of the input audio in seconds.
-
List<TranscriptionDiarizedSegment> segmentsSegments of the transcript annotated with timestamps and speaker labels.
-
String idUnique identifier for the segment.
-
double endEnd timestamp of the segment in seconds.
-
String speakerSpeaker 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, ...). -
double startStart timestamp of the segment in seconds.
-
String textTranscript text for this segment.
-
JsonValue; type "transcript.text.segment"constantThe type of the segment. Always
transcript.text.segment.TRANSCRIPT_TEXT_SEGMENT("transcript.text.segment")
-
-
JsonValue; task "transcribe"constantThe type of task that was run. Always
transcribe.TRANSCRIBE("transcribe")
-
String textThe concatenated transcript text for the entire audio input.
-
Optional<Usage> usageToken or duration usage statistics for the request.
-
class Tokens:Usage statistics for models billed by token usage.
-
long inputTokensNumber of input tokens billed for this request.
-
long outputTokensNumber of output tokens generated.
-
long totalTokensTotal number of tokens used (input + output).
-
JsonValue; type "tokens"constantThe type of the usage object. Always
tokensfor this variant.TOKENS("tokens")
-
Optional<InputTokenDetails> inputTokenDetailsDetails about the input tokens billed for this request.
-
Optional<Long> audioTokensNumber of audio tokens billed for this request.
-
Optional<Long> textTokensNumber of text tokens billed for this request.
-
-
-
class Duration:Usage statistics for models billed by audio input duration.
-
double secondsDuration of the input audio in seconds.
-
JsonValue; type "duration"constantThe type of the usage object. Always
durationfor this variant.DURATION("duration")
-
-
-
-
class TranscriptionVerbose:Represents a verbose json transcription response returned by model, based on the provided input.
-
double durationThe duration of the input audio.
-
String languageThe language of the input audio.
-
String textThe transcribed text.
-
Optional<List<TranscriptionSegment>> segmentsSegments of the transcribed text and their corresponding details.
-
long idUnique identifier of the segment.
-
double avgLogprobAverage logprob of the segment. If the value is lower than -1, consider the logprobs failed.
-
double compressionRatioCompression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
-
double endEnd time of the segment in seconds.
-
double noSpeechProbProbability of no speech in the segment. If the value is higher than 1.0 and the
avg_logprobis below -1, consider this segment silent. -
long seekSeek offset of the segment.
-
double startStart time of the segment in seconds.
-
double temperatureTemperature parameter used for generating the segment.
-
String textText content of the segment.
-
List<long> tokensArray of token IDs for the text content.
-
-
Optional<Usage> usageUsage statistics for models billed by audio input duration.
-
double secondsDuration of the input audio in seconds.
-
JsonValue; type "duration"constantThe type of the usage object. Always
durationfor this variant.DURATION("duration")
-
-
Optional<List<TranscriptionWord>> wordsExtracted words and their corresponding timestamps.
-
double endEnd time of the word in seconds.
-
double startStart time of the word in seconds.
-
String wordThe text content of the word.
-
-
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.audio.AudioModel;
import com.openai.models.audio.transcriptions.TranscriptionCreateParams;
import com.openai.models.audio.transcriptions.TranscriptionCreateResponse;
import java.io.ByteArrayInputStream;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
TranscriptionCreateParams params = TranscriptionCreateParams.builder()
.file(new ByteArrayInputStream("Example data".getBytes()))
.model(AudioModel.GPT_4O_TRANSCRIBE)
.build();
TranscriptionCreateResponse transcription = client.audio().transcriptions().create(params);
}
}
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 Transcription:Represents a transcription response returned by model, based on the provided input.
-
String textThe transcribed text.
-
Optional<List<Logprob>> logprobsThe log probabilities of the tokens in the transcription. Only returned with the models
gpt-4o-transcribeandgpt-4o-mini-transcribeiflogprobsis added to theincludearray.-
Optional<String> tokenThe token in the transcription.
-
Optional<List<Double>> bytesThe bytes of the token.
-
Optional<Double> logprobThe log probability of the token.
-
-
Optional<Usage> usageToken usage statistics for the request.
-
class Tokens:Usage statistics for models billed by token usage.
-
long inputTokensNumber of input tokens billed for this request.
-
long outputTokensNumber of output tokens generated.
-
long totalTokensTotal number of tokens used (input + output).
-
JsonValue; type "tokens"constantThe type of the usage object. Always
tokensfor this variant.TOKENS("tokens")
-
Optional<InputTokenDetails> inputTokenDetailsDetails about the input tokens billed for this request.
-
Optional<Long> audioTokensNumber of audio tokens billed for this request.
-
Optional<Long> textTokensNumber of text tokens billed for this request.
-
-
-
class Duration:Usage statistics for models billed by audio input duration.
-
double secondsDuration of the input audio in seconds.
-
JsonValue; type "duration"constantThe type of the usage object. Always
durationfor this variant.DURATION("duration")
-
-
-
Transcription Diarized
-
class TranscriptionDiarized:Represents a diarized transcription response returned by the model, including the combined transcript and speaker-segment annotations.
-
double durationDuration of the input audio in seconds.
-
List<TranscriptionDiarizedSegment> segmentsSegments of the transcript annotated with timestamps and speaker labels.
-
String idUnique identifier for the segment.
-
double endEnd timestamp of the segment in seconds.
-
String speakerSpeaker 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, ...). -
double startStart timestamp of the segment in seconds.
-
String textTranscript text for this segment.
-
JsonValue; type "transcript.text.segment"constantThe type of the segment. Always
transcript.text.segment.TRANSCRIPT_TEXT_SEGMENT("transcript.text.segment")
-
-
JsonValue; task "transcribe"constantThe type of task that was run. Always
transcribe.TRANSCRIBE("transcribe")
-
String textThe concatenated transcript text for the entire audio input.
-
Optional<Usage> usageToken or duration usage statistics for the request.
-
class Tokens:Usage statistics for models billed by token usage.
-
long inputTokensNumber of input tokens billed for this request.
-
long outputTokensNumber of output tokens generated.
-
long totalTokensTotal number of tokens used (input + output).
-
JsonValue; type "tokens"constantThe type of the usage object. Always
tokensfor this variant.TOKENS("tokens")
-
Optional<InputTokenDetails> inputTokenDetailsDetails about the input tokens billed for this request.
-
Optional<Long> audioTokensNumber of audio tokens billed for this request.
-
Optional<Long> textTokensNumber of text tokens billed for this request.
-
-
-
class Duration:Usage statistics for models billed by audio input duration.
-
double secondsDuration of the input audio in seconds.
-
JsonValue; type "duration"constantThe type of the usage object. Always
durationfor this variant.DURATION("duration")
-
-
-
Transcription Diarized Segment
-
class TranscriptionDiarizedSegment:A segment of diarized transcript text with speaker metadata.
-
String idUnique identifier for the segment.
-
double endEnd timestamp of the segment in seconds.
-
String speakerSpeaker 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, ...). -
double startStart timestamp of the segment in seconds.
-
String textTranscript text for this segment.
-
JsonValue; type "transcript.text.segment"constantThe type of the segment. Always
transcript.text.segment.TRANSCRIPT_TEXT_SEGMENT("transcript.text.segment")
-
Transcription Include
-
enum TranscriptionInclude:LOGPROBS("logprobs")
Transcription Segment
-
class TranscriptionSegment:-
long idUnique identifier of the segment.
-
double avgLogprobAverage logprob of the segment. If the value is lower than -1, consider the logprobs failed.
-
double compressionRatioCompression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
-
double endEnd time of the segment in seconds.
-
double noSpeechProbProbability of no speech in the segment. If the value is higher than 1.0 and the
avg_logprobis below -1, consider this segment silent. -
long seekSeek offset of the segment.
-
double startStart time of the segment in seconds.
-
double temperatureTemperature parameter used for generating the segment.
-
String textText content of the segment.
-
List<long> tokensArray of token IDs for the text content.
-
Transcription Stream Event
-
class TranscriptionStreamEvent: A class that can be one of several variants.unionEmitted 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 TranscriptionTextSegmentEvent: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.-
String idUnique identifier for the segment.
-
double endEnd timestamp of the segment in seconds.
-
String speakerSpeaker label for this segment.
-
double startStart timestamp of the segment in seconds.
-
String textTranscript text for this segment.
-
JsonValue; type "transcript.text.segment"constantThe type of the event. Always
transcript.text.segment.TRANSCRIPT_TEXT_SEGMENT("transcript.text.segment")
-
-
class TranscriptionTextDeltaEvent: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.-
String deltaThe text delta that was additionally transcribed.
-
JsonValue; type "transcript.text.delta"constantThe type of the event. Always
transcript.text.delta.TRANSCRIPT_TEXT_DELTA("transcript.text.delta")
-
Optional<List<Logprob>> logprobsThe log probabilities of the delta. Only included if you create a transcription with the
include[]parameter set tologprobs.-
Optional<String> tokenThe token that was used to generate the log probability.
-
Optional<List<Long>> bytesThe bytes that were used to generate the log probability.
-
Optional<Double> logprobThe log probability of the token.
-
-
Optional<String> segmentIdIdentifier of the diarized segment that this delta belongs to. Only present when using
gpt-4o-transcribe-diarize.
-
-
class TranscriptionTextDoneEvent:Emitted when the transcription is complete. Contains the complete transcription text. Only emitted when you create a transcription with the
Streamparameter set totrue.-
String textThe text that was transcribed.
-
JsonValue; type "transcript.text.done"constantThe type of the event. Always
transcript.text.done.TRANSCRIPT_TEXT_DONE("transcript.text.done")
-
Optional<List<Logprob>> logprobsThe log probabilities of the individual tokens in the transcription. Only included if you create a transcription with the
include[]parameter set tologprobs.-
Optional<String> tokenThe token that was used to generate the log probability.
-
Optional<List<Long>> bytesThe bytes that were used to generate the log probability.
-
Optional<Double> logprobThe log probability of the token.
-
-
Optional<Usage> usageUsage statistics for models billed by token usage.
-
long inputTokensNumber of input tokens billed for this request.
-
long outputTokensNumber of output tokens generated.
-
long totalTokensTotal number of tokens used (input + output).
-
JsonValue; type "tokens"constantThe type of the usage object. Always
tokensfor this variant.TOKENS("tokens")
-
Optional<InputTokenDetails> inputTokenDetailsDetails about the input tokens billed for this request.
-
Optional<Long> audioTokensNumber of audio tokens billed for this request.
-
Optional<Long> textTokensNumber of text tokens billed for this request.
-
-
-
-
Transcription Text Delta Event
-
class TranscriptionTextDeltaEvent: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.-
String deltaThe text delta that was additionally transcribed.
-
JsonValue; type "transcript.text.delta"constantThe type of the event. Always
transcript.text.delta.TRANSCRIPT_TEXT_DELTA("transcript.text.delta")
-
Optional<List<Logprob>> logprobsThe log probabilities of the delta. Only included if you create a transcription with the
include[]parameter set tologprobs.-
Optional<String> tokenThe token that was used to generate the log probability.
-
Optional<List<Long>> bytesThe bytes that were used to generate the log probability.
-
Optional<Double> logprobThe log probability of the token.
-
-
Optional<String> segmentIdIdentifier of the diarized segment that this delta belongs to. Only present when using
gpt-4o-transcribe-diarize.
-
Transcription Text Done Event
-
class TranscriptionTextDoneEvent:Emitted when the transcription is complete. Contains the complete transcription text. Only emitted when you create a transcription with the
Streamparameter set totrue.-
String textThe text that was transcribed.
-
JsonValue; type "transcript.text.done"constantThe type of the event. Always
transcript.text.done.TRANSCRIPT_TEXT_DONE("transcript.text.done")
-
Optional<List<Logprob>> logprobsThe log probabilities of the individual tokens in the transcription. Only included if you create a transcription with the
include[]parameter set tologprobs.-
Optional<String> tokenThe token that was used to generate the log probability.
-
Optional<List<Long>> bytesThe bytes that were used to generate the log probability.
-
Optional<Double> logprobThe log probability of the token.
-
-
Optional<Usage> usageUsage statistics for models billed by token usage.
-
long inputTokensNumber of input tokens billed for this request.
-
long outputTokensNumber of output tokens generated.
-
long totalTokensTotal number of tokens used (input + output).
-
JsonValue; type "tokens"constantThe type of the usage object. Always
tokensfor this variant.TOKENS("tokens")
-
Optional<InputTokenDetails> inputTokenDetailsDetails about the input tokens billed for this request.
-
Optional<Long> audioTokensNumber of audio tokens billed for this request.
-
Optional<Long> textTokensNumber of text tokens billed for this request.
-
-
-
Transcription Text Segment Event
-
class TranscriptionTextSegmentEvent: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.-
String idUnique identifier for the segment.
-
double endEnd timestamp of the segment in seconds.
-
String speakerSpeaker label for this segment.
-
double startStart timestamp of the segment in seconds.
-
String textTranscript text for this segment.
-
JsonValue; type "transcript.text.segment"constantThe type of the event. Always
transcript.text.segment.TRANSCRIPT_TEXT_SEGMENT("transcript.text.segment")
-
Transcription Verbose
-
class TranscriptionVerbose:Represents a verbose json transcription response returned by model, based on the provided input.
-
double durationThe duration of the input audio.
-
String languageThe language of the input audio.
-
String textThe transcribed text.
-
Optional<List<TranscriptionSegment>> segmentsSegments of the transcribed text and their corresponding details.
-
long idUnique identifier of the segment.
-
double avgLogprobAverage logprob of the segment. If the value is lower than -1, consider the logprobs failed.
-
double compressionRatioCompression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
-
double endEnd time of the segment in seconds.
-
double noSpeechProbProbability of no speech in the segment. If the value is higher than 1.0 and the
avg_logprobis below -1, consider this segment silent. -
long seekSeek offset of the segment.
-
double startStart time of the segment in seconds.
-
double temperatureTemperature parameter used for generating the segment.
-
String textText content of the segment.
-
List<long> tokensArray of token IDs for the text content.
-
-
Optional<Usage> usageUsage statistics for models billed by audio input duration.
-
double secondsDuration of the input audio in seconds.
-
JsonValue; type "duration"constantThe type of the usage object. Always
durationfor this variant.DURATION("duration")
-
-
Optional<List<TranscriptionWord>> wordsExtracted words and their corresponding timestamps.
-
double endEnd time of the word in seconds.
-
double startStart time of the word in seconds.
-
String wordThe text content of the word.
-
-
Transcription Word
-
class TranscriptionWord:-
double endEnd time of the word in seconds.
-
double startStart time of the word in seconds.
-
String wordThe text content of the word.
-
Translations
Create translation
TranslationCreateResponse audio().translations().create(TranslationCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
post /audio/translations
Translates audio into English.
Parameters
-
TranslationCreateParams params-
String fileThe audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
-
AudioModel modelID of the model to use. Only
whisper-1(which is powered by our open source Whisper V2 model) is currently available. -
Optional<String> promptAn optional text to guide the model's style or continue a previous audio segment. The prompt should be in English.
-
Optional<ResponseFormat> responseFormatThe format of the output, in one of these options:
json,text,srt,verbose_json, orvtt.-
JSON("json") -
TEXT("text") -
SRT("srt") -
VERBOSE_JSON("verbose_json") -
VTT("vtt")
-
-
Optional<Double> temperatureThe 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
-
class TranslationCreateResponse: A class that can be one of several variants.union-
class Translation:String text
-
class TranslationVerbose:-
double durationThe duration of the input audio.
-
String languageThe language of the output translation (always
english). -
String textThe translated text.
-
Optional<List<TranscriptionSegment>> segmentsSegments of the translated text and their corresponding details.
-
long idUnique identifier of the segment.
-
double avgLogprobAverage logprob of the segment. If the value is lower than -1, consider the logprobs failed.
-
double compressionRatioCompression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
-
double endEnd time of the segment in seconds.
-
double noSpeechProbProbability of no speech in the segment. If the value is higher than 1.0 and the
avg_logprobis below -1, consider this segment silent. -
long seekSeek offset of the segment.
-
double startStart time of the segment in seconds.
-
double temperatureTemperature parameter used for generating the segment.
-
String textText content of the segment.
-
List<long> tokensArray of token IDs for the text content.
-
-
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.audio.AudioModel;
import com.openai.models.audio.translations.TranslationCreateParams;
import com.openai.models.audio.translations.TranslationCreateResponse;
import java.io.ByteArrayInputStream;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
TranslationCreateParams params = TranslationCreateParams.builder()
.file(new ByteArrayInputStream("Example data".getBytes()))
.model(AudioModel.WHISPER_1)
.build();
TranslationCreateResponse translation = client.audio().translations().create(params);
}
}
Response
{
"text": "text"
}
Domain Types
Translation
-
class Translation:String text
Translation Verbose
-
class TranslationVerbose:-
double durationThe duration of the input audio.
-
String languageThe language of the output translation (always
english). -
String textThe translated text.
-
Optional<List<TranscriptionSegment>> segmentsSegments of the translated text and their corresponding details.
-
long idUnique identifier of the segment.
-
double avgLogprobAverage logprob of the segment. If the value is lower than -1, consider the logprobs failed.
-
double compressionRatioCompression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
-
double endEnd time of the segment in seconds.
-
double noSpeechProbProbability of no speech in the segment. If the value is higher than 1.0 and the
avg_logprobis below -1, consider this segment silent. -
long seekSeek offset of the segment.
-
double startStart time of the segment in seconds.
-
double temperatureTemperature parameter used for generating the segment.
-
String textText content of the segment.
-
List<long> tokensArray of token IDs for the text content.
-
-
Speech
Create speech
HttpResponse audio().speech().create(SpeechCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
post /audio/speech
Generates audio from the input text.
Returns the audio file content, or a stream of audio events.
Parameters
-
SpeechCreateParams params-
String inputThe text to generate audio for. The maximum length is 4096 characters.
-
SpeechModel modelOne of the available TTS models:
tts-1,tts-1-hd,gpt-4o-mini-tts, orgpt-4o-mini-tts-2025-12-15. -
Voice voiceThe 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 -
enum UnionMember1:-
ALLOY("alloy") -
ASH("ash") -
BALLAD("ballad") -
CORAL("coral") -
ECHO("echo") -
SAGE("sage") -
SHIMMER("shimmer") -
VERSE("verse") -
MARIN("marin") -
CEDAR("cedar")
-
-
class Id:Custom voice reference.
-
String idThe custom voice ID, e.g.
voice_1234.
-
-
-
Optional<String> instructionsControl the voice of your generated audio with additional instructions. Does not work with
tts-1ortts-1-hd. -
Optional<ResponseFormat> responseFormatThe format to audio in. Supported formats are
mp3,opus,aac,flac,wav, andpcm.-
MP3("mp3") -
OPUS("opus") -
AAC("aac") -
FLAC("flac") -
WAV("wav") -
PCM("pcm")
-
-
Optional<Double> speedThe speed of the generated audio. Select a value from
0.25to4.0.1.0is the default. -
Optional<StreamFormat> streamFormatThe format to stream the audio in. Supported formats are
sseandaudio.sseis not supported fortts-1ortts-1-hd.-
SSE("sse") -
AUDIO("audio")
-
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.core.http.HttpResponse;
import com.openai.models.audio.speech.SpeechCreateParams;
import com.openai.models.audio.speech.SpeechModel;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
SpeechCreateParams params = SpeechCreateParams.builder()
.input("input")
.model(SpeechModel.TTS_1)
.voice(SpeechCreateParams.Voice.UnionMember1.ALLOY)
.build();
HttpResponse speech = client.audio().speech().create(params);
}
}
Domain Types
Speech Model
-
enum SpeechModel:-
TTS_1("tts-1") -
TTS_1_HD("tts-1-hd") -
GPT_4O_MINI_TTS("gpt-4o-mini-tts") -
GPT_4O_MINI_TTS_2025_12_15("gpt-4o-mini-tts-2025-12-15")
-