Member Junction
    Preparing search index...

    Real-time, full-duplex driver for a self-hosted HuggingFace speech-to-speech server running in OpenAI-Realtime-compatible mode. Registers as HuggingFaceRealtime and is resolved for MJ: AI Models typed Realtime (API-key env alias: AI_VENDOR_API_KEY__HuggingFaceRealtime — optional; many self-hosted endpoints are unauthenticated).

    Topologies:

    • Server-bridged (StartSession): the driver opens a raw websocket to the internal endpoint through RawRealtimeWebSocketConnection and runs the SHARED OpenAI-protocol session over it. Unlike the base driver, StartSession resolves only after the session config has been applied (the endpoint's session.createdsession.update handshake) so the runner never streams audio against an unconfigured model (obligation #7).
    • Client-direct (CreateClientSession): the driver mints a one-time proxy ticket and returns a wss://<mjapi-public>/realtime-proxy?ticket=… URL. The browser opens its socket to MJAPI's proxy, which tunnels transparently to the internal endpoint (injecting any auth server-side). The internal endpoint never reaches the browser and needs no browser-facing ingress.

    No managed server object and no usage billing: the entire session config (prompt, tools, voice) is supplied per session; there is no token-usage meter, so OnUsage fires only if the compat endpoint happens to report a response.done usage block.

    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 SupportedVoices(): RealtimeVoiceOption[]

      The compat layer's TTS stage has no OpenAI-style selectable voice catalog, so the dev voice picker gets none — overriding away the OpenAI voice list this class would otherwise inherit. (A voice Config value still passes through to audio.output.voice for stacks that honor it.)

      Returns RealtimeVoiceOption[]

    • 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 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).

    • Builds the upstream Authorization header from the API key, or undefined when the endpoint is unauthenticated. Because the realtime resolver requires a resolvable API key for a model to be selectable, a keyless self-hosted deployment sets a sentinel value (none / self-hosted / local / n/a) for AI_VENDOR_API_KEY__HuggingFaceRealtime — treated here as "no auth" so no bogus header is ever sent upstream (consumed by the MJAPI realtime proxy; the raw browser/Node socket cannot carry headers at all).

      Returns string

    • Builds the OpenAI-Realtime session object from the Core params:

      • instructions: the system prompt, with InitialContext folded in under a "Prior context" heading (the compat protocol has no guaranteed history-seeding channel).
      • tools: the Core tool set mapped to the OpenAI { type: 'function', … } schema.
      • audio.output.voice: from params.Config.voice, when supplied.
      • audio.input.transcription.model: from params.Config.inputTranscriptionModel, when supplied (the pipeline's STT stage transcribes the user natively; this only names a specific model if the compat layer supports selecting one).

      Parameters

      Returns JSONObject

    • Folds optional prior context into the system prompt (no guaranteed history channel).

      Parameters

      • systemPrompt: string
      • OptionalinitialContext: string

      Returns string