SDK
Text to speech
Create speech
Audio formats
HTTP and SSE streaming
WebSocket streaming

Audio formats

FormatStreamedBufferedUse it for
pcmYesYesLow-level audio pipelines
mp3YesYesPlayback and compact storage
wavNoYesA complete file with a RIFF header

PCM output is signed 16-bit little-endian mono audio. MP3 uses the audio/mpeg content type. WAV must be requested with stream=False.

Python

speech = client.audio.speech.create(
    model="teen-v1",
    voice="default",
    input="Return a WAV file.",
    response_format="wav",
    stream=False,
)
speech.write_to_file("speech.wav")

Provider format names are translated only when they map to PCM, MP3, or WAV. Other codecs raise UnsupportedAudioFormatError.

On this page