AI/TLDR

OpenAI Agents SDK

Lightweight Python SDK for building multi-agent workflows with tools, handoffs, and guardrails

Overview

OpenAI Agents SDK is a lightweight Python framework for building multi-agent workflows. You define agents as LLMs configured with instructions, tools, guardrails, and handoffs, then let them delegate work to each other to complete a task.

It is provider-agnostic: it works with the OpenAI Responses and Chat Completions APIs, plus 100+ other LLMs. Built-in sessions handle conversation history across runs, and tracing lets you view, debug, and optimize your workflows.

It fits the multi-agent systems space by keeping the core small and explicit. Instead of a heavy orchestration layer, you compose agents, tools, and handoffs directly in Python, which suits developers who want control over how agents coordinate.

What it does

  • Agents: LLMs configured with instructions, tools, guardrails, and handoffs
  • Handoffs and agents-as-tools for delegating specific tasks to other agents
  • Tools support: Python functions, MCP, and hosted tools
  • Guardrails for input and output validation, plus human-in-the-loop controls
  • Sessions for automatic conversation history, and built-in tracing for debugging
  • Provider-agnostic across OpenAI Responses, Chat Completions, and 100+ other LLMs

Getting started

Python 3.10 or newer is required. Create a virtual environment, install the package, and run an agent.

Install with venv and pip

Set up a virtual environment and install the openai-agents package.

bashbash
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install openai-agents

Or install with uv

If you use uv, the install is a single add command.

bashbash
uv init
uv add openai-agents

Set your API key

Export OPENAI_API_KEY before running an agent. For voice support install the 'voice' extra; for Redis sessions install the 'redis' extra.

bashbash
export OPENAI_API_KEY=sk-...

Run a Sandbox Agent

Sandbox agents (new in 0.14.0) run in a computer environment with a filesystem. This example runs on the local filesystem and summarizes a repo.

pythonpython
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)

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Coordinate several specialized agents that hand off tasks to each other in a workflow
  • Give an agent tools (Python functions, MCP, or hosted tools) to take real actions
  • Build voice agents with realtime models using full agent features
  • Add guardrails and human-in-the-loop checks to validate agent input and output

How OpenAI Agents SDK compares

OpenAI Agents SDK alongside other open-source multi-agent systems tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
MetaGPT★ 68.9kA multi-agent framework that models a software company, assigning roles like product manager, architect, and engineer to generate code from a single prompt.
AutoGen★ 59.1kMicrosoft Research's framework for building applications where multiple agents converse with each other and with tools to solve tasks.
CrewAI★ 54kA framework for assembling teams ('crews') of role-playing agents that divide tasks and collaborate to complete a goal.
OpenAI Agents SDK★ 27.3kLightweight Python SDK for building multi-agent workflows with tools, handoffs, and guardrails
AgentScope★ 27kA framework for building multi-agent applications with message passing, visual debugging tools, and distributed execution.
OpenAI Swarm★ 21.7kAn educational, lightweight framework from OpenAI for experimenting with multi-agent coordination through handoffs and routines.
PentAGI★ 17.8kPentAGI is a self-hosted AI security platform that plans and runs penetration tests autonomously using a team of agents and 20+ built-in pentesting tools.
CAMEL★ 17.2kA research-oriented framework for studying and building communicating agents that cooperate through role-playing conversations.