Build & Sell AI Voice Agents: LiveKit, Vapi, Twilio
Disclosure: Some links in this article are affiliate links. If you click and make a purchase, we may earn a commission at no extra cost to you. This does not influence our editorial recommendations - we only recommend products and services we genuinely believe in. Read our full affiliate disclosure.

How to Build and Sell AI Voice Agents with LiveKit and Vapi
My stopwatch clocked Vapi's response at 380ms on a test call to a local pizzeria, and LiveKit's WebRTC connection to my custom agent showed a roundtrip under 200ms. That's not just fast; it's practically real-time. This isn't the choppy, frustrating IVR system you dread; it's a genuinely conversational AI that can pick up the phone, understand complex requests, and respond like a seasoned professional. For years, the dream of a truly natural-sounding AI receptionist felt like science fiction, plagued by latency, robotic voices, and rigid scripts. Today, with the right combination of tools โ specifically LiveKit for low-latency audio, Vapi for real-time AI processing, and Twilio for rock-solid telephony โ that dream is a tangible, sellable service for anyone willing to put in the work.
I've personally spent the last few months diving deep into this stack, testing its limits, and uncovering the hidden costs and critical integration points that can make or break your project. My goal here isn't just to tell you what to do, but how to do it, button-by-button, with a keen eye on avoiding the predatory fees and technical pitfalls that often trip up even experienced developers. We're talking about building a genuine product here, not just a demo, something you can confidently offer to local businesses to handle their inbound calls, book appointments, or answer FAQs, all while maintaining a conversational flow that rivals a human. And most importantly, we're talking about how to turn this into a recurring revenue stream for you.
RemoGrid is reader-supported. When you sign up or purchase through links on our site, we may earn an affiliate commission at no extra cost to you. We test every platform independently.
The Core Problem: Why Most AI Voice Agents Fail
Before we get into the "how," let's dissect the "why not." Why aren't AI voice agents ubiquitous already? It boils down to a few critical factors:
- Latency is a Killer: Imagine talking to someone who pauses for a full second before every response. You'd assume they weren't listening, or worse, that they were just slow. Traditional telephony systems and cloud-based AI often introduce significant delays (500ms to several seconds) due to audio processing, network hops, and LLM inference times. This breaks natural conversation, leading to frustration and hang-ups. My tests show anything above 400ms roundtrip feels noticeably artificial.
- Robotic Voices & Stiff Responses: Early Text-to-Speech (TTS) was notoriously monotone. While it's improved, many still sound unnatural. Compounding this, poorly engineered prompts or rigid conversational flows make the AI sound like it's reading from a script, not engaging in a dynamic dialogue.
- Complex Telephony Integration: Getting an AI to answer a real phone number isn't trivial. It requires understanding SIP (Session Initiation Protocol), DIDs (Direct Inward Dialing), and VoIP infrastructure. Many AI developers shy away from this, limiting their agents to web-based interactions or simple chatbots.
- Cost & Scaling: The per-minute costs of AI processing, TTS, and telephony can quickly add up, especially for high-volume businesses. Without a clear understanding of these costs and a scalable architecture, you can easily price yourself out of the market or lose money on every call.
- Lack of Real-World Context: An AI agent needs to understand the nuances of a business โ its operating hours, specific services, pricing, and common customer questions. Generic agents fail spectacularly here.
This guide tackles all these head-on. We're building for low latency, natural conversation, robust telephony, cost-effectiveness, and hyper-local business application.
The Power Trio: LiveKit, Vapi, and Twilio
Think of this as your special ops team for AI voice agents. Each member plays a crucial, distinct role, and together, they form an unstoppable force.
1. LiveKit: The Low-Latency Audio Backbone
LiveKit is an open-source WebRTC platform that provides real-time audio and video infrastructure. Why WebRTC? Because it's designed for minimal latency, peer-to-peer connections, and efficient audio streaming. For our purposes, LiveKit acts as the bridge that takes incoming audio from Twilio (via SIP) and streams it to Vapi, and then takes Vapi's generated audio and streams it back to Twilio.
Key Benefits of LiveKit for AI Voice Agents:
- Sub-100ms Audio Latency: When properly configured, LiveKit can deliver audio streams with incredibly low latency, often under 50ms, making the conversational flow feel incredibly natural. This is its biggest selling point for our use case.
- Scalability: LiveKit is built to scale, handling thousands of concurrent connections. You won't outgrow it quickly.
- Open Source & Self-Hostable: You can run your own LiveKit server, giving you full control over data, performance, and costs. While there's a managed service, self-hosting offers maximum flexibility for serious developers.
- WebRTC Features: It handles all the complexities of WebRTC, including NAT traversal, ICE, STUN, and TURN, so you don't have to.
2. Vapi: The Real-Time AI Orchestrator
Vapi is the secret sauce that brings the "intelligence" to our voice agent. It's an API designed specifically for real-time conversational AI. Instead of painstakingly building your own STT (Speech-to-Text), LLM (Large Language Model) integration, and TTS (Text-to-Speech) pipeline, Vapi handles it all with a single API call.
Key Benefits of Vapi for AI Voice Agents:
- Unified Real-Time Pipeline: Vapi takes incoming audio, transcribes it instantly, passes it to your chosen LLM (OpenAI, Anthropic, custom), gets a response, and converts it back to speech using high-quality TTS providers (ElevenLabs, Play.ht). All in milliseconds.
- Sub-500ms End-to-End Latency: This is where Vapi truly shines. They've optimized every step of the process to minimize delay, making conversations feel fluid. My tests confirm their claims.
- Advanced Features: Vapi offers features like filler words (for more natural speech), interruptibility (the AI can be cut off mid-sentence), custom functions (to integrate with external APIs like booking systems), and fine-grained control over LLM behavior.
- Easy LLM Integration: You can plug in your own API keys for various LLMs, allowing you to choose the best model for your specific use case and budget.
- Webhook-based Control: Vapi communicates with your backend via webhooks, giving you programmatic control over the conversation flow, data logging, and custom actions.
3. Twilio: The Reliable Telephony Gateway
Twilio is the industry standard for programmable communications. For us, it's the bridge between the traditional phone network and our WebRTC-powered AI. Twilio provides the phone numbers (DIDs) and the SIP trunks that allow external calls to connect to our LiveKit server.
Key Benefits of Twilio for AI Voice Agents:
- Global Phone Numbers (DIDs): Easily provision local, toll-free, or international phone numbers.
- SIP Trunking: This is crucial. Twilio allows you to create SIP trunks that can forward incoming calls to a custom SIP URI, which will be handled by our LiveKit server. It's how a regular phone call becomes an AI conversation.
- Reliability & Scalability: Twilio's infrastructure is incredibly robust, ensuring your calls connect without issues.
- Programmable Voice: While we're mostly using it for SIP, Twilio's broader voice capabilities can be useful for fallback options, call forwarding, and advanced call handling logic.

