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.
Want help getting this working? Join the Vibe Coding Academy ↗ Run by Alex Finn, who also runs this site.
Discussion on HN · Mar 2, 2026
Related use cases
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.
Autonomously test an entire iOS app and report bugs
A tool lets Claude Code drive an iOS app through the accessibility tree, tap every screen, and return a structured bug summary.
Audit a feature's issues and hand them to an engineer's agent
An AI agent listed all issues with a feature and sent them to an engineer, whose own agent then addressed most of them automatically.
Custom agent
Build small features and integrations with Cursor agent mode
A commenter uses Cursor agent mode for smaller features, third-party integrations, background jobs, notifications and activity tracking, and has it log key findings to a worklog file for the next run.
Cross-check coding agent answers with a second agent
The poster built a tool that automatically sends Claude Code responses to Codex for a second opinion, replacing manual copy-pasting.
Upgrade vulnerable dependencies via automated pull request
Devin opened a PR on a Spring Boot and Next.js sample app upgrading dependencies to fix listed CVEs, including 103 npm vulnerabilities on the frontend.
Get 5 like this every morning
The best things people got an AI agent to do, each with the prompt to try it.