Member Junction
    Preparing search index...

    xAI Grok Voice implementation of the BaseRealtimeModel primitive.

    xAI's Grok Voice Agent API is OpenAI-Realtime-API compatible (WebSocket endpoint wss://api.x.ai/v1/realtime, Base64-encoded PCM16 @ 24 kHz audio, the same client/server event protocol and tool-calling shape). This driver therefore subclasses OpenAIRealtime with the SDK client pointed at xAI's base URL — inheriting the shared protocol implementation (session config, tool loop, barge-in gating, error classification, client-direct minting) and every future GA feature, gated per-provider by XAI_REALTIME_PROFILE, instead of maintaining a near-identical clone of the driver.

    Tool results complete the tool-call loop: the returned session implements the Core IRealtimeSession.SendToolResult contract method, which the agent layer calls after executing a tool to feed its result back to the model.

    Registered as GrokRealtime via @RegisterClass(BaseRealtimeModel, 'GrokRealtime'); the associated MJ: AI Model is typed with the Realtime AIModelType.

    Hierarchy (View Summary)

    Index

    Constructors

    Accessors

    • get apiKey(): string

      Only sub-classes can access the API key

      Returns string

    • get OpenAI(): OpenAI

      Read-only accessor for the underlying OpenAI SDK client.

      Returns OpenAI

    • get SupportsClientDirect(): boolean

      OpenAI supports the client-direct topology: the server mints a short-lived ephemeral client secret that the browser uses to open its OWN connection to OpenAI's Realtime API, while the server still controls the system prompt + tools via the returned SessionConfig.

      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 realtime session credential for a browser to open its own provider connection (client-direct topology). The server builds the session config (system prompt + tools + model) so it retains control of behavior even though the browser owns the socket.

      The GA features (reasoning effort, parallel tool calls, MCP tools) and the output voice are extracted from the Config bag and applied here exactly as on the server-bridged path, so the two topologies stay behaviorally identical — the browser applies the minted SessionConfig verbatim with no client-side changes needed.

      Parameters

      Returns Promise<ClientRealtimeSessionConfig>

      The minted ClientRealtimeSessionConfig the browser authenticates + applies.

    • Mints the ephemeral client secret via the provider's Realtime client-secrets API (resolved from the SDK client's base URL, so OpenAI-compatible subclasses target their own endpoint). Overridable seam for testing — unit tests return a fake response so no network call is made.

      Parameters

      • body: ClientSecretCreateParams

        The client-secret create request (carries the realtime session config).

      Returns Promise<ClientSecretCreateResponse>

      The client-secret create response (token value + expiry + echoed session).