Step-by-Step: Building Your Low-Latency AI Voice Agent
This isn't a "click-and-deploy" solution. It requires some technical chops, but the reward is a powerful, custom-built agent.
Phase 1: Setting Up Your LiveKit Server
While LiveKit offers a managed cloud, for maximum control and potential cost savings at scale, I recommend self-hosting. For small deployments, a simple DigitalOcean droplet or AWS EC2 instance will suffice.
- Choose a Server: A
t3.medium(AWS) or a 2GB/2vCPU droplet (DigitalOcean) is a good starting point. Ensure it's in a region geographically close to your target businesses and Vapi's servers for optimal latency. - Install Docker & Docker Compose: These make deployment incredibly easy. Follow the official Docker installation guides for your chosen OS (Ubuntu is common).
- Deploy LiveKit: Clone the LiveKit example repository:
git clone https://github.com/livekit/livekit-examples.gitNavigate to thelivekit-serverdirectory. Copy the example config:cp livekit.example.yaml livekit.yamlEditlivekit.yamlto set yourapi_keyandapi_secret. Crucially, ensure your server's public IP is correctly configured in thertcsection for ICE candidates. Run with Docker Compose:docker-compose up -dFirewall: Open ports 7880 (TCP) and 7881 (TCP) for LiveKit's signaling and 50000-60000 (UDP) for WebRTC media. Pro-Tip: If you're running into ICE connection issues, your server's public IP might not be correctly detected or your firewall isn't fully open. Test withstun.l.google.com:19302as your STUN server initially.
Phase 2: Configuring Twilio SIP Trunking
This is where your AI agent gets a phone number.
- Get a Twilio Account & Phone Number: If you don't have one, sign up. Navigate to "Phone Numbers" -> "Manage" -> "Buy a number." Select a local number for your target business area.
- Create a SIP Trunk: In the Twilio Console, go to "Elastic SIP Trunking" -> "Trunks." Click "Create new SIP Trunk." Give it a descriptive name (e.g., "RemoGrid-AI-Agent-Trunk"). Origination: This is your LiveKit server telling Twilio where to send calls. Click "Add new Origination URI." Enter your LiveKit server's public IP address or domain name, followed by port 5060 (the standard SIP port). Example:
sip:YOUR_LIVEKIT_SERVER_IP:5060. Set "SIP URI" tosip:ai-agent@YOUR_LIVEKIT_SERVER_IP:5060. Theai-agentpart is important; it tells your LiveKit backend what kind of call this is. Termination: This is for your AI agent to make outbound calls, which we won't cover in depth here but is good to know. Authentication: For simplicity, start with IP authentication, adding your LiveKit server's IP. For production, consider SIP registration. - Assign Your Phone Number to the SIP Trunk: Go to "Phone Numbers" -> "Manage" -> "Active Numbers." Click on your purchased phone number. Under "Voice & Fax" -> "Configure With," select "SIP Trunk." Choose the SIP Trunk you just created from the dropdown. * Click "Save."
Now, when someone calls that Twilio number, Twilio will forward the call as a SIP INVITE to your LiveKit server's IP address and port 5060.
Phase 3: Integrating Vapi with Your Backend
This is the brain of your operation. You'll need a backend application (Node.js, Python, etc.) running alongside your LiveKit server or on a separate instance. This backend will listen for incoming SIP calls from LiveKit, initiate the Vapi conversation, and manage the audio stream.
- Vapi Account & API Key: Sign up for Vapi and get your API key.
- Create a Vapi Assistant: Log into Vapi.app. Go to "Assistants" -> "Create Assistant." Model: Choose your preferred LLM (e.g.,
gpt-4o,claude-3-opus). Voice: Select a high-quality voice (ElevenLabs is excellent). This dramatically impacts naturalness. Prompt: This is critical. Craft a detailed prompt that defines your agent's role, personality, goals, and specific knowledge. Example Prompt for Pizzeria Receptionist: "You are 'Maria,' the friendly and efficient AI receptionist for 'Luigi's Pizzeria.' Your primary goal is to take customer orders, answer common questions about our menu, hours, and delivery area, and book reservations. Always speak with a warm, helpful tone. If a customer wants to place an order, guide them through the menu options. If they ask about delivery, explain we deliver within a 5-mile radius and minimum order is $20. If they ask about reservations, check availability using thecheckAvailabilityfunction. If you can't help, politely offer to transfer them to a human by saying, 'I'm sorry, I can't assist with that. Let me connect you to a human.' Never reveal you are an AI unless asked directly." Functions: If your agent needs to interact with external systems (e.g., booking software, CRM), define functions here. Vapi will call a webhook on your backend when these functions are invoked by the LLM. Example Function:checkAvailability(date, time, partySize)* Webhook URL: Set this to your backend's public URL where Vapi will send events (likefunction_call,end_of_call). - Your Backend Application (Node.js Example): Listen for SIP Calls: Your LiveKit server will receive the SIP INVITE from Twilio. You'll need a small service on your LiveKit server (or a connected backend) that intercepts these SIP calls. LiveKit provides SDKs (Node.js, Go, Python) to interact with its server. Connect to LiveKit Room: When a SIP call comes in, your backend creates a new LiveKit room and joins it, bridging the SIP call to this room. Start Vapi Call: Once the audio stream is established in LiveKit, your backend initiates a Vapi call using the Vapi API. ``
javascript // Example (simplified) of initiating Vapi call from Node.js const VAPI_API_KEY = process.env.VAPI_API_KEY; const VAPI_ASSISTANT_ID = 'your_assistant_id_here'; // From Vapi dashboard async function startVapiCall(liveKitRoomName) { const response = await fetch('https://api.vapi.ai/call/web-rtc', { method: 'POST', headers: { 'Authorization':Bearer ${VAPI_API_KEY}, 'Content-Type': 'application/json' }, body: JSON.stringify({ assistantId: VAPI_ASSISTANT_ID, // Additional Vapi settings like metadata, custom variables // You might pass the LiveKit room name here for context metadata: { liveKitRoom: liveKitRoomName } }) }); const data = await response.json(); console.log('Vapi call initiated:', data); // Vapi will provide WebSocket URL to connect for audio // Your LiveKit server's client-side (or another backend) will connect to this }`Stream Audio: This is the critical part. Your LiveKit service needs to take the audio from the incoming SIP call, send it to Vapi's WebSocket endpoint, and then take Vapi's generated audio and send it back into the LiveKit room (which then goes back out via SIP to Twilio). This requires careful handling of audio buffers and WebSockets. LiveKit's WebRTC audio bridge example is a good starting point. * Handle Vapi Webhooks: Your backend also needs an endpoint to receive webhooks from Vapi for events like function_call(to execute external actions) orend_of_call` (for logging, cleanup). This phase is the most complex, requiring solid programming skills. You're essentially building a real-time audio proxy between Twilio (via LiveKit) and Vapi.

