Elysia
Mount the pipedog WebRTC offer endpoint in an Elysia app on Bun.
Elysia runs on Bun. The offer is a route that passes Elysia's web Request to offer. This snippet
mounts only the offer.
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 elysia@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 { Elysia } from "elysia";
import { offer } from "./voice.ts";
export const app = new Elysia().post("/api/offer", ({ request }) => offer(request));
// `bun server.ts` starts it on port 3000.
if (import.meta.main) {
app.listen(3000);
}
Run it
OPENAI_API_KEY=sk-... bun server.tsIt listens on port 3000, at POST /api/offer.
Deploy
Run it as a long-lived Bun process on a host that allows UDP traffic, for the offer's media.
WebSocket
Elysia has its own WebSocket route API (.ws()), which this snippet doesn't use. To serve WebSocket
sessions, wire .ws() to a WebsocketConnection the way the Bun snippet
does, or run the Bun snippet next to this app.
Authentication
The route has no auth. Wrap offer with a session check before it runs, or use an Elysia
beforeHandle hook, 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).