OpenAI Agents SDK
OpenAI's lightweight, open-source framework for agents — handoffs, guardrails, sessions, and built-in tracing.
OpenAI's open-source Agents SDK is a small, unopinionated framework for building agents: a core agent loop plus handoffs (delegation between agents), guardrails (input/output validation), sessions (memory), and built-in tracing. The production-grade successor to Swarm; works with non-OpenAI models too.
The OpenAI Agents SDK is OpenAI's lightweight, open-source framework for building agentic applications. It's the production-ready successor to the experimental Swarm project, and its design philosophy is "few primitives, learned fast": a core agent loop, plus a handful of well-chosen building blocks rather than a large abstraction layer.
It is aimed at developers who want a minimal, Pythonic framework with the essentials built in. Although it comes from OpenAI, it is provider-agnostic — you can run agents on non-OpenAI models — which makes it a reasonable default even outside the OpenAI ecosystem.
Highlights
- Agents & the loop — define an agent with instructions and tools; the SDK runs the model-tool-observation loop for you.
- Handoffs — delegate from one agent to another, the SDK's mechanism for multi-agent systems.
- Guardrails — validate inputs and outputs (and run checks in parallel) to keep agents safe and on-task.
- Sessions — built-in conversation memory across runs.
- Tracing — first-class tracing for debugging and evaluating agent runs.
In an AI-assisted workflow
from agents import Agent, Runner
agent = Agent(name="Support", instructions="Help with billing", tools=[lookup_invoice])
result = Runner.run_sync(agent, "Why was I charged twice?")TIP
Reach for the Agents SDK when you want a small, standard agent loop with handoffs and guardrails and minimal ceremony. For explicit state graphs and checkpointing, compare LangGraph; for role-based crews, CrewAI.
Good to know
The Agents SDK is open source (MIT) and free; you pay your model provider for tokens. It works with OpenAI models out of the box and with other providers through compatible interfaces. See the agent framework comparison for how it stacks up against LangGraph, CrewAI, AutoGen, and the Claude Agent SDK.
Frequently asked questions
- What is the OpenAI Agents SDK?
- The OpenAI Agents SDK is OpenAI's lightweight, open-source framework for building agentic applications — the production-ready successor to the experimental Swarm project. Its philosophy is 'few primitives, learned fast': a core agent loop plus handoffs for multi-agent delegation, guardrails for input/output validation, sessions for memory, and built-in tracing.
- Is the OpenAI Agents SDK free?
- Yes — it's open source under MIT and free; you pay your model provider for tokens.
- Does the OpenAI Agents SDK work with non-OpenAI models?
- Yes. Although it comes from OpenAI, it's provider-agnostic — it works with OpenAI models out of the box and with other providers through compatible interfaces, which makes it a reasonable default even outside the OpenAI ecosystem.
- OpenAI Agents SDK vs LangGraph?
- Reach for the Agents SDK when you want a small, standard agent loop with handoffs and guardrails and minimal ceremony. LangGraph fits when you need explicit state graphs and checkpointing; CrewAI when you want role-based crews.
Related
- LangGraphA low-level library for building stateful, controllable agents as graphs, with checkpointing and human-in-the-loop.
- CrewAIA Python framework for orchestrating role-playing AI agents as collaborating 'crews', plus event-driven flows.
- AutoGen (AG2)A multi-agent conversation framework where agents collaborate via message-passing, with group chat and code execution.
- Which Agent Framework in 2026? LangGraph vs CrewAI vs AutoGen vs OpenAI Agents SDK vs Claude Agent SDKA decision guide to the major AI agent frameworks — control vs. abstraction, multi-agent models, state and durability, and which fits your project.
- Building Agents with the Claude Agent SDKA working tutorial for the Claude Agent SDK in TypeScript and Python — query(), tool permissions, custom in-process MCP tools, subagents, hooks, and auth.
- LangGraph vs CrewAI: Agent Frameworks Compared (2026)LangGraph vs CrewAI — explicit state-machine control vs role-based crew abstractions. Which agent framework fits your reliability bar and team.
- OpenAI Agents SDK vs LangGraph: Minimal vs Controllable (2026)OpenAI Agents SDK's three-primitive minimalism vs LangGraph's explicit graph and durable state — which agent framework matches your reliability bar in 2026.