Skip to content

ElevenLabsAgentAdapter

Connects to an ElevenLabs Conversational AI ("Convai") agent over WebSocket. Use this when you've built an agent in the ElevenLabs dashboard and want to test it end-to-end.

Constructor

python
import os
import scenario
 
adapter = scenario.ElevenLabsAgentAdapter(
    agent_id=os.environ["ELEVENLABS_AGENT_ID"],
    api_key=os.environ["ELEVENLABS_API_KEY"],
    # Optional per-session overrides (sent via conversation_initiation_client_data):
    # system_prompt_override="Be terse for this test.",
    # first_message_override="Hi — this is the test harness.",
)

The two optional per-session override fields let you adjust the hosted agent's behaviour for a specific test run without modifying the shared ElevenLabs dashboard configuration. They are transmitted in the WebSocket conversation_initiation_client_data handshake at connect time:

PythonTypeScriptDescription
system_prompt_overridesystemPromptOverrideReplaces the agent's system prompt for this session only. Useful for pinning a test persona without touching the shared dashboard agent.
first_message_overridefirstMessageOverrideOverrides the agent's opening message for this session.

Capabilities

streaming_transcriptsnative_vaddtmfinterruptioninput_formatsoutput_formats
pcm16/24000pcm16/24000

Worked examples

Common failures

Composable variant — ElevenLabsVoiceAgent

If you'd rather pair ElevenLabs STT/TTS with a different LLM, use ElevenLabsVoiceAgent:

python
import os
import scenario
 
agent = scenario.ElevenLabsVoiceAgent(
    api_key=os.environ["ELEVENLABS_API_KEY"],
)

Optional args: voice, stt (custom STTProvider), system_prompt / systemPrompt, and llm. The llm default differs by SDK — Python takes a model string (default "openai/gpt-5.4-mini"); TypeScript takes an AI-SDK LanguageModel (e.g. llm: anthropic("claude-sonnet-4-6")).