LiveKit Integration
Build real-time voice agents with LiveKit Agents powered by 60db’s speech and language services — STT, TTS, and LLM all in one plugin.Speech-to-Text
Real-time streaming transcription via WebSocket with interim results
Text-to-Speech
Low-latency streaming synthesis with chunked audio delivery
LLM Chat
OpenAI-compatible chat completions with tool-call support
Installation
Quick Start
Wire all three services together in aVoicePipelineAgent:
Configuration
Environment Variables
All services read from the same environment variables by default. You only need to override them if you use a custom deployment.| Variable | Default | Description |
|---|---|---|
SIXTY_DB_API_KEY | — | Your 60db API key (required) |
SIXTY_DB_STT_URL | wss://api.60db.ai/ws/stt | STT WebSocket endpoint |
SIXTY_DB_TTS_URL | wss://api.60db.ai/ws/tts | TTS WebSocket endpoint |
SIXTY_DB_LLM_URL | https://api.60db.ai/v1/chat/completions | LLM HTTP endpoint |
ws_url (or api_url) constructor argument which takes precedence over environment variables.
Services
- STT
- TTS
- LLM
Speech-to-Text
The STT service streams audio to 60db over WebSocket and returns transcriptions in real time — including interim (partial) results as the speaker is still talking.Parameters
| Name | Type | Default | Description |
|---|---|---|---|
api_key | str | None | global client / env var | Your 60db API key |
ws_url | str | None | env var | WebSocket endpoint URL |
languages | list[str] | None | ["en"] | Language codes for recognition |
encoding | str | "mulaw" | Audio encoding format |
sample_rate | int | 8000 | Audio sample rate in Hz |
continuous_mode | bool | True | Keep the session open for continuous recognition |
Example
Audio Formats
The plugin automatically handles audio conversion for you — no manual preprocessing needed.| Step | What happens |
|---|---|
| Stereo → Mono | Downmix via audioop.tomono |
| Resampling | Any input rate → target rate via audioop.ratecv |
| Encoding | LINEAR16 PCM → mulaw via audioop.lin2ulaw (when encoding="mulaw") |
| Parameter | Default | Supported |
|---|---|---|
| Encoding | mulaw | mulaw, LINEAR16 |
| Sample rate | 8000 Hz | Any rate (auto-resampled) |
Timeouts
Control timeouts per-request by passingAPIConnectOptions:
Error Handling
All three services raise standard LiveKit Agents exceptions:| Exception | When it’s raised |
|---|---|
APIConnectionError | WebSocket handshake failure, HTTP error, or unexpected protocol message |
APITimeoutError | Request exceeds the configured timeout |
ValueError | Missing API key or service URL at construction time |
Common HTTP Error Codes (LLM)
| Status | Meaning |
|---|---|
401 | Invalid or missing API key |
429 | Rate limit exceeded |
500 | Server error |
503 | Service unavailable |
Retry Tips
- STT: If you receive an
errormessage during the handshake, reconnect with a short delay. Aconnectingstatus beforeconnection_establishedis normal. - TTS: Retry connection failures with exponential backoff.
- LLM:
httpx.TimeoutException→APITimeoutError;httpx.HTTPStatusError→APIConnectionError.
WebSocket Protocol Reference
STT WebSocket Protocol
STT WebSocket Protocol
Connect:Handshake:Server → Server → Stop:Client →
{"connection_established": true}Client → start command:{"type": "connected"}Audio: Send raw audio as binary WebSocket frames.Transcription response:{"type": "stop"}Server →TTS WebSocket Protocol
TTS WebSocket Protocol
Connect:Create context:Send text:Flush (trigger audio generation):Audio response:Followed by
{"flush_completed": true} when all audio has been delivered.Close context: