How a Real-Time Voice AI Agent Works
The turns of a call
A call is a loop of turns. Each turn goes through six steps:
- The client, in a browser or a mobile app, captures the microphone and runs voice activity detection (VAD) to tell when the user is speaking. Audio leaves the browser only during speech.
- A WebSocket carries that audio to your Node.js server. Your provider API keys stay on the server, so the browser never needs a session token.
- Speech to text (STT) transcribes the audio as it arrives.
- When the user stops speaking, the LLM writes the answer.
- Text to speech (TTS) turns the answer into audio while the LLM is still writing it. The server streams that audio to the browser, which plays it.
- When the user speaks over the answer, the client stops playback and the server cancels the LLM and the TTS.
Interruptions and echo
Interruptions need echo cancellation. Without it, the microphone picks up the assistant’s voice. If interruptions stayed on, the assistant would answer itself, so Micdrop turns them off. The browser’s echo cancellation usually removes the assistant’s voice from the microphone signal. With headphones, that voice never reaches the microphone.
Realtime models
A realtime speech to speech model, such as the OpenAI Realtime API or Gemini Live, can replace speech to text, the LLM and text to speech on its own. It answers sooner and hears the tone of the voice. With three separate providers, you choose each one and often pay less per minute. Micdrop lets you switch a call to a realtime model on the server and keep the same client code.
Transports
The OpenAI Realtime API and LiveKit connect the browser over WebRTC. Micdrop connects it over a WebSocket to your own backend by default, so you deploy only the server you already run. The same call can also run over WebRTC, which holds up better on weak mobile networks, or answer phone calls through a telephony transport, with the server detecting the turns itself. Transports compares them, and WebSocket or WebRTC weighs the two for group calls, video and phone lines.
Ready for production
Micdrop is MIT licensed and runs on your infrastructure with your own provider keys. You build yourself what a hosted platform includes: transcript storage, call history and a dashboard.
- Metrics time each turn and count what it consumed, OpenTelemetry traces send them to Langfuse, Jaeger or any OTLP backend, leveled logs carry the context of the call, and a devtools panel shows each turn in the browser.
- The reliability scenarios a call survives run on every change, next to a load test of 1000 calls in one process.
- Simulated calls test the agent in text or audio, with simulated callers and judges, in any test runner.
- Phone calls transfer to a person, read the keypad, go outbound with voicemail detection, and get noise suppression on the line.
- The server runs on any Node host or on Cloudflare Workers, with one Durable Object per call. Versioning and stability lists what each package guarantees.