Skip to main content

RealtimeObserver

Observer for the OpenAI Realtime API.
Observer for the OpenAI Realtime API.
Parameters:

Instance Attributes

agent



logger



realtime_client



Instance Methods

initialize_session

Initialize the session for the observer.

on_close

Handle close of RealtimeClient.

on_event

Handle an event from the OpenAI Realtime API.
Parameters:

run

Run the observer with the agent.
When implementing, be sure to call self._ready_event.set() when the observer is ready to process events.
Parameters:

run_loop

Run the loop if needed.
This method is called after the observer is ready to process events.
Events will be processed by the on_event method, this is just a hook for additional processing.
Use initialize_session to set up the session.

wait_for_ready

Get the event that is set when the observer is ready.