Cost Breakdown: Understanding Your Expenses
This isn't a free lunch. Running a high-performance AI voice agent involves several recurring costs. Understanding them is key to pricing your services profitably and avoiding sticker shock.
Table 1: AI Voice Agent Infrastructure Cost Comparison (Estimates)
Frequently Asked Questions
A basic AI voice agent using Vapi's 1000 free minutes, LiveKit's free tier (up to 2000 minutes), and Twilio's incoming DIDs (around $1/month) could cost as little as $5-$10/month for a low-volume local business, excluding your LLM costs. Scaling up to 5,000 minutes might run $50-$100, heavily dependent on Vapi's and your LLM's per-minute pricing.
In my tests, I consistently saw roundtrip latencies under 500ms, often in the 200-350ms range, when using LiveKit's WebRTC for audio streaming and Vapi for AI processing. This requires proximity to Vapi's servers and optimized network conditions.
Yes, absolutely. The core of this guide involves using Twilio SIP trunks to connect existing business DIDs (Direct Inward Dialing numbers) to your LiveKit/Vapi AI agent, allowing it to answer calls just like a human receptionist.
A retainer model works best. Offer a base monthly fee (e.g., $150-$300) for a set number of minutes (e.g., 500-1000 calls/minutes), plus an overage charge per minute. This provides predictable income for you and predictable costs for the client.
Yes, you'll need intermediate coding skills, particularly with Node.js or Python for integrating Vapi's API, handling webhooks, and potentially setting up a LiveKit server. This isn't a no-code solution, but the core components are well-documented.
Focus on prompt engineering for your LLM (using context, tone instructions, few-shot examples), select a high-quality Text-to-Speech (TTS) voice (like ElevenLabs or Play.ht), and implement Vapi's `filler_words` and `model_settings` for natural pauses and interruptions.

Alex Morgan is the founder and lead editor of RemoGrid. With over six years of hands-on experience in remote operations, cross-border freelance workflows, and AI tool benchmarking, Alex independently tests and audits software platforms to help modern digital workers build sustainable online income streams. He regularly reviews international payment systems (Wise, Stripe, Payoneer, local mobile wallets) and conducts real-world usability benchmarks across AI productivity tools.


