What it is used for

The SDK fits work that cannot be finished in a single answer: customer support, document research, data entry, and other jobs that unfold over many steps and many tools. An agent can call program functions, search files, or reach outside services, then continue its work based on what those tools return.

Its signature pattern is a team of specialists. The documentation's own example is a support application where separate agents handle order status, refunds, and general questions. A front door agent reads the request, then hands the conversation to whichever specialist owns that kind of problem.

How to use it

Developers install the SDK as a Python package and provide an OpenAI API key through an environment variable named OPENAI_API_KEY. An agent is then defined with a name, instructions, and a model. The instructions are plain text that set the agent's role and working style, much like a written brief for a new staff member.

Tools are added in a deliberately plain way: any ordinary Python function can become a tool the agent may call. The SDK generates the input schema automatically and validates data with Pydantic, a data checking library, so developers do not hand write formats for every function. A runner then starts the agent, whose built in loop continues until the task completes.

Handoffs are set up by registering destination agents on the agent that may delegate. To the model, a handoff appears as a tool named transfer_to_ followed by the destination agent's name, and the model calls it when another specialist fits the conversation better. The receiving agent continues with the same conversation history, unless the developer installs an input filter to trim it.

Practitioner level

Guardrails work through a tripwire idea: when a check decides that an input or output fails, the SDK raises an exception and the run stops. Input guardrails run only for the first agent in a chain, while output guardrails run only for the agent that produces the final answer.

Input guardrails offer two execution modes. Parallel mode runs the check alongside the agent, which is fast, but the agent may already have spent tokens before cancellation arrives. Blocking mode finishes the check first, so bad input never starts the main agent at all. The documentation's example uses a cheap, fast model as the guard so misuse is caught before an expensive model does any work.

For work spanning many turns, sessions provide a persistent memory layer that keeps working context between turns of a conversation. The SDK also builds in human in the loop mechanisms for involving a person at chosen points, and it can call tools hosted on MCP servers, an open protocol that connects agents to outside tools and data.

Expert level

Under the hood, the SDK uses the Responses API by default for OpenAI models, while wrapping model calls in a higher level runtime. The documentation advises using the Responses API directly when developers want to own the loop, tool dispatch, and state themselves, and choosing the SDK when the runtime should manage turns, tools, guardrails, handoffs, and sessions.

Handoffs can be customised through the handoff function: tool names and descriptions can be overridden, a callback can run the moment a handoff fires, and input filters control what history the receiving agent sees. An agent can also serve as a tool for another agent without surrendering control of the conversation, a different choice from a full handoff.

Built in tracing captures agent flows for visualisation and debugging, and the documentation ties it to OpenAI's evaluation and fine tuning tools. The same documentation now also covers realtime voice agents and sandbox agents that work inside isolated workspaces, two newer directions growing out of the SDK's core.

Limits and risks

Guardrails reduce risk rather than remove it. Input checks cover only the first agent and output checks only the last, so a long chain of agents has middle points that agent level guardrails never inspect. Tool guardrails exist for function calls, but developers must attach them deliberately, tool by tool.

A handoff carries the conversation history to the next agent by default. Without a filter, things a user said early in a conversation travel onward to a specialist agent, which matters when the conversation holds personal or confidential information. The decision to hand off is also made by the model, so an agent can misroute a task to the wrong specialist.

Finally, this documentation moves quickly: the official pages read for this article already describe features younger than the SDK's original core, such as voice and sandbox agents. Applications built on the SDK need maintenance as the documentation changes, and guardrail and handoff behaviour should be tested inside each application instead of being assumed safe by default.