Create speech
POSThttps:/api.openai.com/v1/audio/speech
Generates audio from the input text.
Request body
modelstring
One of the available TTS models:
tts-1,tts-1-hdorgpt-4o-mini-tts.modelstringRequired
modelstringRequired
tts-1string
tts-1-hdstring
gpt-4o-mini-ttsstring
inputstringRequired
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-1ortts-1-hd.voicestring
The voice to use when generating the audio. Supported voices are
alloy,ash,ballad,coral,echo,fable,onyx,nova,sage,shimmer, andverse. Previews of the voices are available in the Text to speech guide.voicestringRequired
voicestringRequired
alloystring
ashstring
balladstring
coralstring
echostring
fablestring
onyxstring
novastring
sagestring
shimmerstring
versestring
response_formatstringDefaults: mp3
The format to audio in. Supported formats are
mp3,opus,aac,flac,wav, andpcm.mp3string
opusstring
aacstring
flacstring
wavstring
pcmstring
speednumberDefaults: 1
The speed of the generated audio. Select a value from
0.25to4.0.1.0is the default.
Response
The audio file content.
Example request
1 curl https://api.openai.com/v1/audio/speech \2 -H "Authorization: Bearer $OPENAI_API_KEY" \3 -H "Content-Type: application/json" \4 -d '{5 "model": "gpt-4o-mini-tts",6 "input": "The quick brown fox jumped over the lazy dog.",7 "voice": "alloy"8 }' \9 --output speech.mp3
Built with