@langwatch/scenario
    Preparing search index...

    Interface OpenAIRealtimeAgentAdapterInit

    interface OpenAIRealtimeAgentAdapterInit {
        apiKey?: string;
        instructions?: string;
        mint?: false | Partial<RealtimeMintEndpoint>;
        model?: string;
        role?: AgentRole;
        tools?: RealtimeToolDef[];
        url?: string;
        voice?: string;
        wsFactory?: (url: string, authHeader: string) => WebSocket;
    }
    Index
    apiKey?: string

    Explicit API key for dialing the vendor directly; falls back to process.env.OPENAI_REALTIME_API_KEY, then process.env.OPENAI_API_KEY.

    This key is only used when the session is not minted, so it matters when OPENAI_BASE_URL points at an endpoint with no mint route. See mint.

    instructions?: string

    System instructions passed via session.update.

    mint?: false | Partial<RealtimeMintEndpoint>

    Where to mint the session credential, overriding OPENAI_BASE_URL and OPENAI_API_KEY. false skips the mint and dials the vendor directly.

    POST /v1/realtime/client_secrets is OpenAI's own path, and a LangWatch AI Gateway mirrors it, so the same request works against either. Against OpenAI it returns an ephemeral client secret. Against a gateway it also checks the virtual key's budget and open-session cap and opens one spend record, naming the session on the X-LangWatch-Session-Id response header. Usage is reported back only when that header is present.

    The media socket runs to the vendor either way, so latency and the wire protocol do not change.

    model?: string

    Realtime model id. Defaults to OPENAI_REALTIME_MODEL.

    role?: AgentRole

    AGENT (default) makes the model the agent under test. USER turns it into the voice-enabled user simulator — scripted user("text") steps route through sendText and bypass the TTS pipeline.

    tools?: RealtimeToolDef[]

    Tool definitions passed straight through to the Realtime session.

    url?: string

    Override the Realtime endpoint URL. Defaults to wss://api.openai.com/v1/realtime?model=<model>. Lets tests point at a loopback WS server without subclassing the adapter.

    voice?: string

    Voice id (e.g. "alloy", "nova").

    wsFactory?: (url: string, authHeader: string) => WebSocket

    Optional factory that creates the WebSocket instead of new WebSocket(url, headers). Intended for testing — lets tests inject a fake WS without subclassing or monkey-patching. The factory receives the resolved URL and Authorization header value.