What it does
Stream live speech with Lanson Live API. Open a WebSocket, send PCM16LE audio frames, and receive completed transcript events. No model parameter is required; language and optional features are configured through session.update.
Billing: WebSocket usage is metered by processed audio and billed at the realtime transcription rate. See API pricing.
Endpoint
WSS /v1/audio/transcriptions/streamAuthentication
Three authentication methods:
| Method | Usage | Use case |
|---|---|---|
| Bearer header | Authorization: Bearer sk-... | Server-side clients |
| Query token | ?access_token=rt_... | Browser (session token) |
| Query token (alias) | ?token=rt_... | Browser (session token) |
Session tokens are obtained via POST /v1/audio/transcriptions/session-token and are valid for 60 seconds. See Authentication.
language is optional. Send a concrete code (e.g. en, zh) when you know it for better accuracy; otherwise omit it or send language: "auto" to auto-detect. You can also call POST /v1/audio/language-detection first and pass the result. An explicit code always wins; sending "auto" mid-session resets detection and re-detects on later speech.
Connection
Upgrade conditions
- Request must be a WebSocket upgrade, otherwise
426 websocket_required - Gateway must be enabled, otherwise
503 gateway_disabled - Connection quota must pass (concurrent connections + handshake rate)
On success
Receives a session.created event:
{
"type": "session.created",
"request_id": "...",
"session_id": "sess_...",
"audio": { "format": "pcm_s16le", "sample_rate": 16000, "channels": 1 },
"turn_detection": { "type": "server_vad" },
"plan": "pro",
"features": { "asr_correction": false },
"limits": {
"max_concurrent_utterances": 8,
"max_session_seconds": 28800,
"idle_timeout_seconds": 180,
"remaining_audio_seconds": 720000
}
}Limits depend on the plan; see Rate Limits.
Message format
All client audio is sent as JSON text frames. Binary PCM frames are not transcribed by the public gateway today.
- Text frames: JSON objects, must contain a
typefield - Audio: base64 PCM16LE in
input_audio_buffer.append(binary frames are not transcribed today)
WebSocket close codes
| Code | Close reason | Meaning |
|---|---|---|
| 1000 | — | Normal close |
| 1008 | session_audio_limit | Realtime session audio budget exceeded |
| 1008 | audio_quota_exhausted | Billing-window audio budget exhausted |
| 1008 | session_duration_limit | Session wall-clock duration exceeded |
| 1009 | frame_too_large | Audio frame exceeds 1 MiB |
| 1011 | client_error | Client socket error or unexpected gateway error |
| 4408 | idle_timeout | No audio received within idle timeout window |
Related
- Client Messages — all client-sent messages
- Server Events — all server-pushed events
- Realtime Quickstart — complete example
- Authentication — auth details