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:
Cancelling a stream
Pass asignal 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 hitPOST /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.
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.