OpenAI Agents SDK
Lightweight multi-agent orchestration framework by OpenAI. Production successor to Swarm. Provider-agnostic.
Warnings
- breaking openai v1.x is no longer supported. Must use openai>=2.0.0.
- breaking Python 3.9 support dropped. Minimum runtime is Python 3.10.
- deprecated Swarm is the deprecated predecessor. Do not use openai/swarm — openai-agents is the production replacement.
- gotcha MCP server methods (list_tools(), etc.) now take AgentBase, not Agent as type hint. Runtime behavior unchanged — objects are still Agent instances.
- gotcha Agent.as_tool() return type narrowed from Tool to FunctionTool. May cause type errors if you relied on the broader union.
- gotcha RealtimeAgent is beta. Breaking changes expected. Azure realtime: use GA URL path (wss://.../openai/v1/realtime), not legacy beta path (/openai/realtime?api-version=...).
- gotcha WebSocket transport for Responses API is opt-in. Default remains HTTP. Must call set_default_openai_responses_transport('websocket') to enable globally.
Install
-
pip install openai-agents -
uv add openai-agents -
pip install 'openai-agents[voice]' -
pip install 'openai-agents[redis]'
Imports
- Agent
from agents import Agent
- Runner
from agents import Runner
- handoffs
Agent(handoffs=[other_agent])
- RealtimeAgent
from agents.realtime import RealtimeAgent
- AgentBase
from agents import AgentBase
Quickstart
from agents import Agent, Runner agent = Agent(name="Assistant", instructions="You are a helpful assistant") result = Runner.run_sync(agent, "Write a haiku about recursion in programming.") print(result.final_output)