Try it first
Live demo
Paste your Agent ID and API key, start a session, and talk to your agent. No setup, nothing to install.
Create a session
Create sessions from your backend. Your API key must never reach a browser or mobile app, and the endpoint does not send CORS headers, so cross-origin browser calls are rejected by design.Request Body
The body is required. Send{} when you have no options to set.
string
Optional conversation UUID. Reuse a value to group multiple voice sessions into one conversation in chat logs; the agent continues with the earlier transcript as history. Omit to create a new conversation. A conversation belongs to the end-user who started it: when reusing, send that same
userId, or omit userId to inherit it — a different userId is rejected with CONVERSATION_USER_MISMATCH.string
Your end-user ID. Max 128 chars,
[a-zA-Z0-9._-] only. Send a stable ID so per-user voice limits apply; if omitted a random one is generated per session (or inherited from the conversation when reusing a conversationId). A userId alone never resumes an earlier conversation — each session without a conversationId is a new conversation owned by that user.string
default:"UTC"
IANA timezone of the end user, for example
Europe/Paris. The agent uses it for time-aware answers.Response
data object to your client. The participantToken is scoped to this single session and expires with it, so it is safe to ship to the browser.
Errors
Failures use the standard API v2 error shape:
A 429 from
VOICE_LIMIT_EXCEEDED is worth surfacing to your user, since it clears on its own:
Example backend route
A minimal Next.js App Router handler that your client calls instead of talking to Chatbase directly:app/api/voice-session/route.ts
Join from your client
Install the Chatbase Voice SDK:error event, and sendText still gets spoken replies.
SDK reference
Methods and properties
Every method returns a promise except
on and off; isMuted and localAudioStream are plain properties.
Events
Interruption
Barge-in needs no client code. The agent detects the caller speaking over it and stops mid-sentence, when the “Allow interruptions” setting is enabled in the agent’s voice settings.Lifecycle and billing
A session ends when the client disconnects, whenmaxDurationSeconds elapses, after the configured silence timeout, or when credits run out. Enforcement happens server-side, so clients cannot extend a session past its limits.
Voice minutes consume message credits exactly like widget voice sessions. Conversations, transcripts, and recordings appear in the dashboard chat logs with source API.
Voice sessions require a plan with voice mode enabled. Session concurrency, per-user, hourly, and daily limits come from the agent’s voice settings; exceeding one returns
VOICE_LIMIT_EXCEEDED with the specific reason in details.reason.