Real-time Voice AI Guide 2025: OpenAI Realtime API
Real-time Voice AI allows users to converse with an AI seamlessly, with the AI responding in less than a second—mimicking a real human phone call.
PART 1: THE LATENCY PROBLEM
Traditional Pipeline (Multi-step format):
- User Speaks -> Whisper STT (Takes 1-2 seconds).
- Text -> ChatGPT LLM (Takes 1-2 seconds to generate text).
- Text -> ElevenLabs TTS (Takes 1-2 seconds to generate audio). Total Latency: 3 to 6 seconds. This unnatural delay ruins the conversational experience.
The Real-time Solution (Single-step):
OpenAI's Realtime API entirely skips the text generation phase. It takes raw audio in, and physically outputs raw audio out. Total Latency: ~300ms (Faster than a human).
PART 2: OPENAI REALTIME API
Launched in late 2024, the Realtime API uses WebSockets to maintain a persistent connection.
Key Features:
- Speech-to-Speech: Direct audio modeling.
- Interruption: If the AI is talking and you interrupt it by speaking, it instantly stops talking and listens to you.
- Function Calling: The AI can trigger backend functions (like checking the weather or booking a calendar slot) mid-conversation.
Pricing (It's Expensive):
- Input audio: $100 per 1M tokens (~$0.06/minute).
- Output audio: $200 per 1M tokens (~$0.12/minute).
- Total cost: roughly $0.18 per minute of conversation.
An automated 10-minute customer support call will cost almost $2.00.
PART 3: BUILDING A CUSTOM PIPELINE (CHEAP ALTERNATIVE)
If $0.18/minute is too expensive, you must build a highly optimized multi-step pipeline.
The Modern Fast Stack:
- STT: Deepgram Nova-2 (Costs $0.0043/min, Latency ~300ms).
- LLM: Groq running Llama-3 (Free, generates 800 tokens per second).
- TTS: ElevenLabs Turbo v2 using WebSockets (Costs $0.15/1K chars, Latency ~400ms).
By chaining these specific blazing-fast APIs together, you can achieve a total conversational latency of ~1 second at a fraction of OpenAI's cost.
PART 4: BEST PRACTICES FOR VOICE BOTS
1. Endpointing (Voice Activity Detection - VAD)
The hardest part of voice AI is knowing when the user has finished speaking. If you cut them off too early, the bot is annoying. If you wait too long, the bot feels laggy. Use a tool like Silero VAD to accurately detect milliseconds of silence before triggering the LLM.
2. Prompting a Voice Bot
A voice model must be prompted differently than a text chat model.
- Instruction: "Keep responses extremely concise. Under 2 sentences. Use conversational filler words like 'umm' or 'hmm' occasionally. Never use markdown, bullet points, or complex formatting."
3. Handling Interruptions
You must constantly monitor the microphone. If the microphone detects user speech (volume spikes) while your TTS engine is playing, you must instantly terminate the TTS audio playback stream and clear the LLM's context buffer.
CONCLUSION
Conversational AI is the final frontier of app interfaces.
- If you are building an expensive high-end B2B sales bot, use the OpenAI Realtime API for the perfect latency.
- If you are building a B2C language learning app or customer support bot, build a Deepgram + Groq + ElevenLabs pipeline to keep unit economics sustainable.
Share
Get our newsletter
Weekly AI & Tech updates