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 The server replies with
start control frame (JSON text frame):{ "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