AI Voice Assistant API Guide: Build Voice Apps in 2026
Published 2026-08-16 · 2,031 words · 8 min read
Voice is the interface users have been waiting for AI to catch up to. Every major platform now ships voice: support lines that resolve issues by conversation, doctors who dictate notes to AI scribes, in-car assistants that actually understand context, and language learners practicing with a patient bot. The ingredients are all APIs: a speech-to-text (STT) service to hear, a large language model to think, and a text-to-speech (TTS) service to speak. The craft is in the pipeline — latency budgets, streaming, interruption handling, and cost — that turns three APIs into something that feels like talking to a person. This guide covers the full architecture: choosing STT and TTS APIs, wiring the LLM in the middle, hitting real-time latency targets, going multilingual, and budgeting the per-minute cost.
The Voice Pipeline: Three APIs, One Conversation
A voice assistant is a loop, not a call:
User speaks
→ [STT API] audio → text
→ [LLM API] text → response text
→ [TTS API] text → audio
→ User hears
(repeat — and listen for interruption while speaking)
Each stage adds latency and cost, and each has its own failure modes: STT mishears, the LLM rambles, TTS clips or sounds robotic. The design goal is a total response time under one second for the response to start, and under three seconds for it to complete — beyond that, humans perceive the assistant as slow or broken. That budget shapes every technology choice below.
Two architectural variants matter:
- Turn-based (press-to-talk or wake-word): the simpler model. Record a full utterance, send it to STT, get the LLM response, play TTS. Latency budget is relaxed (2-4s is acceptable). Most production assistants start here.
- Full-duplex streaming: audio streams continuously in both directions, the assistant can interrupt (barge-in), and turn-taking is automatic. This is the "wow" experience and the engineering-hard version — WebSocket or WebRTC based, with strict latency budgets.
Start turn-based, then add streaming once the quality and cost story is proven. Most of the value is in the first version.
Choosing a Speech-to-Text API
STT quality is the ceiling of your whole assistant — if it mishears, no LLM cleverness can save the conversation. What to compare:
| API | Strengths | Watch out for |
|---|---|---|
| OpenAI Whisper API (or self-hosted Whisper) | Excellent accuracy, 90+ languages, timestamped segments, low cost per minute | Latency on long files; streaming via the API is limited — self-host for real-time |
| Deepgram Nova | Real-time streaming, very low latency (200-400ms), punctuation and diarization built in | Per-minute pricing higher than Whisper; some features require higher tiers |
| Google Speech-to-Text | Mature, 125+ languages, strong on noisy audio, speaker diarization | Pricing and rate limits on large scale; V2 API complexity |
| Azure Speech | Enterprise SLAs, hybrid (cloud + edge) options, strong Chinese/Japanese support | Configuration surface is large; costs add up with custom models |
| AssemblyAI | Great DX, entity detection, sentiment, summarization built in | Higher per-minute cost; less flexible for self-hosting |
Selection rules that matter more than benchmark scores:
- Test with your actual audio. Accents, background noise, domain vocabulary (medical terms, product names) shift rankings dramatically. Record 20 real utterances and run them through every candidate.
- Check streaming support early. If you plan full-duplex, an STT without a streaming endpoint is a dead end regardless of accuracy.
- Word timestamps are not optional. You need them for wake-word detection feedback, barge-in, and highlighting what the model heard.
- Custom vocabulary. If your domain has rare terms, look for hotword/phrase boosting — it saves hours of prompt-level compensation later.
Choosing a Text-to-Speech API
TTS determines whether users describe the assistant as "pleasant" or "creepy." The 2026 landscape:
| API | Strengths | Watch out for |
|---|---|---|
| OpenAI TTS (tts-1, gpt-4o-mini-tts) | Natural voices, simple API, voice-design instructions | Limited voice control; streaming latency historically higher |
| ElevenLabs | Best-in-class realism, voice cloning, 30+ languages, streaming | Most expensive per character; cloning raises consent/compliance questions |
| Azure Neural TTS | 140+ voices, 90+ languages, SSML control, custom neural voice | Steeper learning curve; some voices sound more "broadcast" than natural |
| Google Cloud TTS | Wavenet/Neural voices, cheap, strong non-English voices | Voice quality behind ElevenLabs on English casual speech |
| Amazon Polly / Bedrock TTS | Enterprise integration, neural voices, SSML | Mid-pack realism; fine for IVR, less for consumer apps |
Three practical decisions beyond demo quality:
- Latency to first audio. For real-time feel, you want the first audio chunk in under 400ms. Test with short sentences — some APIs buffer the whole sentence first.
- Streaming support. Sentence-by-sentence TTS streaming lets the assistant start speaking while the LLM finishes the next sentence — a huge perceived-latency win.
- Voice consistency. One voice per assistant, everywhere. Voice cloning (with proper consent) or careful voice selection prevents the "different person every session" problem.
The LLM in the Middle: Conversation State and Tools
The LLM layer is where your assistant becomes useful. For voice specifically:
- Keep responses short. Voice is not a document channel — instruct the model for 1-3 sentence replies unless the user asks for detail. Long LLM answers are the #1 perceived-latency killer in voice apps.
- Stream the LLM output into TTS. Feed completion tokens to TTS as they arrive (sentence-buffered) so speech starts before the response finishes. This hides 30-50% of LLM latency.
- Function calling for real actions. The assistant earns trust by doing: booking, searching, updating records. Wire the same function-calling patterns you'd use in chat, and always confirm destructive actions out loud.
- Persist conversation state server-side. Voice sessions are short and fragmented — "book the same table for Friday" needs the previous turn's context. Keep a session store; don't rely on the model's context window alone.
- Handle recognition errors gracefully. Add a "did you mean?" confirmation path for critical intents. Better to confirm than to book the wrong flight.
Model choice matters less than prompt discipline here: a fast small model with tight voice-specific instructions usually beats a large reasoning model that answers in paragraphs. See our model routing guide for matching models to utterance complexity.
The Latency Budget: Engineering the One-Second Response
Perceived quality in voice is a latency game. The budget for a snappy turn-based assistant:
| Stage | Target | How to hit it |
|---|---|---|
| Audio capture end → STT result | 300-600ms (streaming) | Stream audio during speech; use an STT with partial results |
| STT → LLM first token | 300-800ms | Small fast model; pre-warmed connections; keep context small |
| LLM → TTS first audio | 200-400ms | Sentence-buffered streaming; pre-connect TTS session |
| Total to first audible response | < 1.5s | Everything above, plus good network (WebSocket, not polling) |
Techniques that buy back latency:
- Early partial results. Show/act on STT partials; the user hears "let me check" while the LLM works.
- Pre-warming. Keep persistent connections to STT, LLM, and TTS. Connection setup is 100-300ms you can eliminate entirely.
- Prompt compression. Trim system prompts and history for voice — shorter prompts = faster first tokens. Our latency optimization guide has the full toolkit.
- Cache common responses. "What can you do?" and other frequent intents can skip the LLM entirely.
Measure per-stage latency in production from day one — voice apps degrade silently as traffic grows, and per-stage metrics are the only way to catch it. The observability guide covers the monitoring setup.
Real-Time Voice: Streaming Architecture (WebSocket)
For full-duplex voice, the standard production architecture looks like this:
Browser/App (Web Audio API, getUserMedia)
│ WebSocket (audio up, audio down)
▼
Gateway (your backend)
├── STT stream (client audio → partial text)
├── LLM (partial text + context → streamed response)
└── TTS stream (response text → audio frames down)
│
└── Barge-in: client audio level detection cuts TTS playback,
sends "interrupt" event, LLM regenerates with new context
Implementation notes that separate working demos from production systems:
- Audio format discipline. Agree on sample rate (16kHz mono is the STT standard) and codec (PCM or Opus) end-to-end. Format mismatch is the most common silent bug in voice pipelines.
- Voice activity detection (VAD). Detect speech start/end client-side or in the gateway to segment turns. Without VAD, silence gets transcribed and the LLM answers empty input.
- Barge-in handling. When the user speaks during TTS playback: stop playback, cancel in-flight LLM generation, and re-enter the STT loop with the new utterance. This single feature is what makes assistants feel human.
- Backpressure and buffering. Network jitter kills voice UX. Buffer 100-200ms of audio and tolerate drops rather than stalling the stream.
- Fallback to turn-based. If streaming degrades (poor network, high gateway load), downgrade gracefully to press-to-talk instead of failing. Our streaming in Python guide has working SSE/WebSocket code patterns.
Multilingual Voice: One Assistant, Many Languages
Voice assistants get multilingual more cheaply than text products because the pipeline can mix and match:
- STT: Whisper-class models handle 90+ languages; Deepgram and Google cover 100+. Language auto-detection lets one endpoint serve all users.
- LLM: modern models answer fluently in 50+ languages. Prompt in the user's language (or instruct: "respond in the user's language") and keep the system prompt bilingual-safe.
- TTS: this is the constraint. ElevenLabs, Azure, and Google each cover 30-140 voices across languages, but quality varies per language — test the languages you actually serve rather than trusting the marketing matrix.
Two production rules: route per language (a language-detection pass can pick the best STT/TTS pair per call — the cheapest per-language provider usually wins), and test code-switching — users mixing languages mid-sentence is common in real traffic and breaks naive pipelines.
The Cost Model: Per-Minute Economics of Voice
Voice is more expensive per interaction than chat because audio is charged by the minute on top of tokens. A realistic budget model for a turn-based assistant:
| Component | Typical price | Per 2-minute call |
|---|---|---|
| STT | $0.006-0.012 / minute (Whisper ~$0.006) | $0.012-0.024 |
| LLM (small model, ~400 tokens in/out) | $0.10-0.60 / M tokens | $0.0002-0.0008 |
| TTS | $0.015-0.30 / 1k chars (≈ 150 words/min) | $0.005-0.09 |
| Total per minute of conversation | ≈ $0.01-0.06 / min |
Cost control levers, in order of impact:
- Don't transcribe silence. VAD-gated STT cuts the biggest waste — users pause, think, and backchannel constantly.
- Keep LLM replies short. Every extra sentence costs tokens and TTS characters and latency. Voice-specific prompting pays three times.
- Use the cheapest adequate model per turn. Route simple turns to a mini model, complex ones to a bigger model.
- Cache. FAQs and intents with deterministic answers skip both LLM and TTS (pre-render the audio).
- Negotiate volume. At scale, STT/TTS providers discount 20-40% — ask. And compare gateway pricing: an aggregator like DrAI gives you per-model pricing transparency so you can route voice workloads to the cheapest healthy provider automatically.
Compliance Notes for Voice Data
Audio is sensitive data with extra obligations:
- Consent and disclosure: record and process audio only with clear disclosure — many jurisdictions require consent for recording, and AI processing must be disclosed regardless.
- Minimize retention: transcribe → act → delete the audio as soon as the transcription is complete, unless your product needs the recording. Retention of raw audio is the most common compliance failure in voice products.
- Vendor data handling: verify your STT/TTS providers' retention and training policies — see our LLM data privacy guide for the checklist that applies to audio too.
- Biometric caution: voiceprints and voice cloning are regulated biometric data in several jurisdictions. If you clone voices (even a user's own), document consent and purpose carefully.
Voice Assistant Launch Checklist
- Record 20-50 real utterances and benchmark 3 STT candidates on accuracy and latency
- Pick a TTS provider and voice; verify first-audio latency with short sentences
- Start turn-based; design the API so streaming can be added without client changes
- Set the one-second latency budget and instrument each stage from day one
- Add VAD, barge-in, and graceful degradation before the public launch
- Keep LLM replies short with voice-specific prompting and function calling
- Test your real language mix — including code-switching — before launch
- Build the per-minute cost model and set alert thresholds per user and per day
- Document audio consent, retention limits, and provider data handling
- Monitor per-stage latency and error rates in production continuously
Voice is the highest-engagement interface for AI, and the APIs are mature enough that the differentiator is pipeline engineering — latency, interruption handling, and cost control — not magic. DrAI's gateway powers the LLM layer with 40+ models behind one OpenAI-compatible API, with per-key usage tracking to keep your voice cost model honest. Start building at sign in, and check pricing for plans that fit voice traffic patterns.
Start Building with DrAI Today
One OpenAI-compatible API key for GPT-5, Claude Opus 4, DeepSeek, Qwen, Llama and 40+ models — pay-as-you-go with no monthly fees.