WebRTC & LiveKit
For custom voice experiences beyond the widget, connect directly to the thinnestAI voice engine using WebRTC via LiveKit. Build your own call UI, integrate into existing apps, or create unique voice-first experiences.Overview
thinnestAI uses LiveKit as its real-time infrastructure. LiveKit handles WebRTC connection management, audio routing, and scaling — you just connect and stream audio.Getting a Session Token
Before connecting, request a session token from the thinnestAI API:Connecting with LiveKit SDK
JavaScript / Browser
React
Python
Mobile (React Native)
Session Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
agent_id | string | Yes | Voice agent public ID |
metadata | object | No | User/session context data for the agent |
stt_provider | string | No | Override STT engine |
tts_provider | string | No | Override TTS engine |
voice_id | string | No | Override bot voice ID |
first_message | string | No | Override first greeting message |
Events
Monitor session state via LiveKit room events:| Event | Description |
|---|---|
connected | WebRTC connection established |
disconnected | Session ended |
track_subscribed | Agent audio track available |
track_unsubscribed | Agent audio track removed |
data_received | Metadata from the voice engine (transcripts, etc.) |
Receiving Transcripts
The voice engine sends real-time transcripts via LiveKit data channels:Architecture
vs Voice Widget
| Feature | WebRTC/LiveKit | Voice Widget |
|---|---|---|
| UI | Build your own | Pre-built floating button |
| Flexibility | Full control | Configuration-based |
| Setup time | Hours | Minutes |
| Mobile | Native SDKs available | Browser only |
| Best for | Custom apps, kiosks, IoT | Websites |
Troubleshooting
| Issue | Solution |
|---|---|
| Connection fails | Check firewall allows WebRTC (UDP ports 443, 10000-20000) |
| No audio from agent | Verify you’re subscribing to remote tracks |
| Echo | Enable echo cancellation in audio constraints |
| High latency | Use a server region close to your users |
| Token expired | Tokens are valid for 5 minutes — request a new one |

