Member Junction
    Preparing search index...

    Adapts a RAW platform WebSocket speaking the OpenAI Realtime wire protocol into the IOpenAIRealtimeConnection seam the shared OpenAIRealtime driver family consumes.

    This is the enabling primitive for OpenAI-protocol-compatible providers whose endpoint is NOT reachable through the openai SDK client — e.g. a self-hosted HuggingFace speech-to-speech server (arbitrary ws:// endpoint, optional/no auth) — letting them subclass the shared driver instead of re-implementing the protocol against a bare socket.

    Behavior mirrors the SDK's OpenAIRealtimeWebSocket where the driver depends on it:

    • Inbound JSON frames fan out to 'event' listeners; non-JSON frames are ignored.
    • Provider error FRAMES are routed to 'error' listeners with the payload attached at .error (the driver classifies those as recoverable), while TRANSPORT failures are routed with no .error payload (classified fatal) — the same dual-channel contract the SDK exposes.
    • Outbound Send calls made before the socket opens are buffered and flushed on open, so a non-deferring profile can configure the session without racing the handshake.
    • The raw socket's close event is surfaced through the optional socket shim the driver feature-detects for unexpected-closure handling.

    Implements

    Index

    Constructors

    Properties

    Methods

    Constructors

    • Opens the raw socket immediately (matching the SDK connection's construct-then-connect lifecycle). The platform-global WebSocket API has no header support, so any upstream auth must be enforced by the endpoint or injected by an intermediary (e.g. MJAPI's realtime proxy).

      Parameters

      • url: string

        The ws(s)://…/v1/realtime endpoint URL.

      • OptionalwebSocketCtor: NativeWebSocketCtor

        Optional WebSocket constructor override (tests inject a fake; production resolves the platform global).

      Returns RawRealtimeWebSocketConnection

    Properties

    socket: { addEventListener(type: "close", listener: () => void): void }

    The socket shim the driver uses to detect UNEXPECTED closure (see IOpenAIRealtimeConnection.socket).

    Methods

    • Registers a listener for parsed server events ('event') or connection errors ('error').

      Parameters

      • event: "event"
      • listener: (event: RealtimeServerEvent) => void

      Returns void

    • Registers a listener for connection errors. The SDK routes BOTH transport-level failures (socket error, unparseable frame, failed send — error.error is undefined) and provider error server frames (error.error carries the payload) through this channel; the driver classifies fatality from that distinction.

      Parameters

      • event: "error"
      • listener: (error: OpenAIRealtimeError) => void

      Returns void