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)
| type | Model | Key Fields |
|---|---|---|
| "partial" | StreamingPartial | text, language, segment_id, latency_ms |
| "final_segment" | StreamingFinalSegment | text, language, segment_id, silence_duration_ms |
| "final" | StreamingFinal | text, language, audio_duration_sec, inference_time_ms |
| "done" | StreamingDone | total_segments, total_audio_duration_sec |
| "error" | StreamingError | message, 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.