Audio

Generates audio from the input text.

Returns the audio file content, or a stream of audio events.

The tts-1, tts-1-hd, gpt-4o-mini-tts, gpt-4o-mini-tts-2025-03-20, and gpt-4o-mini-tts-2025-12-15 models are deprecated and scheduled to shut down on January 6, 2027. These examples use the existing Speech API; for new integrations, migrate to gpt-realtime-2.1-mini through the Realtime API. See the deprecation schedule for migration details.

post/audio/speech

Request

  • Base URL
    https://api.openai.com/v1
  • URL
    https://api.openai.com/v1/audio/speech
  • Auth
    HTTP bearer

Request body

inputstring required

The text to generate audio for. The maximum length is 4096 characters.

instructionsstring

Control the voice of your generated audio with additional instructions. Does not work with tts-1 or tts-1-hd.

response_format'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm'

The format to audio in. Supported formats are mp3, opus, aac, flac, wav, and pcm.

speednumber

The speed of the generated audio. Select a value from 0.25 to 4.0. 1.0 is the default.

stream_format'sse' | 'audio'

The format to stream the audio in. Supported formats are sse and audio. sse is not supported for tts-1 or tts-1-hd.

Example request

{
  "voice": {
    "id": "voice_1234"
  }
}

Response

OK

Changes

    • info

      added the optional property // to the response with the status

    • info

      added the optional property // to the response with the status

    • info

      added the optional property // to the response with the status

    • info

      added the optional property // to the response with the status

    • info

      added the optional property // to the response with the status

    • breaking

      removed the enum value alloy of the request property

    • breaking

      removed the enum value echo of the request property

    • breaking

      removed the enum value fable of the request property

    • breaking

      removed the enum value nova of the request property

    • breaking

      removed the enum value onyx of the request property

    • breaking

      removed the enum value shimmer of the request property

    • breaking

      the request property type changed from string to no type

    • info

      added the new optional request property

    • info

      added the new optional request property

    • info

      added subschema #1 subschema #2 to the request property anyOf list

    • info

      added the new gpt-4o-mini-tts enum value to the request property /

    • info

      added the new gpt-4o-mini-tts-2025-12-15 enum value to the request property /

    • info

      added the media type audio/aac for the response with the status

    • info

      added the media type audio/flac for the response with the status

    • info

      added the media type audio/mpeg for the response with the status

    • info

      added the media type audio/opus for the response with the status

    • info

      added the media type audio/pcm for the response with the status

    • info

      added the media type audio/wav for the response with the status

    • info

      added the media type text/event-stream for the response with the status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status