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
python
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 / apiKey is read from OPENAI_API_KEY by default; pass it explicitly
to override. tools accepts function-calling schemas.
To use the OpenAI Realtime model as a voice user simulator instead of the
agent under test, set role to the user role
(role=AgentRole.USER / role: AgentRole.USER).
Capabilities
| streaming_transcripts | native_vad | dtmf | interruption | input_formats | output_formats |
|---|---|---|---|---|---|
| ✅ | ✅ | ❌ | ✅ | pcm16/24000 | pcm16/24000 |
Worked examples
- Python:
openai_realtime_agent.py— agent under test with a judge step;openai_realtime_user.py— Realtime as a voice user simulator;getting_started.py— minimal scenario from the getting-started page. - TypeScript:
openai-realtime-agent.test.ts— agent under test;openai-realtime-user.test.ts— Realtime as a voice user simulator.
