API Reference

Streaming WebSocket Endpoint

Full reference for wss://asr.shunyalabs.ai/ws.


Handshake

Send StreamingConfig as JSON immediately after the WebSocket connection is established:

json
{
  "language": "hi",
  "sample_rate": 16000,
  "dtype": "int16",
  "chunk_size_sec": 1.0,
  "silence_threshold_sec": 0.5
}

Inbound (Client → Server)

After handshake, send raw PCM binary frames. Signal end of stream:

json
{ "type": "end" }

Outbound message schema (Server → Client)

typeModelKey Fields
"partial"StreamingPartialtext, language, segment_id, latency_ms
"final_segment"StreamingFinalSegmenttext, language, segment_id, silence_duration_ms
"final"StreamingFinaltext, language, audio_duration_sec, inference_time_ms
"done"StreamingDonetotal_segments, total_audio_duration_sec
"error"StreamingErrormessage, code

Disconnect behavior

  • The server closes the WebSocket after sending the "done" event.
  • On authentication failure, the server sends an "error" event and closes immediately.