Realtime transcription
Stream 16 kHz PCM16 mono audio as base64 JSON events over an authenticated WebSocket.
Event flow
- Send
session.configureimmediately after connecting, then wait forsession.configured. - Send
input_audio_buffer.appendevents while receiving optionaltranscript.partialresults. - Send
input_audio_buffer.commit. Receiveinput_audio_buffer.committed, thentranscript.completedfor that utterance.
VAD and automatic duration boundaries can also commit an utterance. An empty manual commit returns input_audio_buffer.commit_empty. The connection stays open for subsequent utterances.
The audio example contains one 20 ms PCM16 chunk. Append all chunks before committing an utterance. Transcript examples illustrate the event format.
Handshake
WSS
wss://api.narilabs.com/v1/realtime?intent=transcription
Authentication
AuthorizationBearer
Nari API key in the WebSocket handshake Authorization header.
Send
session.configure
Send once within 10 seconds of connecting. Wait for `session.configured` before sending audio. Open a new connection to change settings.
OR
input_audio_buffer.append
Send audio in a JSON text frame and receive results concurrently. Appends have no individual acknowledgement.
OR
input_audio_buffer.commit
Commit pending audio. The server returns `input_audio_buffer.committed`, followed by `transcript.completed`. With no pending audio, it returns `input_audio_buffer.commit_empty` instead.
Receive
session.configured
Configuration accepted; audio can now be sent. Returns applied settings and `session.limits`.
OR
transcript.partial
Replace the previous partial for this `item_id`; earlier words can change. A completed result can arrive without any partial.
OR
transcript.completed
Final result for this utterance. Replaces any partial text and leaves the connection open.
OR
transcript.words
Word-level alignment for an opted-in completed transcript. Match it by `item_id`; alignment is asynchronous, so other utterance events can arrive first.
OR
transcript.words.failed
Terminal alignment failure for an opted-in completed transcript. The matching `transcript.completed` remains valid.
OR
input_audio_buffer.committed
Acknowledges a manual, VAD, or duration boundary. Use `item_id` to match the subsequent `transcript.completed` result.
OR
input_audio_buffer.speech_started
Sent when server VAD detects the start of speech.
OR
input_audio_buffer.speech_stopped
Sent when server VAD detects enough silence to end speech.
OR
error
Reports an error before the connection closes. Use `error.code` to choose the next action. For `INSUFFICIENT_CREDITS`, stop sending audio and add credits before reconnecting. See [Errors and troubleshooting](/errors#websocket-failures).
OR
input_audio_buffer.commit_empty
No audio is pending, so this commit produces no new final result. Previously committed utterances may still have results pending.