The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows. It is provider-agnostic, supporting the OpenAI Responses and Chat Completions APIs, as well as 100+ other LLMs.
[!NOTE]
Looking for the JavaScript/TypeScript version? Check out Agents SDK JS/TS.
Core concepts:
Agents: LLMs configured with instructions, tools, guardrails, and handoffs
Sandbox Agents: Agents preconfigured to work with a container to perform work over long time horizons.
For voice support, install with the optional voice group: pip install 'openai-agents[voice]'. For Redis session support, install with the optional redis group: pip install 'openai-agents[redis]'.
uv
If you’re familiar with uv, installing the package would be even easier:
uv init
uv add openai-agents
For voice support, install with the optional voice group: uv add 'openai-agents[voice]'. For Redis session support, install with the optional redis group: uv add 'openai-agents[redis]'.
Run your first agents
The SDK supports three primary ways to run agents. Set the OPENAI_API_KEY environment variable before running any of these examples.
Run a sandbox agent
Use a SandboxAgent when the agent needs to inspect files, run commands, apply patches, or preserve workspace state across longer tasks.
This example uses UnixLocalSandboxClient, which is supported on macOS and Linux. On Windows, use DockerSandboxClient with the openai-agents[docker] extra or a hosted sandbox client instead; see Sandbox clients for setup details.
from agents import Runner
from agents.run import RunConfig
from agents.sandbox import Manifest, SandboxAgent, SandboxRunConfig
from agents.sandbox.entries import GitRepo
from agents.sandbox.sandboxes import UnixLocalSandboxClient
agent = SandboxAgent(
name="Workspace Assistant",
instructions="Inspect the sandbox workspace before answering.",
default_manifest=Manifest(entries={"repo": GitRepo(repo="openai/openai-agents-python", ref="main")}),
)
result = Runner.run_sync(
agent,
"Inspect the repo README and summarize what this project does.",
run_config=RunConfig(sandbox=SandboxRunConfig(client=UnixLocalSandboxClient())),
)
print(result.final_output)
Run a text agent
Use a text Agent for workflows that do not need a persistent realtime connection or a sandbox workspace.
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)
# Code within the code,
# Functions calling themselves,
# Infinite loop's dance.
OpenAI Agents SDK
The OpenAI Agents SDK is a lightweight yet powerful framework for building multi-agent workflows. It is provider-agnostic, supporting the OpenAI Responses and Chat Completions APIs, as well as 100+ other LLMs.
Core concepts:
gpt-realtime-2.1and full agent featuresExplore the examples directory to see the SDK in action, and read our documentation for more details.
Get started
To get started, set up your Python environment (Python 3.10 or newer required), and then install OpenAI Agents SDK package.
venv
For voice support, install with the optional
voicegroup:pip install 'openai-agents[voice]'. For Redis session support, install with the optionalredisgroup:pip install 'openai-agents[redis]'.uv
If you’re familiar with uv, installing the package would be even easier:
For voice support, install with the optional
voicegroup:uv add 'openai-agents[voice]'. For Redis session support, install with the optionalredisgroup:uv add 'openai-agents[redis]'.Run your first agents
The SDK supports three primary ways to run agents. Set the
OPENAI_API_KEYenvironment variable before running any of these examples.Run a sandbox agent
Use a
SandboxAgentwhen the agent needs to inspect files, run commands, apply patches, or preserve workspace state across longer tasks.This example uses
UnixLocalSandboxClient, which is supported on macOS and Linux. On Windows, useDockerSandboxClientwith theopenai-agents[docker]extra or a hosted sandbox client instead; see Sandbox clients for setup details.Run a text agent
Use a text
Agentfor workflows that do not need a persistent realtime connection or a sandbox workspace.(For Jupyter notebook users, see hello_world_jupyter.ipynb)
Run a realtime agent
Use a
RealtimeAgentfor low-latency, server-side voice and multimodal experiences over WebSocket.Explore the examples directory to see the SDK in action, and read our documentation for more details.
Acknowledgements
We’d like to acknowledge the excellent work of the open-source community, especially:
This library has these optional dependencies:
We also rely on the following tools to manage the project:
We’re committed to continuing to build the Agents SDK as an open source framework so others in the community can expand on our approach.