# OpenAI Agents SDK

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

- Category: Agents & Automation / Multi-Agent Systems
- Language: Python
- Repository: https://github.com/openai/openai-agents-python
- Website: https://openai.github.io/openai-agents-python/
- Canonical page: https://ai-tldr.dev/tools/openai-agents-sdk/

## In short

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 sits in the Multi-Agent Systems category of the Agents & Automation tools and is open-source, written in Python.

## 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.

1. Install with venv and pip

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

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

2. Or install with uv

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

```bash
uv init
uv add openai-agents
```

3. 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.

```bash
export OPENAI_API_KEY=sk-...
```

4. 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.

```python
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)
```

## 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
