| layout | default |
|---|---|
| title | OpenAI Agents Tutorial |
| nav_order | 201 |
| has_children | true |
| format_version | v2 |
OpenAI Agents SDKView Repo is the official OpenAI framework for building multi-agent systems in Python. As the production successor to Swarm, it provides first-class primitives for agent handoffs, tool use, guardrails, streaming, and tracing — all backed by the OpenAI API and designed for real-world deployment.
The SDK embraces a minimalist, opinionated design: agents are defined declaratively with instructions, tools, and handoff targets, while the Runner orchestrates the agentic loop, model calls, and tool execution behind a clean async interface.
flowchart TD
A[User Input] --> B[Runner]
B --> C[Agent]
C --> D{Decision}
D -->|Tool Call| E[Tool Execution]
D -->|Handoff| F[Target Agent]
D -->|Final Answer| G[Output]
E --> C
F --> H[New Agent Loop]
H --> D
C --> I[Guardrails]
I -->|Pass| D
I -->|Trip| J[Early Exit]
B --> K[Tracing]
K --> L[OpenAI Dashboard]
classDef input fill:#e1f5fe,stroke:#01579b
classDef core fill:#f3e5f5,stroke:#4a148c
classDef execution fill:#fff3e0,stroke:#ef6c00
classDef output fill:#e8f5e8,stroke:#1b5e20
classDef safety fill:#fce4ec,stroke:#c2185b
class A input
class B,C,H core
class D,E,F,K,L execution
class G output
class I,J safety
The OpenAI Agents SDK is increasingly the default choice for Python developers building multi-agent applications on the OpenAI platform. Latest Release: The SDK has matured rapidly since its March 2025 launch, with built-in support for GPT-4.1, streaming events, guardrail validation, and first-party tracing integrated with the OpenAI dashboard.
This track focuses on:
- understanding the agent primitive and its declarative configuration
- mastering tool integration and function calling patterns
- building multi-agent systems with handoffs and routing
- implementing guardrails for input/output safety
- using streaming, tracing, and observability for production systems
Welcome to your journey through the OpenAI Agents SDK! This tutorial takes you from first install to production-grade multi-agent systems.
- Chapter 1: Getting Started - Installation, configuration, and your first agent
- Chapter 2: Agent Architecture - The Agent primitive, instructions, models, and lifecycle
- Chapter 3: Tool Integration - Function tools, hosted tools, and custom integrations
- Chapter 4: Agent Handoffs - Routing between agents, escalation, and specialization
- Chapter 5: Guardrails & Safety - Input/output validation and tripwire patterns
- Chapter 6: Streaming & Tracing - Real-time events, spans, and the tracing dashboard
- Chapter 7: Multi-Agent Patterns - Orchestrator, pipeline, and parallel agent topologies
- Chapter 8: Production Deployment - Scaling, error handling, cost control, and monitoring
- repository:
openai/openai-agents-python - stars: about 20.6k
- latest release:
v0.13.5(published 2026-04-06)
By the end of this tutorial, you'll be able to:
- Build intelligent agents with declarative instructions, tools, and handoffs
- Orchestrate multi-agent systems using handoffs, routing, and specialization
- Implement safety guardrails for input validation and output filtering
- Integrate tools including function tools, code interpreter, and web search
- Stream agent responses with fine-grained event handling
- Trace and debug agent runs using built-in tracing and the OpenAI dashboard
- Design production architectures with error recovery, cost controls, and monitoring
- Apply proven patterns for orchestrator, pipeline, and parallel agent topologies
- Python 3.9+ (3.11+ recommended)
- An OpenAI API key with access to GPT-4o or later models
- Basic understanding of async/await in Python
- Familiarity with LLM concepts (prompts, tool calling, function calling)
Production Successor to Swarm: The OpenAI Agents SDK brings Swarm's lightweight agent-handoff philosophy into a production-grade framework with built-in tracing, guardrails, and streaming.
Key features:
- Agent Handoffs: First-class primitive for routing between specialized agents
- Guardrails: Input and output validation with tripwire abort patterns
- Streaming: Fine-grained event stream for real-time UIs
- Tracing: Built-in OpenTelemetry-compatible tracing with OpenAI dashboard integration
- Tool Use: Function tools, hosted tools (code interpreter, web search), and agents-as-tools
Perfect for developers new to multi-agent systems:
- Chapters 1-2: Setup and agent fundamentals
- Focus on understanding the agent lifecycle and Runner
For developers building agent applications:
- Chapters 3-5: Tools, handoffs, and guardrails
- Learn to build interconnected multi-agent workflows
For production multi-agent system development:
- Chapters 6-8: Streaming, tracing, patterns, and deployment
- Master enterprise-grade agent orchestration
Ready to build multi-agent systems with OpenAI? Let's begin with Chapter 1: Getting Started!
- Start Here: Chapter 1: Getting Started
- Back to Main Catalog
- Browse A-Z Tutorial Directory
- Search by Intent
- Explore Category Hubs
Generated by AI Codebase Knowledge Builder