aiellie

Search

Find a component, template or page

GitHub
Components

Video Call

A live call with the assistant: the orb listens and speaks, your camera sits in a corner and is shared with it a frame a second, with mute, camera and hang-up, and a transcript beside it. Runs on Gemini Live, or on a mock with no key.

Call Ellie

Transcript

What you both say shows up here.

Open full screen
fig. 01 · open it full screen from the corner

Installation

npx shadcn@latest add "@aiellie/video-call"

shadcn needs the @aiellie registry in components.json first. npx aiellie add video-call adds it on its first run, then installs the same way.

Video Call is a live call with the assistant, like FaceTime. The assistant fills the stage as an Orb, your camera sits in a corner, and you talk in real time. The assistant sees your camera, one frame a second. Mute, camera and hang-up sit under the orb, and a transcript runs beside it.

Calls run on Gemini Live. The browser talks to Gemini directly over a WebSocket, with a one-use token that your server mints, so your key never reaches the browser. Pass mock to fake the assistant with no key and no network, as the demo above does.

Getting started

  1. Add the token route

    live-token installs a route at app/api/live-token/route.ts. It turns your key into a token that works once, for one minute, and only on the model and settings the route picks. Get a key from Google AI Studio and put it in your environment.

    Anyone who can reach the route can start a call on your key, so put it behind your own sign-in before you deploy.

    .env.local
    GEMINI_API_KEY=your-key
  2. Place the call

    The call waits for the start button, and asks for the camera and microphone only then.

    app/call/page.tsx
    import { VideoCall } from "@/components/aiellie/video-call"
    
    export default function CallPage() {
      return <VideoCall name="Ellie" />
    }
  3. Try it without a key

    app/call/page.tsx
    <VideoCall mock name="Ellie" />

Anatomy

<div data-slot="video-call" data-state="listening">
  <div data-slot="video-call-stage">
    <span role="status" /> {/* the state, the timer and the mic menu */}
    <div data-slot="orb" />
    <div data-slot="video-call-self" /> {/* your camera */}
    <div data-slot="video-call-controls" role="toolbar" />
  </div>
  <div data-slot="video-call-transcript">
    <div data-slot="transcript" />
  </div>
</div>

data-state is idle, connecting, listening, speaking or ended. The orb thinks while connecting and sleeps once the call ends. While listening it swells with your voice, and while speaking with its own.

The microphone goes to Gemini as 16-bit PCM in 100 ms chunks, and the camera as a 640px JPEG once a second, the most Gemini takes. Replies come back as 24 kHz audio and play in order. When you talk over the assistant, Gemini cuts the reply off and the rest of it is dropped.

An audio and video session ends after two minutes unless Gemini compresses its context, so the token turns that on, along with session resumption. Gemini closes a connection after about ten minutes, and the call moves to a new one without dropping.

The assistant's words settle in the transcript when its turn ends. Screen readers hear each line once it settles.

Examples

From a call menu

Open the call from CallMenu in a dialog. autoStart places it as soon as it mounts, and onEnd closes the dialog.

Your own script

mockLive takes the assistant's lines, the lines it shows you saying when your microphone is off, and a time to hang up after. Pass the result as transport. A transport is a function from handlers to a session, so the same prop takes another provider's live API.

Call Sam

Your own layout

useLiveCall is the call without the screen: its state, the transcript, the two streams and the controls.

components/voice-only.tsx
"use client"

import { Orb } from "@/components/aiellie/orb"
import { useLiveCall } from "@/components/aiellie/video-call"
import { geminiLive } from "@/lib/live-call"

export function VoiceOnly() {
  const call = useLiveCall({
    transport: () => geminiLive(),
    defaultCameraOff: true,
  })

  return (
    <button onClick={call.state === "idle" || call.state === "ended" ? call.start : call.end}>
      <Orb state={call.state === "speaking" ? "speaking" : "listening"} />
    </button>
  )
}

API reference

VideoCall

PropTypeDefaultDescription
transportLiveTransportWhere the assistant's side comes from. Overrides mock and tokenUrl.
mockbooleanfalseFakes the assistant, with no key and no network.
tokenUrlstring"/api/live-token"The route that mints a Gemini Live token.
frameIntervalnumber1000Milliseconds between camera frames. Anything under 1000 is raised to it.
namestring"Assistant"Who the call is with, for the transcript and labels.
seed, colorsPassed to the Orb.
autoStartbooleanfalseStarts the call on mount instead of waiting for the button.
defaultMutedbooleanfalse
defaultCameraOffbooleanfalse
showTranscriptbooleantrue
onStateChange(state: "idle" | "connecting" | "listening" | "speaking" | "ended") => void
onTranscript(segments: CallSegment[]) => voidEvery settled line so far, each time one settles.
onEnd(reason: "hangup" | "error" | "timeout") => void

All other div props are forwarded to the root.

geminiLive

OptionTypeDefaultDescription
tokenUrlstring"/api/live-token"Answers a POST with { token, model }.
frameIntervalnumber1000
apiVersionstring"v1beta"The Gemini API version the token was minted for.

mockLive

OptionTypeDefaultDescription
repliesstring[]What the assistant says, in turn.
promptsstring[]What you're shown saying while your microphone is off.
hangUpAfternumberEnds the call by itself after this many milliseconds.

With the microphone on, the mock listens to it and answers after you've been quiet for 800 ms. Talking while it speaks cuts it off.