By Sagar Shankaran, Founder of CallSphere
Deno Deploy ships TypeScript voice bridges to 35 edge regions in seconds. Real working code for Deno.serve, WebSocket subprotocol auth, and global low-latency.
Key takeaways
TL;DR — Deno's standards-based runtime + 35-region Deploy edge = sub-200ms cold start voice bridges anywhere. Same WebSocket API as the browser; ship the same code to backend and edge.
A Deno HTTP server that upgrades browser sockets, opens a paired Realtime socket using the WebSocket subprotocol auth pattern (browser-like envs can't set headers), and runs on Deno Deploy's global edge with zero config.
:8000).OPENAI_API_KEY saved as a Deno Deploy env var.deno_kv if you want session persistence (built-in).flowchart LR
B[Browser anywhere] -- ws --> E[Deno Deploy edge nearest user]
E -- ws --> O[OpenAI Realtime]
Deno.serve with WebSocket upgrade```typescript Deno.serve({ port: 8000 }, (req) => { const url = new URL(req.url); if (url.pathname !== "/voice") return new Response("nf", { status: 404 }); if (req.headers.get("upgrade") !== "websocket") { return new Response("expected websocket", { status: 400 }); } const { socket, response } = Deno.upgradeWebSocket(req); attach(socket); return response; }); ```
In Deno (and browsers), you can't set arbitrary headers on a WebSocket. OpenAI accepts auth via the subprotocol array:
```typescript function openOAI() { const key = Deno.env.get("OPENAI_API_KEY")!; return new WebSocket( "wss://api.openai.com/v1/realtime?model=gpt-4o-realtime-preview-2025-06-03", [ "realtime", `openai-insecure-api-key.${key}`, "openai-beta.realtime-v1", ], ); } ```
(Note: in production, prefer minting an ephemeral key from a secured handler instead of putting the API key in the subprotocol — but the subprotocol pattern is what unlocks Deno/edge for Realtime.)
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
```typescript function attach(client: WebSocket) { const oai = openOAI(); let oaiOpen = false; const queue: string[] = [];
oai.onopen = () => { oaiOpen = true; oai.send(JSON.stringify({ type: "session.update", session: { instructions: "You are CallSphere's edge agent. Reply in 1-2 sentences.", voice: "alloy", turn_detection: { type: "server_vad", threshold: 0.5 } } })); while (queue.length) oai.send(queue.shift()!); };
oai.onmessage = (e) => client.readyState === 1 && client.send(e.data as string); oai.onclose = () => client.close();
client.onmessage = (e) => { const t = typeof e.data === "string" ? e.data : ""; if (!t) return; if (oaiOpen) oai.send(t); else queue.push(t); }; client.onclose = () => oai.close(); } ```
Move auth out of the subprotocol entirely:
```typescript async function mint() { const r = await fetch("https://api.openai.com/v1/realtime/sessions", { method: "POST", headers: { "Authorization": "Bearer " + Deno.env.get("OPENAI_API_KEY"), "Content-Type": "application/json", }, body: JSON.stringify({ model: "gpt-4o-realtime-preview-2025-06-03", voice: "alloy", }), }); return (await r.json()).client_secret.value as string; } ```
Hand that key to the browser; the browser then connects WebRTC directly to OpenAI. Your edge function only does auth + token issuance.
```bash deno deploy --project=callsphere-voice-edge ./server.ts ```
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.
Deno Deploy automatically replicates to 35 regions; users get the nearest pop. Cold start is typically <50ms.
```typescript const kv = await Deno.openKv(); async function bumpUsage(userId: string) { await kv.atomic() .sum(["usage", userId, new Date().toISOString().slice(0, 10)], 1n) .commit(); } ```
headers on WebSocket — Deno honors them only outside Deploy; on edge use subprotocol or ephemeral keys.CallSphere's edge marketing experiments (lead-gen voice landing pages — see /affiliate for our 22% partner program) run on Deno Deploy in front of our healthcare FastAPI :8084 cluster. 37 agents, 6 verticals — and the edge layer adds <40ms.
Why Deno over Node? First-class TypeScript, no node_modules, web-standard APIs.
Does Deno KV scale? Built on FoundationDB; tens of millions of ops/day, fine for session state.
Can I run Pipecat on Deno? Pipecat is Python; pair Deno frontend with Modal Python backend.
Cold start? ~30ms typical, <100ms p99.
Pricing? Free tier covers ~1M req/mo; paid is usage-based.
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.
Haystack 2.7's Agent component plus an Ollama-served Llama 3.2 gives you tool-calling RAG with citations. Here's a complete pipeline against your own document store.
Run STT, LLM, and TTS entirely on Cloudflare's edge — no OpenAI, no ElevenLabs. Real working code with Whisper, Llama 3.3 70B, and Deepgram Aura.
On May 4 2026 OpenAI published its Realtime stack rebuild — split-relay plus transceiver edge. Here is what changed and what it means for production voice agents.
Version your prompts in git, run a 50-case eval suite on every PR, block merges below threshold, and ship a new agent prompt with confidence — full GitHub Actions tutorial.
Replace expensive outbound SDR tooling with a self-hosted dialer that runs OpenAI Realtime agents at 100 concurrent calls. Full architecture and code.
Each Cloudflare agent runs on a Durable Object with its own SQLite, WebSockets, and scheduling. Agents Week 2026 shipped MCP, Code Mode, and 10GB SQLite per agent.
© 2026 CallSphere LLC. All rights reserved.
Watch how CallSphere handles real customer calls, schedules appointments, and processes payments — live.
Try Live DemoBook a DemoCalculate Your ROI