How WebRTC Works, Explained Simply
What WebRTC is and why voice agents use it: the four steps of a call (signaling, STUN and TURN routing, encryption, audio), explained simply.
Part of Voice AI Explained. See every episode, in learning order, in How Voice AI Works: A Complete Guide.
Summary
What is WebRTC?
WebRTC is a free toolkit built into major web browsers that enables live transmission of voice, video, and data between devices. For voice AI agents, WebRTC prioritizes speed over perfection. Unlike other web technologies that pause to wait for missing data packets, WebRTC skips lost pieces to maintain a natural conversation flow, as brief gaps are less disruptive than frozen pauses.
The Four Steps of a WebRTC Call
- Swap Contact Cards (Signaling): The two devices exchange contact cards containing supported audio formats, potential connection addresses, and security codes. This exchange typically happens through a signaling server.
- Find a Route: Since most devices sit behind firewalls or routers, they use a STUN server to discover their public addresses and establish a direct connection. If firewalls are too strict, a TURN server acts as a middleman to relay the audio.
- Lock It (Encryption): All transmitted data is permanently encrypted. Security codes from the contact cards verify that the connection is secure and connected to the correct device. While a TURN relay cannot hear the encrypted audio, a media hub server can unless end-to-end encryption is implemented.
- Talk: Audio is split into small pieces (typically 50 per second). The receiving device uses a jitter buffer to smooth out playback. Additionally, the browser performs echo cancellation and noise reduction to prevent the AI agent from hearing its own voice and interrupting itself.
AI Integration
The AI agent can connect directly to the browser or through a central hub called an SFU (Selective Forwarding Unit). Common frameworks and services utilizing WebRTC for voice AI include Daily (Pipecat), LiveKit, and OpenAI's Realtime API.
Full transcript
Talking to a voice agent in your browser feels like a phone call, but there's no phone line. Your voice crosses the internet in tiny pieces, and it has to arrive fast enough to feel like a conversation. Very often, the technology doing this is called WebRTC. Today: what it does, in plain words.
WebRTC is a free toolkit built into every major browser. It lets two devices send voice, video, and data to each other, live. You've probably used it already: many video calls in the browser run on it. For a voice agent, one side is you, the other side is the AI.
Here's the big idea. Imagine someone reading you a letter, page by page. If page 3 gets lost, the careful way is to stop and wait for it before reading page 4. That's how most of the web works, including WebSockets, a common way to stream data. But in a live conversation, waiting is worse than a tiny gap. So for voice, WebRTC takes the fast way: if a piece is lost, skip it and keep talking. A missing 50th of a second is barely noticed; a frozen pause is. That's why OpenAI and PipeCat both recommend WebRTC for voice in browser and mobile apps.
Now, how does a WebRTC call start? In four steps.
Step 1: the two sides swap contact cards. Each card says which audio formats that side understands, where it might be reached, and a security code. This step is called signaling. WebRTC doesn't care how the cards travel—usually through a server, yours or your provider's.
Step 2: find a route. Most devices sit behind a router or a firewall, like an apartment building with a front desk. Strangers can't just walk in. So WebRTC asks a helper outside, called a STUN server: "What's my address from out there?" Often, that's enough to connect directly. When the building is too strict, a TURN server acts as a middleman. Both sides send their audio to it, and it passes it along. WebRTC tries the possible routes and keeps the most direct one that works.
Step 3: lock it. Your audio, video, and data are always encrypted, and that can't be turned off. The security code from the contact cards checks you're talking to the right device, as long as the cards were delivered safely. One honest caveat: a TURN relay only passes the locked audio along—it can't hear it. But a server that handles your audio, like a hub that shares it with others, can still hear it unless you add end-to-end encryption.
Step 4: talk. Your voice is cut into small pieces, usually 50 per second. They don't all arrive at the same pace, so the receiver keeps a tiny waiting line and plays them back smoothly. The browser can also clean your microphone, reducing background noise and echo. Echo matters for agents. Without that cleaning, the agent can hear its own voice through your speakers, think you're talking, and interrupt itself.
So where does the AI sit? On a server. Either your browser connects straight to it, or everyone connects to a hub that passes the audio around, including to the agent. That hub is called an SFU. A few examples, in alphabetical order, not a ranking: Daily, which maintains the open-source framework PipeCat; LiveKit, whose open-source server and agent framework let an agent join a room just like a person; and OpenAI's Realtime API, which accepts WebRTC connections straight from the browser.
So to recap: swap contact cards, find a route, lock it, talk. And the big idea: for live voice, speed beats perfection. Want the details? WebRTC for the Curious is a free, open-source book that goes much deeper. The link is in the description.
Next time: phone calls and how they reach an AI agent. If we got something wrong, tell us—corrections get pinned. And you'll find voice AI products, sorted by role, in the Voice AI Space library.
Related Content

Noise and Echo in Voice Agents, Explained

How Voice Agents Use Tools Mid-Call

How Speech-to-Speech AI Models Work

On-Device Voice AI: What Runs Locally

Speaker Diarization Explained

Build or Buy a Voice AI Agent?

Is Your AI Voice Agent Legal? 5 Rules

Voice AI Agent Cost Per Minute (2026)