Streaming text to speech
HTTP API
Streaming TTS
Start playback before generation finishes. SSE-style data records.
POST
Streaming text to speech
Building with an AI agent? Point it at
docs.kova.ai/for-agents.md — the complete API contract as one plain-text page.POST /v1/tts/stream returns a text/plain body of SSE-style records — one JSON object per data: line, separated by blank lines. The request body is identical to Text to speech.
Use streaming whenever you want playback to begin before generation completes, and for any text over roughly 1,000 characters — the synchronous endpoint would otherwise make you wait tens of seconds for the first byte.
The default response encoding is mp3, not raw PCM. Each
audio_chunk is base64-encoded audio in your chosen response_format; concatenate the decoded chunks to reconstruct the file.Response headers
Event stream format
The body is a sequence of records. Each one starts withdata: (note the trailing space), contains one JSON object, and ends with \n\n:
Event types
audio
timestamps
Emitted only when the request settimestamps: true.
words[i] spans start_seconds[i] to end_seconds[i].
A real stream for a fourteen-word sentence looks like this:
start_seconds are always absolute offsets from the beginning of the utterance, so no rebasing is needed as you append.
Audio and timestamps events interleave with no fixed ratio or ordering guarantee. Handle them in whatever order they arrive.
Reconstructing the audio
Base64-decode eachaudio_chunk and concatenate in arrival order.
Latency
Time to first audio chunk is under 200 ms on an already-open connection, plus your network round-trip. The floor is stable at roughly 185 ms measured from a client ~40 ms away, and does not vary with text length or voice.Examples
Parsing the stream without an SDK
The framing is simple enough to handle directly. Buffer bytes, split on\n\n, strip the data: prefix:
\n\n rather than parsing each iter_bytes chunk directly.
See also
- WebSocket API — for multi-utterance, interactive use cases.
- Text to speech — same request body, single audio response.
- For AI agents — the whole contract on one page.