Voice Agents: Pipecat and LiveKit
Voice agents are a first-class production category in 2026. Pipecat gives you a Python frame-based pipeline (VAD → STT → LLM → TTS → transport), and LiveKit Agents bridges AI models to users over WebRTC. Production latency targets land at 450–600ms end-to-end for premium stacks.
Learning Objectives
- Describe Pipecat's frame-based pipeline: DOWNSTREAM (source→sink) and UPSTREAM (control).
- Name the canonical voice pipeline stages and which transports Pipecat supports.
- Explain LiveKit Agents' two voice agent classes (MultimodalAgent, VoicePipelineAgent) and when each fits.
- Summarize 2026 production latency expectations and how they drive architecture choices.
The Problem
A voice agent is not a text loop with TTS bolted on. The latency budget is brutal (~600ms is the edge of a premium stack; 800–1200ms is what most deployments land at), partial audio is the default state, turn detection is itself a model, and the transports range from telephony SIP to WebRTC. You have two real options: build a frame-based pipeline yourself with Pipecat, or lean on a platform like LiveKit.
The Concept
Pipecat (pipecat-ai/pipecat)
Pipecat is a Python framework for building voice pipelines out of frames. A Frame is a typed unit of data (audio, a transcript, text), and a FrameProcessor is a stage that consumes frames and emits new ones. Chain processors together and you have a pipeline.
Frames travel in two directions:
- DOWNSTREAM: source to sink. Audio comes in, TTS audio goes out.
- UPSTREAM: feedback and control, such as cancellation, metrics, and barge-in.
PipelineTask manages the lifecycle through events (on_pipeline_started, on_pipeline_finished, on_idle_timeout) and observers for metrics, tracing, and RTVI.
The typical pipeline looks like this:
VAD (Silero) → STT → LLM (context alternates user/assistant) → TTS → transport
Transports: Daily, LiveKit, SmallWebRTCTransport, FastAPI WebSocket, and WhatsApp.
Two add-ons sit on top. Pipecat Flows adds structured conversations (state machines), and Pipecat Cloud is the managed runtime.
LiveKit Agents (livekit/agents)
LiveKit Agents bridges AI models to users over WebRTC. The key concepts are Agent, AgentSession, entrypoint, and AgentServer.
It ships two voice agent classes, and the choice between them is the main design decision:
- MultimodalAgent: direct audio through OpenAI Realtime or an equivalent. No text sits in the middle.
- VoicePipelineAgent: an STT → LLM → TTS cascade. You get text-level control at every step.
The rest of the feature list: semantic turn detection via a transformer model, native MCP integration, telephony via SIP, and 50+ models with no API keys through LiveKit Inference, with 200+ more via plugins.
Commercial platforms
Vapi (~450–600ms on an optimized premium stack) and Retell (~600ms end-to-end across 180 test calls) build on top of these. Pick a platform when you want a managed voice stack and don't have a WebRTC team.
Where this pattern goes wrong
- No barge-in handling. The user interrupts and the agent keeps talking. Pipecat needs UPSTREAM cancel frames for this, and LiveKit has an equivalent.
- STT confidence ignored. Low-confidence transcripts reach the LLM as if they were gospel. Gate on confidence, or ask the user to confirm.
- TTS mid-sentence cutoff. When the pipeline cancels mid-utterance, TTS has to be told, or it keeps producing audio past the cancel.
- Latency budget ignored. Every component adds 50–200ms. Sum your chain before shipping.
Typical 2026 latencies
- VAD: 20–60ms
- STT partial: 100–250ms
- LLM first token: 150–400ms
- TTS first audio: 100–200ms
- Transport RTT: 30–80ms
End-to-end 450–600ms is premium. 800–1200ms is common. Anything over 1500ms feels broken.
Build It
code/main.py is a toy frame-based pipeline. It has:
Frametypes: audio, transcript, text, tts_audio, and control.- A
Processorinterface withprocess(frame). - Five scripted stages (VAD → STT → LLM → TTS → transport).
- An UPSTREAM cancel frame that demonstrates barge-in.
Run it:
python3 code/main.py
The trace shows normal flow first, then a barge-in cancel that stops TTS mid-utterance.
Use It
- Pipecat when you want full control: custom processors, Python-first, pluggable providers.
- LiveKit Agents for WebRTC-first deployments and telephony.
- Vapi / Retell for hosted voice agents when you have no WebRTC team.
- OpenAI Realtime / Gemini Live for direct audio-in/audio-out (the MultimodalAgent shape).
Ship It
outputs/skill-voice-pipeline.md scaffolds a Pipecat-shaped voice pipeline with VAD, STT, LLM, TTS, and transport, plus barge-in handling.
Get barge-in working before you polish anything else. The failure modes in this lesson (an agent that talks over the user, TTS that keeps going after a cancel, a bad transcript treated as truth) all make a voice agent feel broken. Write down each component's latency cost before you pick a stack, too, because the budget decides your architecture more than any feature list does.
On build versus buy, settle the cascade versus direct-audio question early. If you need to inspect or gate what the model hears, you need the text in the middle, and that means the cascade. If you don't, direct audio removes stages from the chain.
Exercises
- Add a metrics observer to your toy pipeline: count frames per stage per second. Where does latency accumulate?
- Implement confidence-gated STT: below threshold, request "could you repeat that?"
- Add semantic turn detection: simple rule: if transcript ends with "?", end of turn.
- Read Pipecat's transport docs. Swap the stdlib transport for the SmallWebRTCTransport config (stub).
- Measure an OpenAI Realtime vs STT+LLM+TTS cascade on the same query. What latency cost does text-level control carry?
Key Terms
| Term | What people say | What it actually means |
|---|---|---|
| Frame | "Event" | Typed unit of data in the pipeline (audio, transcript, text, control) |
| Processor | "Pipeline stage" | Handler with process(frame) |
| DOWNSTREAM | "Forward flow" | Source to sink: audio in, speech out |
| UPSTREAM | "Feedback flow" | Control: cancel, metrics, barge-in |
| VAD | "Voice activity detection" | Detects when user is speaking |
| Semantic turn detection | "Smart end-of-turn" | Model-based decision that the user is done |
| MultimodalAgent | "Direct audio agent" | Audio in, audio out; no text in the middle |
| VoicePipelineAgent | "Cascade agent" | STT + LLM + TTS; text-level control |
Further Reading
- Pipecat docs: frame-based pipeline, processors, transports
- LiveKit Agents docs: WebRTC + voice primitives
- Vapi: managed voice platform
- Retell AI: managed voice, latency-benchmarked
Code
- main.py (python, 158 lines)