Skip to main content
On long text, waiting for the whole clip before you hear anything is the slow path. Streaming hands you audio one sentence at a time: play sentence 1 while sentence 2 is still being synthesized, so time-to-first-audio drops from “the whole thing” to “the first sentence.” Each chunk is a complete, independently playable WAV (24 kHz, 16-bit PCM, mono) — the same format as tts.create(), just delivered piece by piece.

When to stream

Streaming doesn’t make total synthesis faster; it makes the first audio arrive sooner. For short inputs there’s no first-sentence advantage to win, so create() is simpler.

SDK — the async iterable

geko.tts.stream(params) takes the same params as create() and returns an async iterable of WAV ArrayBuffers, one per sentence chunk:
Play chunks as they land (queue them behind the one that’s currently playing) and the listener hears continuous speech that started ~1 sentence in rather than after the full render.
Streams are not retried. A partial stream can’t be replayed, so unlike tts.create() there’s no automatic retry on a mid-stream failure. Bound the whole stream with a per-call timeout, and cancel with an AbortSignal — see Errors & retries.

Cancelling a stream

Pass a signal to stop synthesis you no longer need (the user interrupted, navigated away, started a new request):
abort() propagates as-is; it is not retried or wrapped. A per-call timeout bounds the full stream end-to-end.

The raw HTTP protocol

Non-JS callers hit POST /v1/tts/stream directly. Same JSON body as POST /v1/tts, same auth and metering — only the response shape differs:
  • Content-Type: application/octet-stream
  • Header X-Tokay-Stream: wav-frames-v1
  • Body is a sequence of frames. Each frame is a 4-byte big-endian length, followed by that many bytes of one complete WAV.
Read a length, read that many bytes (that’s one playable WAV chunk), repeat until the stream closes.
The non-streaming POST /v1/tts still returns the whole audio/wav in one response, with the billed character count in the X-Tokay-Chars header. /v1/tts/stream bills identically — streaming changes delivery, not price.

Next steps

Voice agents

Pipe an LLM’s reply into streaming TTS for low-latency speech.

Playing & saving audio

Turn each WAV chunk into playback, files, or other formats.

Latency & quality

Drop nfe to 16 and dodge cold starts for faster audio.

Errors & retries

Why streams aren’t retried, and how to bound them.