Skip to main content
The Voice Sessions API lets you run your agent’s voice mode inside your own web interface instead of the Chatbase widget. Your backend creates a session, your client joins it with the Chatbase Voice SDK, and the full voice pipeline runs on Chatbase: speech to text, the agent response with your training data and actions, text to speech, and natural interruption handling. Your client only publishes microphone audio and renders state. Transport is WebRTC rather than a plain WebSocket. This is what makes low latency and barge-in possible: the user can talk over the agent and it stops speaking immediately, with no extra code on your side.

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.
The demo takes an API key in its UI so you can try it in a few seconds; the key is sent only to the demo’s own backend, which proxies Chatbase. Your own app should keep it in server-side env vars instead, as shown below. Demo sessions are real: they use message credits and appear in your chat logs.

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

Hand the 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.
Never cache this response. Each participantToken belongs to one session and expires with it, so a cached response makes every later visitor connect with a dead token. In Next.js App Router that means cache: "no-store" on the fetch and export const dynamic = "force-dynamic" in the route.

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:
The agent joins the session automatically and speaks the configured greeting; its audio plays without any setup.
If the user declines microphone permission, the session continues in text mode: the SDK emits an 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, when maxDurationSeconds 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.