Skip to content

OpenAIRealtimeAgentAdapter

Connects directly to wss://api.openai.com/v1/realtime. Use this when the OpenAI Realtime model itself is the agent under test, or as a voice-enabled user simulator.

Constructor

import scenario
from scenario.config.voice_models import OPENAI_REALTIME_MODEL
from scenario.types import AgentRole
 
adapter = scenario.OpenAIRealtimeAgentAdapter(
    model=OPENAI_REALTIME_MODEL,
    voice="alloy",
    instructions="You are a helpful assistant. Keep responses brief.",
    role=AgentRole.AGENT,
)

api_key is read from OPENAI_API_KEY by default; pass it explicitly to override. tools accepts function-calling schemas.

Capabilities

streaming_transcriptsnative_vaddtmfinterruptioninput_formatsoutput_formats
pcm16/24000pcm16/24000

Worked examples