Member Junction
    Preparing search index...

    Real-time, full-duplex driver for Google's Gemini Live API, implementing the Core BaseRealtimeModel primitive.

    The driver opens a bidirectional Gemini Live session, streams client audio in, and translates the provider's LiveServerMessage frames into the modality-agnostic Core events (RealtimeTranscript, RealtimeToolCall, RealtimeUsage, output media, and interruption). It registers via the MemberJunction class factory as GeminiRealtime and is resolved for MJ: AI Models typed Realtime.

    Testability: the live-session creation is isolated behind the overridable connectLiveSession seam, so unit tests inject a fake GeminiLiveSession and exercise the full message→event translation with no network.

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    • get apiKey(): string

      Only sub-classes can access the API key

      Returns string

    • get SupportedVoices(): RealtimeVoiceOption[]

      The provider-native voice ids this model can speak with (e.g. OpenAI alloy/echo/shimmer). The model/driver is the authoritative owner of "what voices do I support", so each driver declares its own — used to populate the dev voice picker. Default empty (a driver that hasn't declared voices yields no picker options, falling back to the configured/default voice).

      NOTE: this is the near-term, driver-owned source of truth. Long term this should move to metadata so providers that let users add their OWN voices (e.g. ElevenLabs) can be enumerated dynamically.

      Returns RealtimeVoiceOption[]

      The supported voice ids (id + human label), or [] when none are declared.

    • get SupportsClientDirect(): boolean

      Gemini Live supports the client-direct topology: the server mints a short-lived ephemeral auth token (v1alpha auth_tokens API) that the browser uses to open its OWN Live websocket, while the server keeps prompt/tool authority by LOCKING the connect config into the token via liveConnectConstraints.

      Returns boolean

    • get SupportsVideo(): boolean

      Whether this driver's sessions carry a video track in addition to audio — i.e. the model accepts video input (it can "see" the user's camera) and/or emits video output (a talking-head avatar / generated video), in sync with audio.

      Defaults to false (audio-only — today's realtime models). Video-capable drivers (a native multimodal realtime model, or an avatar provider) override this to true. The session's media plane is media-tagged (IRealtimeSession.SendInput takes a RealtimeMediaKind; IRealtimeSession.OnVideoOutput delivers video-out), so a video session reuses the entire realtime contract — only the media frames gain a video kind. Resolution prefers a video-capable model when an agent requests video, and degrades to audio-only otherwise.

      Returns boolean

      true if sessions can carry video; false (audio-only) otherwise.

    Methods

    • Mints an ephemeral, server-scoped Live credential for a client-direct session.

      The connect config is built EXACTLY as StartSession builds it (same buildConnectConfig: audio modality, input+output transcription, system instruction, mapped tools) and is locked into the token via liveConnectConstraints + lockAdditionalFields: [] — so the API ignores any attempt by the browser to change the locked fields. The same config is ALSO carried in SessionConfig (as { model, config }) because the SDK still expects the client to pass a model/config at live.connect time; the token-side lock is what makes the server's prompt and tool set authoritative.

      Expiry: the browser must open its session within GEMINI_CLIENT_TOKEN_NEW_SESSION_WINDOW_MS; the token (and thus the session's ability to send messages) dies at GEMINI_CLIENT_TOKEN_EXPIRY_MS.

      Parameters

      Returns Promise<ClientRealtimeSessionConfig>

      The minted ClientRealtimeSessionConfig the browser authenticates + applies.

    • Mint seam for the ephemeral auth token. Production routes through the SDK's authTokens.create on a v1alpha client (ephemeral tokens are v1alpha-only); unit tests override this to return a fake token with no network.

      Parameters

      • params: CreateAuthTokenParameters

        The auth-token create parameters (expiry, uses, live-connect constraints).

      Returns Promise<AuthToken>

      The created AuthToken (its name is the credential the browser presents).

    • Projects the full connect config down to the fields Gemini's ephemeral-token API accepts as liveConnectConstraints.config. The token mint converts the provided keys into a field mask over BidiGenerateContentSetup, and only generation-level fields are valid there — systemInstruction, tools, and the transcription configs are NOT, and their presence 400s the entire mint. Only defined fields are copied (an absent key must stay absent so it doesn't enter the mask).

      Parameters

      • config: LiveConnectConfig

      Returns LiveConnectConfig