Skip to main content
Use WebRTCSession in the browser for WebRTC voice. Mint the credential on the server with Client.generateSessionToken and TRANSPORT_WEBRTC, then pass webrtc_token (LiveKit media-room JWT), url, room, and identity to the client. The response also includes a platform token (session JWT) for other APIs; use webrtc_token for WebRTCSession.connect.

Session token

API reference for the session-token request and response fields.

JavaScript SDK

Package install and SDK entry points.

Connection (message types)

WebSocket Session message catalog. WebRTCSession uses the same event names for signaling except it does not emit response_audio (agent speech is only on the WebRTC audio path into remoteAudioContainer).

Prerequisites

  • @vatel/sdk
  • Organization API key on the server only, agent UUID, WebRTC enabled on your stack

generateSessionToken (WebRTC)

On the client, call WebRTCSession.connect with data.webrtc_token as token (the LiveKit media-room JWT), plus data.url and data.room - not data.token (the platform session JWT for WebSocket and other APIs). data.identity is part of the WebRTC payload. Check status and data for failures like any other SDK call.

Connect WebRTCSession (client)

credential is the response from the generateSessionToken result.

Session events

WebRTCSession uses the same signaling-style events as a WebSocket Session, except response_audio is not fired - agent audio is delivered only as a remote media stream (attach with remoteAudioContainer or your own playback). Subscribe with session.on(eventName, (msg) => { ... }). Each msg has type, timestamp, and data (fields depend on type). For base64 response_audio chunks, use a WebSocket Session instead of WebRTCSession. Reply to tools with session.sendToolCallOutput(toolCallId, outputString) (async in some builds; use .catch(...) if needed).

See also