OpenAI Agents SDK
What it is
The OpenAI Agents SDK is a lightweight toolkit from OpenAI for building agentic applications in Python and TypeScript. Its own docs describe it as a package with very few abstractions, built on two design principles: enough features to be worth using, but few enough primitives to make it quick to learn, and great out of the box, but customisable exactly where you need it.
An agent in the SDK is a large language model configured with instructions, tools, and optional runtime behaviour such as handoffs, guardrails, and structured outputs. The SDK provides a built-in agent loop that handles tool invocation, sends results back to the model, and continues until the task is complete. You do not have to write that loop yourself.
The SDK covers three kinds of agent: text agents for ordinary chat and task work, sandbox agents that work in an isolated filesystem workspace with shell commands and file editing, and voice agents for low-latency spoken conversations. It uses the Responses API by default for OpenAI models, and it can also work with other model providers.
Who made it
The OpenAI Agents SDK is made by OpenAI. The documentation is published on GitHub Pages, and the source is on GitHub under the openai organisation.
- Official docs (Python): https://openai.github.io/openai-agents-python/agents/
- Official docs (TypeScript): https://openai.github.io/openai-agents-js/
- GitHub: https://github.com/openai/openai-agents-python
What it does
The SDK lets you build agents that answer questions, call tools, hand off to specialist agents, and enforce guardrails. A handoff lets one agent delegate a conversation to another agent that is better suited to the task — for example, a general support agent handing off to a billing specialist. Guardrails let you check inputs and outputs, for example blocking a request that should not be handled by the agent. Structured outputs let you ask for a validated result type instead of free text.
The SDK supports sessions, so an agent can keep conversation state across turns, and streaming, so you can show progress as the agent works. It also supports tracing, which records what the agent did, and it works with the OpenAI Responses API, the Chat Completions API, and other providers through a provider interface.
How it works
You define an Agent with a name, instructions, a model, and tools. Instructions are the system prompt, and the docs strongly recommend writing them. Tools are functions you decorate — in Python, with @tool — so the model can call them. You then run the agent with a Runner, which manages turns, tool calls, guardrails, handoffs, and sessions for you.
A typical run goes like this: the Runner sends the user’s message and the tool descriptions to the model. The model either answers or calls a tool. The Runner executes the tool, sends the result back to the model, and repeats until the model gives a final answer or hands off to another agent. If you want to own that loop yourself, the docs say to use the Responses API directly instead of the SDK.
You can set model settings such as temperature and tool choice, add hooks that run at lifecycle events, and define an output type so the agent returns structured data. For multi-agent work, you list other agents in the handoffs field, with a short handoff_description that tells the model when to hand off.
How to start
- Install the SDK. In Python, the docs use
pip install openai-agents; in TypeScript, usenpm install @openai/agents zod. Check the official docs for the current package name for your language. - Set your API key as an environment variable:
export OPENAI_API_KEY="your-key". Keep the key out of your code and out of any sandbox the agent works in. - Write a first agent. In Python, import
Agentfromagents, define a tool function with@tool, create anAgentwith a name, instructions, and that tool, and run it withRunner.run_sync(agent, "Your question"). In TypeScript, importAgentandrunfrom@openai/agentsand follow the hello-world example in the docs. - Test with a read-only tool first, such as a weather lookup, and read the trace to see which tools the agent called.
- Add a second agent and a handoff, then add a guardrail that blocks a request you do not want the agent to handle.
- When you are ready for file work, read the sandbox agents quickstart in the docs before giving an agent access to a workspace.
Follow the Agents page in the official docs for your language — Python and TypeScript have separate docs sites.
Who it is for
The OpenAI Agents SDK is for developers who want a small, well-documented toolkit for building agents on OpenAI models, without adopting a large framework. It suits product teams building support agents, research assistants, and internal tools, and developers who want handoffs and guardrails as first-class features. It is a code toolkit, not a no-code builder, and you need Python or TypeScript. It is a good fit if you already use OpenAI’s APIs and want the agent loop, sessions, and tracing handled for you.
Watch out for
The SDK is designed around OpenAI models by default. It can work with other providers, but check the Models page in the docs for how to configure a non-OpenAI provider before you assume it works the same way.
Source
- Official docs (Python): https://openai.github.io/openai-agents-python/agents/
- Official docs (TypeScript): https://openai.github.io/openai-agents-js/
- GitHub: https://github.com/openai/openai-agents-python