Show HN: I built a sub-500ms latency voice agent from scratch
TL;DR Highlight
Building a voice agent from scratch with EU deployment and Groq cut latency to about 400ms
Who Should Read
A backend developer building voice agents on Vapi or ElevenLabs who is struggling with response latency
Core Mechanics
- Turn-taking is the hard part
- When the user starts talking, you must instantly cancel LLM generation, TTS, and buffered audio.
- When they stop, you must start responding with minimal delay.
- VAD alone isn't enough
- VAD (voice activity detection) only says whether speech is present, not whether the thought is finished.
- A slow speaker pausing mid-sentence gets interrupted too early.
- Deepgram Flux handled turn detection
- Flux does transcription and turn detection in one model and emits start-of-turn and end-of-turn events.
- On end of turn, the pipeline streams LLM to TTS to Twilio audio.
- Warm TTS sockets saved about 300ms
- Opening a new WebSocket to ElevenLabs adds a few hundred milliseconds.
- Keeping a pool of pre-connected sockets cut roughly 300ms.
- Local ~1.7s became ~790ms on EU deploy
- Running locally from southern Turkey averaged 1.6s on the server, about 1.7s including Twilio's edge.
- Deploying on Railway EU with EU endpoints for Twilio, Deepgram, and ElevenLabs gave ~690ms server-side, ~790ms with the edge.
- That beat Vapi's ~840ms estimate for the same configuration by about 50ms.
- Groq llama-3.3-70b gave ~400ms
- A test of 360 completions measuring first-token latency showed Groq models well ahead of OpenAI models.
- After swapping from gpt-4o-mini, end-to-end latency averaged ~400ms with first audio often under 500ms.
- The author says TTFT (time to first token) accounts for more than half of total latency.
Community Reactions
- An ex-Alexa commenter's experience
- They say the median gap between human speakers is 0ms and almost no Alexa response is under 500ms.
- They say end-of-turn used to be 300ms of silence, and moving processing closer to users was a huge unlock.
- Opinion that the 2x claim isn't apples to apples
- The commenter notes the author's pipeline has no tool calls, webhooks, recording, or multi-tenant routing.
- Vapi does more work per turn, so the workloads differ.
- Production experience with barge-in pitfalls
- One commenter says switching from fixed silence thresholds to semantic end-of-turn detection was night and day.
- They had a bug where a barged-in appointment confirmation still triggered the downstream booking pipeline.
- They say callers in India hitting US-East pay 150-250ms for the Twilio edge hop alone.
- View that STT→LLM→TTS is a dead end
- One commenter argues useful tasks will need end-to-end trained models.
- Another reports that the open-source smart-turn-v3 waits indefinitely on anything but short, clear sentences.
How to Apply
- Measure TTFT per candidate model today
- Send a streaming request to each candidate LLM and cancel as soon as the first token arrives, logging the time.
- Repeat many times, compare averages, and shortlist the lowest-TTFT models.
- Co-locate all services in one region
- Check the region settings for your orchestration server, STT, TTS, and telephony.
- Switch to same-region endpoints and re-measure server-side latency.
- Keep a pool of warm TTS connections
- Pre-connect a few TTS WebSockets before a turn starts.
- Take one from the pool at response time instead of opening a new connection.
- Propagate barge-in cancellation everywhere
- Write one function that cancels LLM generation, TTS, and outbound audio buffers together when the user starts speaking.
- Invalidate downstream actions like booking confirmations on cancel.
Try It
# Paste into Claude or ChatGPT (simplified version of the post's method: latency bottleneck diagnosis)
You are an expert in real-time voice agent latency optimization.
Here is our voice agent setup.
- Telephony: {{telephony provider and region}}
- STT/turn detection: {{STT provider and region}}
- LLM: {{model name, hosting location}}
- TTS: {{TTS provider and connection method}}
- Orchestration server location: {{server region}}
- Measured latency: {{e.g. average 1.6s}}
Answer in this order.
1. List each stage from the moment the user stops speaking to the first audio played.
2. Rank the slowest stages and suggest one fix each. Always check region, TTFT, streaming pipeline, and TTS connection reuse.
3. Make a checklist of everything to cancel on barge-in.Terminology
Related Papers
A Beginner's Guide to Local AI with Inkling, Qwen, and Unsloth
Install Unsloth Desktop, load a quantized Qwen model, and share a private ChatGPT-like AI on your home LAN.
Muru – AI-assisted Rust server for Python apps by mod_WSGI's creator
mod_wsgi's creator is building Muru, an AI-assisted Rust ASGI/WSGI server, documenting it in public
87% of the Anthropic power will come from gas and 11% from coal in 2028
Analysis of Anthropic's contracted data centers: 87% gas, 11% coal power in 2028
Anthropic’s Nasdaq debut
Anthropic listed on Nasdaq and closed its first day below its opening price.
OpenAI still has a WebRTC Problem
WebRTC drops late audio, hurting voice AI; MoQ retransmits and buffers instead
Gemini 4 Neon
Gemini 4 Neon cuts cost per task 32% versus Carbon, at $3 input and $15 output per million tokens
AI is killing All About Berlin
After Google AI Overviews, a Berlin guide site lost 70-75% of its traffic.
Not Everything Needs an LLM
PostHog used small decision models to skip 98.7% of expensive LLM calls
Related Resources
- https://www.ntik.me/posts/voice-agent
- https://github.com/NickTikhonov/shuo
- https://github.com/acatovic/ova
- https://soniox.com/docs/stt/rt/endpoint-detection
- https://www.daily.co/blog/benchmarking-stt-for-voice-agents/
- https://github.com/jdarpinian/chirpy
- https://danluu.com/latency-mitigation/
- https://github.com/cjpais/Handy
- https://github.com/dograh-hq/dograh
- https://flux.deepgram.com/
- https://news.ycombinator.com/item?id=46946705