Skip to main content

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

name
str
default:"'RealtimeAgent'"
No description available.
llm
Optional
No description available.
realtime
Optional
No description available.
instructions
Optional
No description available.
verbose
bool
default:"True"
No description available.

Methods

console()

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 GitHub

praisonaiagents/agent/realtime_agent.py at line 37

Agents Concept

Single Agent Guide

Multi-Agent Guide

Agent Configuration

Auto Agents