camelAI Documentation

Channels and voice

Voice calls and realtime voice sessions in camelRun v2

Run realtime OpenAI and ElevenLabs voice calls (/v2/voice/calls) and agent voice sessions (/v2/voice/sessions) bridged to camelRun v2 agents.

View as Markdown

camelRun v2 provides two realtime voice interfaces backed by OpenAI Realtime and ElevenLabs:

  1. Managed voice calls (/v2/voice/calls): Durable call lifecycle (VoiceCallDO) with WebRTC SDP negotiation (OpenAI) or signed conversation URLs (ElevenLabs), speaker mapping, transcript ingestion, automatic metering, and voice webhooks.
  2. Agent voice sessions (/v2/voice/sessions): Lightweight realtime session broker hosted directly on AgentDO with an HTTP and WebSocket tool bridge back to the agent's tools.

Managed voice calls (/v2/voice/calls)

Start a voice call (POST /v2/voice/calls)

Create a call linked to an existing agent (agt_...):

bash
curl -s -X POST "https://run.camelai.com/v2/voice/calls" \
  -H "Authorization: Bearer $CAMELRUN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent": "agt_0123456789abcdef",
    "provider": "openai",
    "voice": "alloy",
    "subject": "user-42",
    "instructions": "Answer concisely and use tools for account actions.",
    "maxMinutes": 60,
    "speakers": { "user-42": "Alice" },
    "sdp": "v=0\r\n..."
  }'

Request fields:

FieldTypeRequiredDescription
agentstringYesAgent ID (agt_...)
provider"openai" | "elevenlabs"YesRealtime voice provider
subjectstringYesCaller or end-user identifier (1 to 200 chars)
sdpstringOpenAI onlyWebRTC SDP offer (up to 64 KiB)
modelstringNoProvider realtime model override
voicestringNoVoice ID or name (defaults to alloy for OpenAI)
instructionsstringNoVoice prompt override (up to 8,000 chars)
languagestringNoBCP-47 language code (for example en, en-US)
bucketstringNoOptional billing/context bucket tag
contextobjectNoOptional context object attached to call events
keyScopestringNoOptional provider key scope (1 to 100 chars)
maxMinutesnumberNoCall duration limit (1..720, default 240)
metadataobjectNoCustom JSON metadata (up to 4 KiB serialized)
speakersRecord<string, string>NoMap of up to 50 speaker IDs to display names (max 40 chars each)
interruptResponsebooleanNoWhether caller speech interrupts an active reply

Returns 201 with the VoiceCall object plus connect:

  • For OpenAI: connect: { sdpAnswer: "..." }
  • For ElevenLabs: connect: { signedUrl: "...", conversationId: "..." }

Manage active calls

EndpointPurpose
GET /v2/voice/calls?state=live|ended&limit=50List calls for your tenant (limit 1 to 100, requires tenant key)
GET /v2/voice/calls/:idFetch call status, turns, asks, audioSeconds, costUsd, metadata, speakers
PATCH /v2/voice/calls/:idUpdate speakers and/or metadata on a call
POST /v2/voice/calls/:id/transcriptAppend a transcript utterance ({ speaker, text, seconds?, startedAt?, endedAt? }), returns 202
POST /v2/voice/calls/:id/endEnd a call with optional { reason }
DELETE /v2/voice/calls/:idEnd a call (with reason "requested")

Voice calls emit signed webhooks (voice.session.started, voice.utterance, voice.agent.replied, voice.session.ended, and usage.recorded). See Webhooks.

ElevenLabs provider callbacks

camelRun exposes signed callback routes used by ElevenLabs agents:

  • POST /v2/voice/providers/elevenlabs/post-call (verifies ElevenLabs-Signature)
  • POST /v2/voice/providers/elevenlabs/tools/:tool (ask_agent or stay_silent, authenticated with X-Voice-Tool-Secret)

Agent voice sessions (/v2/voice/sessions)

For direct browser or app clients that want an ephemeral provider credential and a tool bridge into an agent's configured tools, use /v2/voice/sessions:

ts
const session = await client.voice.createSession({
  agentIdOrKey: "support-agent",
  provider: "openai", // or "elevenlabs"
  voice: "alloy",
});
// { sessionId: "vs_...", provider, voice, agentId, clientSecret, wsUrl, expiresAt }

// Execute an agent tool from the voice session
const toolOut = await client.voice.invokeTool(session.sessionId, {
  name: "lookupOrder",
  args: { orderId: "ORD-42" },
});

Voice session routes:

EndpointPurpose
POST /v2/voice/sessionsCreate a 15-minute realtime session for { agentIdOrKey, provider?, voice?, instructions? }
GET /v2/voice/sessions/:idInspect an active voice session
POST /v2/voice/sessions/:id/toolInvoke one of the agent's tools ({ name, args?, callId? })
GET /v2/voice/sessions/:id/wsWebSocket tool bridge (accepts Authorization: Bearer ... or ?token=...; send { type: "tool_call", callId, name, args }, receive { type: "tool_result", ... })

Limits

  • Up to 50 concurrent active voice calls per tenant (configurable via AGENT_VOICE_SESSIONS_PER_TENANT).
  • Maximum call duration: 720 minutes (default 240 minutes).
  • Metadata: up to 4 KiB JSON; speakers: up to 50 entries (40 chars max per display name); SDP: up to 64 KiB.