The OpenAI Agents SDK provides four agent types—Agent, SandboxAgent, RealtimeAgent, and VoicePipeline—to cover text, isolated execution, WebSocket-based voice/multimodal, and voice workflow use cases. Text agents run synchronously; realtime and voice agents handle streaming audio/multimodal events asynchronously, differing in connection model (RealtimeAgent uses RealtimeRunner, VoicePipeline processes AudioInput buffers).
The openai-agents-python SDK supports four primary agent types: the text Agent, SandboxAgent (isolated workspace), RealtimeAgent (WebSocket voice/multimodal), and VoicePipeline for voice workflows.[1]
Example: minimal realtime agent loop using RealtimeAgent, RealtimeRunner, and async event iteration.
import asyncio
from agents.realtime import RealtimeAgent, RealtimeRunner
async def main() -> None:
agent = RealtimeAgent(name="Assistant", instructions="You are a helpful voice assistant. Keep responses short.")
runner = RealtimeRunner(starting_agent=agent)
session = await runner.run()
async with session:
await session.send_message("Say hello in one short sentence.")
async for event in session:
if event.type == "audio":
pass
elif event.type == "history_added":
print(event.item)
elif event.type == "agent_end":
break
Example: minimal voice pipeline run using VoicePipeline, SingleAgentVoiceWorkflow, and AudioInput.
from agents import Agent
from agents.voice import AudioInput, SingleAgentVoiceWorkflow, VoicePipeline
async def main() -> None:
agent = Agent(name="Assistant", instructions="You are a helpful voice assistant.")
pipeline = VoicePipeline(workflow=SingleAgentVoiceWorkflow(agent))
audio_input = AudioInput(buffer=np.zeros(24000 * 3, dtype=np.int16))
result = await pipeline.run(audio_input)
async for event in result.stream():
if event.type == "voice_stream_event_audio":
pass
Sources