Realtime Agent • AI Agent SDK
RealtimeAgent: Agent for real-time voice conversations using OpenAI Realtime API.
RealtimeAgent
Defined in the Realtime Agent module.
AI Agent
Agent for real-time voice conversations using OpenAI Realtime API.
This agent enables bidirectional audio streaming for voice conversations, supporting both text and audio modalities with configurable voice settings.
Constructor
strNo description available.
Optional[str]No description available.
Optional[str]No description available.
OptionalNo description available.
Optional[str]No description available.
boolNo description available.
Methods
Lazy load Rich console.
connect()Connect to the Realtime API (sync wrapper).
aconnect()Connect to the Realtime API asynchronously.
disconnect()Disconnect from the Realtime API (sync wrapper).
adisconnect()Disconnect from the Realtime API asynchronously.
send_text()Send text message (sync wrapper).
asend_text()Send text message asynchronously.
send_audio()Send audio data (sync wrapper).
asend_audio()Send audio data asynchronously.
on_message()Register callback for text messages.
on_audio()Register callback for audio data.
on_error()Register callback for errors.
receive_loop()Main receive loop for processing incoming events.
Usage
from praisonaiagents import RealtimeAgent
agent = RealtimeAgent(
name="VoiceAssistant",
realtime={"voice": "nova"}
)
# Connect and start conversation
await agent.aconnect()
await agent.send_text("Hello!")Source
View on GitHubpraisonaiagents/agent/realtime_agent.py at line 87