Skip to main content
The streaming endpoint synthesizes audio one sentence at a time and sends each sentence as a binary WebSocket frame as soon as it is ready. Begin playback on the first frame for the lowest perceived latency — ideal for conversational agents.

Protocol

1

Connect

Open a WebSocket to /v1/audio/speech/stream with your key in the header: Authorization: Bearer sk_….
2

Start a session

Send a start control frame (JSON text frame):
The server replies with { "type": "ready" } once the session is open.
3

Send text

After ready, send one or more text frames, then a done frame:
4

Receive audio

The server sends binary frames — one complete audio buffer per sentence — followed by { "type": "session.done" } when synthesis is finished.

Frame reference

Client → server

Server → client

Send the start frame before anything else — text frames sent first are rejected with an error frame. Quota and rate limits apply per text frame, the same as HTTP requests.

Example

Python