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)
Connect WebRTCSession (client)
Session events
WebRTCSession uses the same signaling-style events as a WebSocket Session, exceptresponse_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).
| Event | Purpose | Typical msg.data |
|---|---|---|
session_started | Session is live | id — session identifier |
session_ended | Session closed | May be an empty object; treat as end-of-call |
response_text | Agent text for the current turn | text, turn_id |
input_audio_transcript | STT of user speech | transcript |
speech_started | User speech detected (VAD) | emulated — if true, VAD did not fire but a transcript arrived, so start-of-speech is synthetic |
speech_stopped | User speech segment ended (VAD) | Usually empty |
interruption | User cut off the agent while it was speaking | Usually empty |
tool_call | Agent invoked a client tool | toolCallId, toolName, arguments (array of parameter descriptors with optional value) |
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
| Topic | Link |
|---|---|
| Browser voice demo (Next.js) | Next.js |
| SDK overview | JavaScript SDK |

