SvelteKit
Mount the pipedog WebRTC offer endpoint in a SvelteKit +server.ts route.
A +server.ts route handles POST /api/offer. SvelteKit hands the route a web Request, so the
route passes it to offer unchanged.
Install
bun add @pipedog/core @pipedog/asyncio @pipedog/transport-smallwebrtc @pipedog/transport-websocket @pipedog/serializer-protobuf @pipedog/openai @pipedog/audio-silero @pipedog/audio-smart-turn @sveltejs/kit@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.
$lib/voice re-exports it:
export { offer, runSocketAgent, socket } from "../../../shared/voice.ts";
import type { RequestHandler } from "@sveltejs/kit";
import { offer } from "$lib/voice";
// Use adapter-node (or any Node, Bun or Deno server): the media runs over UDP,
// which serverless adapters don't carry.
export const POST: RequestHandler = ({ request }) => offer(request);
In your app, put shared/voice.ts and shared/agent.ts in src/lib/ and drop the re-export.
Run it
OPENAI_API_KEY=sk-... bunx vite devThe browser then POSTs its SDP offer to /api/offer.
Deploy
Use an adapter that runs a Node, Bun or Deno server, such as @sveltejs/adapter-node
(bun add -d @sveltejs/adapter-node, then set it in svelte.config.js). The serverless adapters (Vercel, Netlify, Cloudflare) don't carry the UDP media.
WebSocket
This snippet mounts only the offer. To serve socket too, run it on a server that upgrades
WebSockets next to the SvelteKit app: Bun, Deno,
or serveFetch(socket, { port }) from @pipedog/transport-websocket/serve on Node, Bun or Deno.
Authentication
The route has no auth. Wrap offer with a session check before it 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).