@langwatch/scenario
    Preparing search index...

    Interface ElevenLabsAgentAdapterOptions

    interface ElevenLabsAgentAdapterOptions {
        agentId: string;
        apiKey?: string;
        baseUrl?: string;
        conversationClient?: ElevenLabsConversationClient;
        dynamicVariables?: Record<string, string | number | boolean>;
        firstMessageOverride?: string;
        overrides?: Record<string, unknown>;
        systemPromptOverride?: string;
        webSocketFactory?: ElevenLabsWebSocketFactory;
    }
    Index
    agentId: string

    ID of the ElevenLabs Conversational AI agent (provisioned in the EL dashboard).

    apiKey?: string

    The key sent as xi-api-key. Falls back to ELEVENLABS_CONVAI_API_KEY, then ELEVENLABS_API_KEY.

    Against a gateway this carries a LangWatch virtual key rather than an ElevenLabs one, which is why it has its own variable. See resolveElevenLabsConvAIApiKey.

    baseUrl?: string

    Base URL for the ElevenLabs REST API, passed straight to the SDK client's own baseUrl option. Falls back to ELEVENLABS_BASE_URL.

    Points the signed-URL handshake at a LangWatch AI Gateway, which mirrors the vendor's own mint path: the gateway checks the virtual key's budget and session cap, mints the signed URL, and bills the call as one spend record. The websocket the URL names still belongs to ElevenLabs, so the media stream runs client to vendor and nothing about latency or the wire protocol changes.

    Unset here and in the environment, the SDK talks to ElevenLabs directly as it always has. The variable covers this adapter only; see resolveElevenLabsBaseUrl for why the speech-to-text and text-to-speech leaves take an explicit option instead.

    conversationClient?: ElevenLabsConversationClient

    SDK conversation client used ONLY for the requiresAuth signed-URL handshake — injected for unit tests so startSession() does not make a real getSignedUrl HTTP call. Production callers leave this unset; the adapter's own authenticated ElevenLabsClient is used.

    dynamicVariables?: Record<string, string | number | boolean>

    Per-call dynamic variables, forwarded NATIVELY to ElevenLabs as the init handshake's dynamic_variables. EL personalizes a hosted agent per call from these: a call-init webhook keyed on e.g. a tenant/org id resolves that call's system prompt, first message, and task context.

    Values pass through with their native JSON type — Text (string), Numeric (number), or Boolean (boolean) — with NO String() coercion, matching EL's typed dynamic-variable support. A key whose value is undefined is dropped before sending (the JSON serializer omits it). When this option is unset the adapter sends no dynamic_variables at all (not an empty {}).

    Applied only if the agent is configured to allow it — EL ignores variables the agent has not declared (server-side allowlist).

    scenario.elevenLabsAgent({
    agentId, apiKey,
    dynamicVariables: { tenant_id: "acme", seat_tier: 2, is_vip: true },
    });
    firstMessageOverride?: string

    Per-session first message override (conversationConfigOverride.agent.first_message).

    overrides?: Record<string, unknown>

    Per-call conversation-config overrides, DEEP-merged into the init handshake's conversation_config_override. Use this for any override the narrow ElevenLabsAgentAdapterOptions.systemPromptOverride/ElevenLabsAgentAdapterOptions.firstMessageOverride knobs do not cover (e.g. { agent: { language: "es" }, tts: { stability: 0.3 } }).

    Merge + precedence: the caller's overrides are applied FIRST, then the narrow systemPromptOverride/firstMessageOverride are layered on top — so the narrow knobs take precedence over the same keys here (agent.prompt.prompt, agent.first_message), while the shared top-level agent key DEEP-merges so a caller's agent.language and the adapter's agent.prompt BOTH survive.

    Applied only if the agent is configured to allow it — EL ignores non-allowlisted overrides server-side.

    scenario.elevenLabsAgent({
    agentId, apiKey,
    overrides: { agent: { language: "es" }, tts: { stability: 0.3 } },
    });
    systemPromptOverride?: string

    Per-session system prompt override applied via the SDK's conversationConfigOverride.agent.prompt.prompt. Lets demos use a different prompt shape without mutating the shared test agent.

    webSocketFactory?: ElevenLabsWebSocketFactory

    SDK WebSocket factory — injected for unit tests so the real Conversation runs against an in-memory socket (no network). Production callers leave this unset; the SDK's DefaultWebSocketFactory (the ws package) is used.