POST
/
v1
/
audio
/
speech
curl -X POST https://api.example.com/v1/audio/speech \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini-tts",
    "input": "The quick brown fox jumped over the lazy dog.",
    "voice": "alloy"
  }' \
  --output speech.mp3
Binary audio file content
Official documentation: https://platform.openai.com/docs/guides/text-to-speech
Generates audio from the input text.

Request Parameters

model
string
required
One of the available TTS models: tts-1, tts-1-hd, gpt-4o-mini-tts.
input
string
required
The text to generate audio for. The maximum length is 4096 characters.
voice
string
required
The voice to use when generating the audio. Supported voices are: alloy, echo, fable, onyx, nova, shimmer.
response_format
string
default:"mp3"
The format of the audio. Supported formats are: mp3, opus, aac, flac.
speed
number
default:"1"
The speed of the generated audio. Select a value from 0.25 to 4.0.

Response

Returns the audio file content in the specified format.
curl -X POST https://api.example.com/v1/audio/speech \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini-tts",
    "input": "The quick brown fox jumped over the lazy dog.",
    "voice": "alloy"
  }' \
  --output speech.mp3
Binary audio file content