Deno
Serve the pipedog WebRTC offer and WebSocket endpoints with Deno.serve.
Deno.serve routes both endpoints. socket is a fetch handler, and Deno upgrades a WebSocket from
fetch, so the upgrade uses Deno.upgradeWebSocket under the hood.
Install
deno add npm:@pipedog/core npm:@pipedog/asyncio npm:@pipedog/transport-smallwebrtc npm:@pipedog/transport-websocket npm:@pipedog/serializer-protobuf npm:@pipedog/openai npm:@pipedog/audio-silero npm:@pipedog/audio-smart-turn@pipedog/audio-smart-turn isn't imported anywhere: the default turn strategies load it. To run
the snippet from a checkout instead, see Installation.
Files
The endpoints come from the shared module on the overview.
voice.ts re-exports it:
export { offer, runSocketAgent, socket } from "../shared/voice.ts";
import { offer, socket } from "./voice.ts";
// `deno run -A main.ts` starts it on port 3000, or on $PORT.
Deno.serve({ port: Number(Deno.env.get("PORT") ?? 3000) }, (request) => {
const { pathname } = new URL(request.url);
if (pathname === "/api/offer") return offer(request);
if (pathname === "/ws") return socket(request);
return new Response("not found", { status: 404 });
});
Run it
OPENAI_API_KEY=sk-... deno run -A main.tsIt listens on port 3000, or on $PORT. The offer is at POST /api/offer and the WebSocket at /ws.
Deploy
Run it as a long-lived Deno process on a host that allows UDP traffic, for the offer's media. A host
that runs Deno without UDP can still serve socket.
Authentication
Neither route has auth. Check the session in the Deno.serve handler before either endpoint runs,
as in Authentication.
pipedog is an unofficial community TypeScript port of Pipecat. It is not affiliated with or endorsed by Daily or the Pipecat project.
Portions adapted from the Pipecat documentation, Copyright (c) 2024–2025 Daily, BSD-2-Clause (see apps/docs/LICENSE-pipecat-docs).