Creates a new RealtimeAgentAdapter instance
The session can be either connected or unconnected. If unconnected, call connect() before use.
Configuration for the realtime agent adapter
The name that LangWatch shows as the target of the run. When you do not set it, the framework uses the class name of the adapter.
Whether the live session was minted by a gateway rather than the vendor.
Only true after connect(), and only when the mint answered with
X-LangWatch-Session-Id. Configuration cannot set it, because the
response is the one thing that cannot be told a lie about what answered.
Process input and generate response (implements AgentAdapter interface)
This is called by Scenario framework for each agent turn. Handles both text and audio input, returns audio message with transcript.
Scenario agent input with message history
Agent response as audio message or text
Open the session, minting its credential the way every other realtime adapter does.
The media websocket runs to OpenAI either way. What changes is the bearer
it opens with: POST ${OPENAI_BASE_URL}/realtime/client_secrets is
OpenAI's own mint path and a LangWatch AI Gateway mirrors it, so pointing
OPENAI_BASE_URL at a gateway makes the same request check the virtual
key's budget and session cap and open one spend record. The socket then
carries the ephemeral secret the mint returned, which the @openai/agents
websocket transport was built to take.
An explicit params.apiKey skips the mint: the caller has already said
which credential to dial with.
Optionalparams: RealtimeSessionConnectOptionsCloses the session connection
Remove audio response listener
The callback function to remove
Subscribe to audio response events
Function called when an audio response completes
Adapter that connects Scenario testing framework to OpenAI Realtime API
This adapter wraps a RealtimeSession to provide the Scenario framework interface. The session is created by your own session creator, so the same creation pattern runs in both browser and tests.
connect()mints the session credential atOPENAI_BASE_URL, which is how a run through a LangWatch AI Gateway gets metered.Example