OpenAI Realtime & ElevenLabs agents
Goal: answer and place phone calls with an agent you already built at OpenAI or ElevenLabs, on your Kolwire numbers. The conversation runs at the provider; calls, recordings, transcripts, webhooks and billing stay here. Anything that can route to an agent (numbers, POST /v1/calls with agent_id, flows, campaigns) works with these agents.
OpenAI Realtime
- In OpenAI: note your project ID (Settings → Project → General,
proj_…) and create an API key. - Create the agent here:
const agent = await vi.agents.create({
name: "Receptionist",
mode: "openai_realtime",
system_prompt: "You are the receptionist of Acme Clinic…",
first_message: "Hi, Acme Clinic, how can I help?",
language: "he",
external: { project_id: "proj_abc123", model: "gpt-realtime-2.1", voice: "marin", region: "global" }, // region "eu" = EU data residency
provider_api_key: process.env.OPENAI_API_KEY,
provider_webhook_secret: "whsec_…", // from step 3 — you can PATCH it in afterwards
});
console.log(agent.connector.webhook_url); // https://api.kolwire.com/v1/integrations/openai/webhook/agt_…- In OpenAI (Settings → Project → Webhooks): add a webhook for
realtime.call.incomingpointing atconnector.webhook_url, and save its signing secret on the agent (provider_webhook_secret). - Route a number to it:
vi.numbers.update(id, { voice_config: { mode: "agent", agent_id: agent.id } }), or call out:vi.calls.create({ from, to, agent_id: agent.id }).
How it works: we bridge the call to sip:<project_id>@sip.api.openai.com;transport=tls. OpenAI posts realtime.call.incoming; we check the signature (Standard Webhooks), make sure the call is one we bridged for this agent (anything else is rejected with 603), and accept it with the agent's prompt, first message, language, model and voice.
ElevenLabs Agents
- In ElevenLabs: build the agent (prompt, voice, tools) and create an API key.
- Create the agent here and connect it:
const agent = await vi.agents.create({
name: "Support",
mode: "elevenlabs",
external: { agent_id: "agent_…", region: "global", transport: "tcp" },
provider_api_key: process.env.ELEVENLABS_API_KEY,
});
await vi.agents.provision(agent.id);provision creates a SIP gateway with new digest credentials and registers a SIP-trunk "phone number" at ElevenLabs (identifier vi-<agent id>) bound to your ElevenLabs agent. Run it again to rotate the credentials.
- Route numbers or calls to
agent.idas above. Each call gets anX-VI-Call-IDheader, available in ElevenLabs as the dynamic variable.
Notes
- Billing: the phone minutes are billed here as usual; the AI is billed by OpenAI / ElevenLabs on your account.
- Media is plain RTP (G.711). ElevenLabs numbers are created with media encryption disabled.
- In the dashboard: AI agents → Model → OpenAI Realtime / ElevenLabs Agents.