Stream text to speech

View as Markdown
Stream text and receive base64-encoded 24 kHz PCM audio over an authenticated WebSocket. ## Message flow 1. Send `{"text":" "}` immediately after connecting. This initialization space is not billed. 2. Send text fragments while receiving `audio` chunks. Set `flush:true` to finish a segment without closing the connection. Audio may arrive before a flush. 3. Send `{"text":""}` to end input. Keep receiving until `{"isFinal":true}`, then the connection closes. Output streams automatically. Only automatic generation is supported. There is no public flush-completion event; `isFinal` completes the whole connection. See the [TTS input streaming guide](/streaming-text) for a runnable example.