Create speech
POSThttps:/api.openai.com/v1/audio/speech
Generates audio from the input text.
Request body
model
string
One of the available TTS models:
tts-1
,tts-1-hd
orgpt-4o-mini-tts
.model
string
Required
model
string
Required
tts-1
string
tts-1-hd
string
gpt-4o-mini-tts
string
input
string
Required
The text to generate audio for. The maximum length is 4096 characters.instructions
string
Control the voice of your generated audio with additional instructions. Does not work with
tts-1
ortts-1-hd
.voice
string
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.voice
string
Required
voice
string
Required
alloy
string
ash
string
ballad
string
coral
string
echo
string
fable
string
onyx
string
nova
string
sage
string
shimmer
string
verse
string
response_format
string
Defaults: mp3
The format to audio in. Supported formats are
mp3
,opus
,aac
,flac
,wav
, andpcm
.mp3
string
opus
string
aac
string
flac
string
wav
string
pcm
string
speed
number
Defaults: 1
The speed of the generated audio. Select a value from
0.25
to4.0
.1.0
is 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