By Sagar Shankaran, Founder of CallSphere
OpenAI's Realtime API speaks both WebRTC and WebSocket. Here is the production playbook CallSphere uses across 37 agents to decide which transport fits which call path.
Key takeaways
OpenAI documents two transports for the Realtime API: WebRTC and WebSocket. The right answer is not "pick one." It is "pick per hop." CallSphere uses WebRTC at the browser edge and WebSocket on every server-to-server hop.
flowchart LR
Mobile[iOS / Android SDK] --> WHIP[WHIP ingest]
WHIP --> Mux[Mux / LiveKit]
Mux --> Brain[AI brain]
Brain --> WHEP[WHEP egress]
WHEP --> Web[Web viewer]The Realtime API exposes `gpt-realtime` (and `gpt-4o-realtime`) over two wire formats. WebRTC is the recommended path for browsers and mobile clients; WebSocket is the recommended path for middle-tier servers running inside controlled networks. The difference is not academic. WebRTC runs over UDP/SRTP with a built-in jitter buffer, AEC, AGC, and noise suppression. WebSocket runs over TCP — every dropped packet stalls the stream while it retransmits, which is fine for tokens but devastating for live audio.
In 2026 the question matters more than ever because most teams have started embedding voice in marketing pages and product UIs, not just in phone systems. A live page-embed running over WebSocket on flaky Wi-Fi sounds like a 1990s VoIP call. The same path over WebRTC sounds like FaceTime.
The peer connection lifecycle for a Realtime call:
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
Where WebSocket wins: server agents that need to mediate tool calls, redact PII, write audit logs, or talk to phone networks. There the server keeps a WebSocket open to OpenAI and bridges audio to whichever transport the user uses.
CallSphere runs both transports in production:
Across 37 agents and 90+ tools we touch 115+ database tables. The ability to keep WebRTC at the user edge while WebSocket carries the controlled-network legs is what lets us claim sub-second perceived latency without giving up SOC 2 controls.
```ts async function startRealtime() { const tokenRes = await fetch("/api/realtime/token"); const { client_secret } = await tokenRes.json();
const pc = new RTCPeerConnection(); const audioEl = document.createElement("audio"); audioEl.autoplay = true; pc.ontrack = (e) => { audioEl.srcObject = e.streams[0]; };
const mic = await navigator.mediaDevices.getUserMedia({ audio: true }); pc.addTrack(mic.getAudioTracks()[0]);
Still reading? Stop comparing — try CallSphere live.
CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.
const dc = pc.createDataChannel("oai-events"); dc.onmessage = (e) => console.log("event", JSON.parse(e.data));
const offer = await pc.createOffer(); await pc.setLocalDescription(offer);
const res = await fetch("https://api.openai.com/v1/realtime?model=gpt-realtime", { method: "POST", body: offer.sdp, headers: { Authorization: `Bearer ${client_secret}`, "Content-Type": "application/sdp" }, }); await pc.setRemoteDescription({ type: "answer", sdp: await res.text() }); } ```
Can I run both at once? Yes. CallSphere uses WebRTC client-side and WebSocket server-side; they connect to the same model. Does WebRTC work on iOS Safari? Yes since iOS 11, and Safari 26.4 (March 2026) ships first-party WebTransport too. What about telephony? Phone calls hit our SIP gateway, which bridges into a WebSocket Realtime session. Browser callers stay on WebRTC. Do I still need TURN? Yes — about 8–10% of users live behind symmetric NATs that fail STUN. How long is a session? OpenAI caps Realtime sessions at 30 minutes; renew before that.
Try the WebRTC path live on our /demo, see the bundle in /pricing, or start a /trial.
Written by
Sagar Shankaran· Founder, CallSphere
Sagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
A founder's guide to texto a voz (text-to-speech in Spanish): LATAM vs Castilian voices, free options, and how CallSphere ships Spanish agents.
A founder's guide to the female voice generator landscape: AI female voices, Japanese voices, robot voices, and how CallSphere ships 57+ voices live.
A founder's guide to the Siri voice generator landscape: how AI voice cloning works, what is legal, and how CallSphere uses 57+ voices in production.
A founder's guide to AI voice assistants for ecommerce: customer service, order lookup, and how CallSphere fits in versus virtual receptionists.
Robot text to speech in 2026: how I pick TTS APIs, when robotic voices help, and how CallSphere ships 57+ language voice agents. Hands-on guide.
The customer support specialist role in 2026 is half human, half AI. Here is what the job looks like, the AI tools that pair with it, and how we ship it.
© 2026 CallSphere LLC. All rights reserved.