Docs

Hono, Workers, Bun and Deno

Mount the realtime avatar proxy on any Fetch-handler runtime (Hono, Cloudflare Workers, Bun or Deno), including the apiKey factory Workers require.

Install realtime-avatar with its LiveKit peers, mount realtimeAvatarHono on app.all("/api/realtime-avatar/*"), render <AvatarCall>, and talk to the avatar for 8 free minutes, once. The LiveKit peers are livekit-client and @livekit/components-react, and zod is a peer as well. The public example avatar seed-rin-ashfall needs no avatar creation. One meter covers speech recognition, the LLM, the voice and the video.

The route holds REALTIME_AVATAR_API_KEY: your API key must never reach a browser, so the browser talks to your app and your app talks to us, and a server entry imported into a browser bundle throws. The adapter runs in a Hono app on Cloudflare Workers, Bun, Deno or Node; on Workers, pass apiKey as a factory so the key is read per request, not at module scope. Outside Hono, a Fetch handler such as Deno.serve passes { req: { raw: request } } to the function realtimeAvatarHono returns.

The server half

Mount on a wildcard so every operation reaches the handler, not just the mount path.

import { Hono } from "hono";
import { realtimeAvatarHono } from "realtime-avatar/hono";

const app = new Hono<{ Bindings: Env }>();

app.all(
  "/api/realtime-avatar/*",
  realtimeAvatarHono({
    // A FACTORY, not a value. On Workers there is no process.env, and a
    // module-scope read runs before any binding exists.
    apiKey: () => env.REALTIME_AVATAR_API_KEY,

    authorize: async ({ request, operation }) => {
      const user = await currentUser(request);
      if (!user) return new Response("Sign in", { status: 401 });
      if (operation === "connect" && !user.credits) {
        return Response.json({ code: "insufficient_credits" }, { status: 402 });
      }
    },

    session: async ({ avatarId }) => ({
      instructions: promptFor(avatarId),
    }),
  }),
);

export default app;

On Node or Bun, where process.env exists, a plain string is fine: apiKey: process.env.REALTIME_AVATAR_API_KEY!. The factory form is what makes the Workers case work, and it is harmless everywhere else — the value is simply read per request instead of once at module scope.

The client half

import { AvatarCall, createProxyClient } from "realtime-avatar/react";

const client = createProxyClient({ proxyUrl: "/api/realtime-avatar" });

<AvatarCall client={client} avatarId={avatarId} />

Next

  • Authentication — keys, scopes, and what authorize is really gating.
  • Calls — everything the session policy can decide.

Compare and cost guides