Skip to Content

Talk to your agent in the browser

The fastest way to hear your agent — a WebRTC call from a web page, no telephony setup.

A browser call needs no phone number and no carrier. You need a deployed agent and one endpoint on your backend that hands the browser a short-lived token. Audio flows directly between the browser and us.

Mint a token on your backend

Your API key must never reach the browser, so make this call server-side:

curl --fail-with-body -X POST "$KEJUE_API_BASE/web-calls" \
  -H "Authorization: Bearer $KEJUE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 018f4d7a-9c41-7e55-b2aa-59d4f1c88e21" \
  --data '{
    "agent_id": "AGENT_ID"
  }'

Return the whole response body to the browser. You can also send variables to fill in prompt variables, metadata to tag the call, and modality: "text" to start a chat session instead.

Install the SDK

npm install @kejue/voice-web livekit-client

Connect

import { startCall } from '@kejue/voice-web';

const call = await startCall({
  // The SDK calls this; fetch fresh credentials from YOUR backend.
  credentials: async () => {
    const response = await fetch('/api/voice-token', { method: 'POST' });
    return response.json();
  },
});

call.on('stateChange', (state) => {
  // 'connecting' | 'initializing' | 'listening' | 'thinking' | 'speaking' | 'disconnected'
  console.log('agent is', state);
});

call.on('transcript', (line) => {
  console.log(`${line.role}: ${line.text}`);
});

// Later:
call.setMuted(true);
await call.hangup();

Speak — the agent answers.

What you get without doing anything

  • The call shows up in your call list like any phone call, with its transcript and recording.
  • Guardrails, tools, webhooks, and extractions all run exactly as they do on phone calls.
  • Agent state, transcripts, and tool activity stream to the browser as events — enough to build a full call UI.

If something goes wrong

You seeWhat to do
422 no_production_versionThe agent isn't deployed. Deploy it, or pass version_id.
403 forbidden naming calls:start-webAdd that permission to the key your backend uses.
The browser connects but you hear nothingBrowsers block audio until the user interacts with the page. Start the call from a click. See Playing the audio.
The call shows failed with caller_hangup_pre_answerNobody joined within the token's window. Mint later, just before connecting.

Next

On this page