DEV Community

Cover image for LiveKit vs Twilio is the wrong question for a phone agent
Pritesh Kumar for Dograh AI

Posted on

LiveKit vs Twilio is the wrong question for a phone agent

Here's a view we hold firmly. SIP trunking is the most reliable way to bring production phone traffic into a voice agent, and WebRTC belongs to calls that start in a browser or an app. Work out which one your callers will use before you pick anything else.

Put that next to the LiveKit vs Twilio question and the question mostly falls apart. The two products do different jobs inside the same call, and plenty of phone agents run on both.

Follow one call from the handset

Someone dials your number from their mobile. The phone network has to hand that call to whoever owns the number, and that's the carrier's job. Twilio is a carrier. It rents numbers in more than 100 countries and connects them to the public phone network.

Then the audio has to reach your agent, and the agent's voice has to come back fast enough to feel like a conversation. That's the media layer, which is where LiveKit lives. It moves live audio between participants over WebRTC, and your agent joins the room as one of those participants.

A caller's phone call crosses the phone network to a Twilio number, then a SIP trunk carries it into a LiveKit room, where the call and the AI agent talk over WebRTC.

So a LiveKit agent that answers real phone calls usually has a SIP trunk feeding the room. Inbound calls show up as SIP participants that dispatch rules route into rooms, and outbound calls leave through an outbound trunk. LiveKit lists Twilio, Telnyx and Plivo among the trunk providers it has tested.

When you can skip the carrier

LiveKit Cloud does sell phone numbers, local and toll-free, in the United States only. If every caller is in the US and you're on LiveKit Cloud, those numbers can carry the whole thing and Twilio drops out.

Anything outside that brings a carrier back. Numbers in other countries need a trunk, and so do numbers you already own. Self-hosting LiveKit needs one too, plus LiveKit's SIP service running as its own deployment next to the media server. That's one more service to keep alive.

So for most teams the real decision is which carrier sits under LiveKit. Twilio is a common pick partly because LiveKit documents that exact route. You create a Twilio Elastic SIP trunk, point its origination at LiveKit's SIP endpoint, and the trunk domain ends in pstn.twilio.com. For inbound calls only, TwiML on Programmable Voice works as well.

Twilio has two doors, and they bill differently

Programmable Voice is the first door. A call hits your number, Twilio asks your server what to do, and Media Streams pushes the raw audio to your agent over a WebSocket. Receiving a call on a US local number costs $0.0085 a minute, and the stream adds $0.0044 a minute.

Elastic SIP Trunking is the second. It connects your Twilio numbers to anything that speaks SIP, LiveKit included. The audio travels over SIP, so there's no stream fee, and origination to a US local number is $0.0034 a minute.

Twilio also sells a speech layer of its own called ConversationRelay. If your agent already runs its own speech models, you can leave it out.

Price one call and look at the shape

Take a 5-minute inbound call to a US local number on LiveKit Cloud's Ship plan with a Twilio trunk, past the plan's 5,000 included agent session minutes and 5,000 SIP minutes, with the speech and language models left out.

Twilio origination comes to 5 x $0.0034 = $0.0170. LiveKit SIP minutes are 5 x $0.004 = $0.0200. Agent session minutes are 5 x $0.01 = $0.0500. That's $0.0870 for the call before models, plus the $50 Ship plan and $1.15 a month for the Twilio number. Inside the included minutes, the plan fee covers the LiveKit lines instead.

The total isn't the interesting bit. Two companies bill you for one call, the carrier for the line and the platform for the agent, and that split holds on every stack we've priced. Budget for both from the first day.

What the framework leaves on your plate

LiveKit gives you the media server and an agent framework, LiveKit Agents, which is open source under Apache-2.0. Your team writes the agent in code and builds the product around it, such as call lists and a way to review what happened on each call.

That's the gap a ready agent platform fills while keeping the carrier underneath. Dograh, the open-source AI voice agent platform we build, works that way, and you can self-host it or run it on our cloud. It runs on Pipecat through our own fork, not on LiveKit, and connects to Twilio with an Account SID and Auth Token. Your numbers stay on your Twilio account and your bill.

Full call traces and QA that scores each step of a call come built in, so reviewing calls isn't a side project.

On our cloud, a Twilio trunk can also point at the organisation's Managed SIP domain, which swaps the receive and stream lines for the trunk rate.

Handing a caller to a person works on Twilio too. Transfer Call rings the destination first and connects the caller once someone answers, with an optional short spoken introduction on Twilio.

If you're running LiveKit for phone calls outside the US, which carrier did you put underneath it, and what made you pick it?

The side-by-side table and the same call priced on a ready agent platform are in our breakdown of how a media framework and a phone carrier split one voice agent call.

Top comments (0)