Engines
Connecting
Query parameters (both endpoints)
Authentication, one of:
- Subprotocol list
["token", "<api key>"]on the upgrade. The socket is authenticated before it opens; a bad key is refused with HTTP 401. - An
authmessage within 30 seconds of connecting (below).
400 for an invalid languages value, 401 for
a bad key, 503 when the service is at capacity.
Client → server messages
Audio is sent as binary frames: 16 kHz, 16-bit signed little-endian PCM, mono, ideally 640 bytes (20 ms) per frame at a steady cadence. Control messages are JSON text frames:object
Authenticate when no subprotocol was used. Must be the first message.
languages and metadata are optional. metadata is passed through
unchanged to usage webhooks and cannot be set with subprotocol auth.object
Signal that no more audio is coming. The engine flushes its last result.
Keep the socket open until you receive it, then close.
Server → client messages
object
Authentication succeeded and the engine is configured. Send audio after this.
sessionId is the same id reported in usage webhooks. languages echoes the
configuration actually applied.object
A recognition result.
isFinal: false results are provisional and will be replaced. isFinal: true
results are settled. On /v2/stream an interim carries the cumulative text of
the current utterance so far; the matching final replaces it.object
error and message carry the same text. Codes you may see:Lifecycle
- Connect with the key in the subprotocol, or connect and send
auth. - Wait for
ready. - Send audio frames at a steady 20 ms cadence. Read
transcriptmessages. - Send
end. Wait for the lastisFinal: true. - Close the socket.
type: "stream", the billed duration, and any metadata you attached.