The open-source alternative to Twilio voice AI keeps Twilio as your carrier and replaces only the agent layer. Dograh, the open-source AI voice agent platform we build, runs on your Twilio number with your own models, under the BSD 2-Clause licence, and you can self-host it with Docker Compose or run it on Dograh Cloud.
Key Takeaways
- Keep Twilio's numbers and network. Replace only the layer that runs the agent.
- Twilio's ConversationRelay runs speech on Twilio. Your code still runs the agent.
- To leave Twilio too, connect an Asterisk PBX through Asterisk ARI.
Twilio does two jobs for a voice agent, and you can keep one while owning the other. We separate the two layers, cover what Twilio's AI voice products do, what owning the agent changes, the same call both ways, running it with Docker Compose, then the route that replaces Twilio.
Twilio does two jobs
When people say they want an open-source alternative to Twilio, they usually mean one of two projects. The first job Twilio does is the carrier layer. It rents you phone numbers and connects calls to the phone network, with your caller ID and billing kept in one account. The second is the agent layer, where its AI voice products listen to the caller, hand text to a language model and speak the reply.
Most teams who ask the question are happy with the first job. Twilio rents numbers in more than 100 countries, and their numbers and billing are already set up there. What they want to own is the second job, because that is where the models, the call data and the agent's logic live.
So this post keeps Twilio as the carrier and replaces only the agent layer. The last section covers the other project, where Twilio goes as well. For how carriers, numbers and SIP trunks fit together in general, see Telephony 101 for voice AI.
What Twilio's AI voice products do
Twilio sells its agent layer as a set of conversational AI products, each priced on its own. Twilio's conversational AI prices list ConversationRelay at $0.07 a minute, with voice minutes calculated separately, beside Conversation Orchestrator, Conversation Intelligence, Conversation Memory and Enterprise Knowledge.
ConversationRelay is the one that runs a live call. Twilio turns the caller's speech into text with Google or Deepgram, sends that text to your application over a WebSocket, and speaks your application's reply with Google, Amazon or ElevenLabs. Your application runs the language model and decides what to say. The other products work on text and conversations around the call. Intelligence analyses transcripts, from $0.002 per 1,000 characters, and Orchestrator charges $0.0002 per 1,000 characters it takes in.
That split is useful to understand. With ConversationRelay, Twilio owns the speech-to-text and the voice, and you own the model and every action the agent takes, written as your own code. Our post on Twilio ConversationRelay goes through every setting it offers and what you still build around it.
What owning the agent layer changes
An open-source agent platform on a Twilio number takes the raw call audio through Media Streams, at $0.0044 a minute, and runs the whole agent itself. Under Dograh, you connect Twilio with your Account SID and Auth Token. Your numbers stay in your Twilio account, and Dograh sells no numbers or minutes, so the carrier bill stays yours.
The models become your choice. You bring your own keys for any speech-to-text, language model and voice provider, or run open-weight models on your own servers. Swapping a provider means changing a setting. Dograh handles the call flow and the phone connection, while the speech and language models sit in their own layer you choose.
The call data moves too. Self-hosted, recordings and transcripts sit on your own servers, and with local open models no AI vendor receives the audio. Twilio still carries the call, and Twilio's Regions guide says its default Region is in the eastern US and that it does not guarantee all data stays in a chosen Region, so the carrier side still needs its own review.
The code is yours to read. Dograh is released under the BSD 2-Clause licence, so you can read and change the code and keep running it as long as you like. You also get a visual workflow builder, tools that call your systems mid-call, Transfer Call with an optional spoken introduction on Twilio, pre-recorded clips with a voice fallback, full call traces and built-in QA, which you would otherwise build around ConversationRelay.
Open Source Alternative to Vapi / Retell
Self-hosted voice agent platform — no per-minute fees
dograh-hq/dograh
Star on GitHub
Three routes side by side
The table compares the three routes a team with Twilio numbers can take. Dograh appears on the second row, the route this post recommends for teams who like Twilio as a carrier.
| Route | Carrier | Speech and voice | Language model and agent logic | Where call data sits | Code |
|---|---|---|---|---|---|
| Twilio ConversationRelay | Twilio | Twilio, with Google, Deepgram, Amazon or ElevenLabs | Your own code and model | Twilio and your app | Closed speech layer, your app |
| Dograh on a Twilio number | Twilio | Any provider by your key, or open models you host | Dograh's visual builder, tools and QA | Your servers when self-hosted, or Dograh Cloud | BSD 2-Clause |
| Open-source carrier stack | Asterisk or similar, with your own SIP provider | Whatever your agent layer runs | Your own agent layer, which can be Dograh over Asterisk ARI | Your servers | Open source end to end |
The same call on both routes
Here is one worked example, a 5-minute inbound call to a US local Twilio number. On the ConversationRelay route, Twilio's side is 5 minutes at $0.0085 plus 5 minutes of ConversationRelay at $0.07, $0.3925, and you add your language model and the server that runs your WebSocket app.
On the open-source platform route, Twilio's side is the same minutes plus Media Streams, $0.0645, and your speech-to-text, voice and model providers bill your own keys. Self-hosted Dograh has no per-minute platform fee, but servers, model keys and phone minutes still cost money. Dograh Cloud charges a 1¢-a-minute platform fee. On this call, that comes to $0.05.
With every model line priced, our ConversationRelay post puts the same call at about $0.4052 on ConversationRelay and about $0.2377 on Dograh Cloud with Deepgram and gpt-4.1-mini. Your providers and the agent's talk time will move both. Our guide to Twilio pricing covers every other line on the Twilio side.
Running it yourself with Docker Compose
Self-hosting starts with one machine. Dograh ships a docker-compose.yaml at the root of its repository, and the quickstart downloads that file with a start script and runs it. The Docker deployment guide asks for a server with Docker and Docker Compose and at least 8 GB of memory and 4 vCPUs.
On a local machine, the quickstart opens a public quick tunnel to the API so Twilio's webhooks can reach it, and signup is on. Once you have created your first account, set ENABLE_SIGNUP=false in the .env file and run the start script again so nobody else can sign up. On a remote server with a public IP, setup gets an HTTPS certificate for you, which browsers need before they allow the microphone for test calls.
Then connect Twilio, create an agent and save it as the inbound workflow on a number. Saving points that Twilio number at Dograh straight away. Our tutorial on how to self-host a voice AI agent with Docker walks through each step, from the first download to the first test call.
Self-hosted Dograh runs 10 concurrent calls by default, and you can raise that limit with a setting. Your servers and Twilio account set the practical ceiling above it.
If you want to replace Twilio too
Some teams want the carrier layer open as well, often for cost at very high volume or because a compliance review covers every vendor that touches the call. That route swaps Twilio for an open-source PBX such as Asterisk, fed by a SIP trunk from a provider you choose, and it is a bigger project than changing the agent layer.
The agent layer still needs a home on that route. Dograh connects to an existing Asterisk PBX through Asterisk ARI, Asterisk's REST interface, which gives Dograh control of the call and its audio. Transfer Call works on Asterisk ARI as well. You need Asterisk 22, or Asterisk 20 LTS with the WebSocket channel modules built in.

There are open-source carrier platforms too. Fonoster, released under the MIT licence, describes itself as a platform for building and running voice agents on real phone lines, either self-hosted or on its own cloud. Projects like these replace the carrier side, and you still choose which agent runs on top.
If you are happy with Twilio's numbers and network, you don't need any of this. Keep the carrier and own the agent. You can still move the carrier later if a reason comes up.
Join the Dograh Community
Dograh is an OSS alternative to Vapi. Join our Slack community for queries, releases, best practices & community interactions.
Glossary
- Agent layer
- The part of a voice stack that listens to the caller, decides what to say and speaks the reply, with its models, tools and call flow. It is separate from the carrier, so you can own it while keeping Twilio's numbers.
- Media Streams
- Twilio's raw audio feed for a call. It sends the audio to your server over a WebSocket and plays back what your server sends, for $0.0044 a minute, and it is how Dograh receives Twilio calls.
- Asterisk ARI
- The Asterisk REST Interface, which lets outside software control calls on an Asterisk PBX. Dograh uses it to run agents on calls that never touch Twilio.
- BSD 2-Clause licence
- A short, permissive open-source licence. You can use, change and run the code, including commercially, as long as the copyright notice and disclaimer stay with it.

