Build a phone voice agent that answers in under half a second
A from-scratch voice agent averaging about 400ms end to end, with streaming speech-to-text, LLM, and text-to-speech and clean barge-ins.
Done with a custom-built or unnamed agent
- What they did
- A FastAPI server takes Twilio's audio over a WebSocket and sends it to Deepgram Flux, which handles transcription and turn detection. When a turn ends, the transcript goes to an LLM, tokens stream into ElevenLabs TTS, and the audio goes straight back to Twilio. A barge-in cancels the LLM and TTS and flushes Twilio's buffer. Pre-connected TTS sockets are kept warm.
- How it went
- Run locally, latency was about 1.7s. Deploying in the EU cut it to about 790ms, slightly better than Vapi's estimate of about 840ms. Swapping gpt-4o-mini for Groq's llama-3.3-70b brought it to about 400ms. The first turn was slower.
- Worth knowing
- The build took about a day and roughly $100 in API credits. Keep the server in the same region as Twilio, Deepgram and ElevenLabs, because location halved latency.
Try it yourself with Claude Code
Help me build a phone voice agent in [language, e.g. Python] for [use case, e.g. answering calls for a dental office] using streaming speech-to-text, an LLM, and streaming text-to-speech, with the goal of responding in under 500ms and handling interruptions cleanly. Scaffold the project, wire up [providers, e.g. Deepgram, an LLM API, ElevenLabs, Twilio], and add latency logging. Finish when a test call works and the log shows average latency; ask before making any real phone calls or purchasing numbers.
Discussion on HN · Mar 2, 2026
Five of these in your inbox every morning
The best things people got an AI agent to do, each with the prompt to try it.
More like this
- Claude
Build a C compiler with a team of parallel agents
Anthropic's engineering write-up on tasking Opus 4.6 agent teams with building a C compiler.
- Custom agent
Catch cloud outage risks before they happen
An autonomous ReAct agent that queries real data to stop cloud outages before they occur, built for the Sanity Challenge.
Hand narrow code changes to Devin for pull requests
A team used Devin for a month on small fixes like chart formatting and API edge cases, with tests and PRs; a complex full-stack task went poorly.
Migrate toolchain, architecture and site design with Claude Code
A developer had Claude Code switch a monorepo to oxlint/oxfmt, restructure the architecture and redesign a site, validating in a loop; the redesign took days instead of weeks.
Build and deploy a Game of Life simulation site
In a vendor launch demo, Devin built an interactive Game of Life website, added requested features step by step, and deployed it to Netlify.
Resolve a Slack-reported issue with a coding agent
A Codex agent resolved an issue passed to it in about 40 minutes, and an ops agent verified the fix back in Slack.