Create speech

post https://api.openai.com/v1/audio/speech

Generates audio from the input text.source

Request body

One of the available TTS models: tts-1 or tts-1-hdsource

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

The voice to use when generating the audio. Supported voices are alloy, echo, fable, onyx, nova, and shimmer. Previews of the voices are available in the Text to speech guide.source

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

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

Returns

The audio file content.source

Example request
1
2
3
4
5
6
7
8
9
curl https://api.openai.com/v1/audio/speech \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tts-1",
    "input": "The quick brown fox jumped over the lazy dog.",
    "voice": "alloy"
  }' \
  --output speech.mp3