POST/audio/speech

Create speech from text

Generates audio from text using a selected text-to-speech model and voice. Provide model, input, and voice, then choose an output format or streaming mode as needed. The response contains audio data or streamed audio events.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

7 body fields

Text-to-speech request configuration. model, input, and voice are required.

modelstringrequired
One of the available [TTS models](https://developers.openai.com/api/docs/guides/text-to-speech): `tts-1`, `tts-1-hd`, `gpt-4o-mini-tts`, or `gpt-4o-mini-tts-2025-12-15`.
inputstringrequired
The text to generate audio for. The maximum length is 4096 characters.
instructionsstringoptional
Control the voice of your generated audio with additional instructions. Does not work with `tts-1` or `tts-1-hd`.
voicestringrequired
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`, and `cedar`. You may also provide a custom voice object with an `id`, for example `{ "id": "voice_1234" }`. Previews of the voices are available in the [Text to speech guide](https://developers.openai.com/api/docs/guides/text-to-speech#voice-options). Custom voices must be created from audio samples.
response_formatstringoptional
The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`.
Allowed:mp3opusaacflacwavpcmDefault:mp3
speednumberoptional
The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is the default.
Default:1
stream_formatstringoptional
The format to stream the audio in. Supported formats are `sse` and `audio`. `sse` is not supported for `tts-1` or `tts-1-hd`.
Allowed:sseaudioDefault:audio

7 status codes
200Returns audio file content in the selected audio format, or a stream of audio events when streaming is requested.
400Returned when the speech request, input, output format, or voice is invalid.
errorobjectrequired
401Returned when the API key is missing or revoked, or the client IP is not authorized.
errorobjectrequired
403Returned when organization policy blocks access to a personal API organization.
429Returned when the request is rejected because a rate limit was exceeded.

One documented failure

  • slow_down

    Your request rate increased too quickly. Please reduce the request rate and gradually increase it again.

    Traffic increased too quickly

errorobjectrequired
500Returned when the voice or speech audio could not be processed.
errorobjectrequired
503Returned when the service is temporarily unavailable.

One documented failure

  • server_is_overloaded

    The model is temporarily overloaded. Please retry your request after a brief delay.

    The requested model is temporarily overloaded

errorobjectrequired

Error handling

A 400 is returned for an invalid speech request, input, output format, or voice; a 401 indicates a missing or revoked API key or an unauthorized client IP; and a 403 indicates organization policy blocks access. A 429 indicates a rate limit was exceeded, a 500 indicates the voice or audio could not be processed, and a 503 indicates temporary service unavailability. model, input, and voice are required; input and instructions must not exceed 4,096 characters, speed must be between 0.25 and 4, and response_format and stream_format must use supported values.