Authenticating
- Subprotocol (recommended)
- First message (fallback)
Pass the key as a WebSocket subprotocol. It never appears in a URL, so it stays
out of proxy and server logs.
Sending audio
Wait forready, then send binary chunks:
- 16 kHz, 16-bit PCM, mono
- 20 ms per chunk — 640 bytes
Messages you receive
object
Authentication succeeded. Start sending audio.
object
A result.
transcript holds the text; isFinal says whether it is settled.Interim results arrive fast and may be revised — good for showing live
captions. Final results are stable — use those for anything you store or
act on.object
Something went wrong.
message explains what.A complete example
Keeping the stream healthy
- Send steadily. Bursting a buffer is worse than a paced 20 ms cadence.
- Reconnect on close. Networks drop; keep the transcript you already finalised and resume.
- Close cleanly when you stop, so the last partial result is flushed.