Decision guide
REST (sync)
You have short, complete text and want one finished WAV file. Simplest to integrate.
HTTP streaming
You have one complete utterance but want playback to start as early as possible.
WebSocket
Text arrives incrementally (e.g. from an LLM), or you need a long, low-latency, interactive session.
Multi-context WebSocket (beta)
A voice agent that must stop speech mid-sentence when the user interrupts, or run more than one reply at a time, on one connection.
Comparison
Rules of thumb
- Start with REST. If you’re generating short clips and don’t need sub-second first audio,
POST /v1/ttsis the least code. - Reach for HTTP streaming when you already have the full sentence but want the user to hear audio sooner, for example reading a chat reply aloud.
- Use the WebSocket when text is produced token-by-token (streaming from an LLM), when you’re driving a voice agent, or when your script exceeds a single request’s model limit. You send
input.textmessages as text becomes available, theninput.flushto generate audio before the buffer reaches the model limit. See WebSocket streaming.
Which WebSocket?
Both WebSockets stream incrementally with the same voices, latency, and billing. Choose by what your application needs to do with speech once it has started.- Start with
/v1/tts/wsif you only ever play one stream of speech and never need to stop it early. It is the simpler protocol. - Use
/v1/tts/ws-multifor voice agents. When the user interrupts, cancel the reply that is speaking and start the next one on the same connection, without reconnecting. See Multi-context WebSocket.
Concurrency limits apply to sync, HTTP streaming, and active WebSocket generations. HTTP returns
429 when the limit is reached; the WebSocket closes with 4429; the multi-context WebSocket ends only the affected context. If you need many simultaneous generations, see Rate limits & concurrency before choosing a transport.