know.2nth.ai Agents OpenAI Agents SDK
agents · OpenAI Agents SDK · Skill Leaf

The successor to Assistants. Five primitives. One SDK.

The OpenAI Agents SDK is OpenAI's official agent framework, released in 2025 as the production-grade successor to the Assistants API. Python and TypeScript SDKs, both open source. Built around five primitives: Agents, Handoffs, Tools, Guardrails, and Tracing. Native MCP support, native function-calling, native built-in tracing dashboard on the OpenAI Platform. The default for production agents on GPT, and the cleanest path from prototype to scaled deployment for teams already on OpenAI infrastructure.

Live · production-ready OpenAI-built Python · TypeScript GPT + o-series Native tracing

OpenAI's first-party agent framework, second iteration.

The OpenAI Agents SDK (openai-agents on PyPI, @openai/agents on npm) is OpenAI's official agent framework. It launched in 2025 as the successor to the older Assistants API, addressing the production gaps that platform had: opaque execution, limited debugging, no clean handoff pattern between agents, no first-party MCP integration. The new SDK is open source, available in Python and TypeScript with a third-party Go port, and ships under a permissive licence.

The thesis: OpenAI knows how their models behave best. The SDK encodes those production patterns — structured handoffs, declarative guardrails, automatic tracing, MCP-first tool integration — rather than leaving teams to invent them. For agents that run on GPT-4.x, GPT-5, or the o-series reasoning models, the Agents SDK is the framework that's tested against the model behaviour you actually get.

Distribution: the SDK works against the OpenAI Platform, Azure OpenAI Service, and any OpenAI-compatible endpoint (Ollama's localhost:11434, OpenRouter, vLLM-served open-weights models). That last point matters — despite the name, the SDK is not strictly OpenAI-only; it's optimised for OpenAI but works with any compatible model API.

Naming · "agents" SDK vs the basic SDK

Two OpenAI things sound similar. The openai SDK (Python / TS) is the basic API client — chat completions, tool use, streaming. The openai-agents SDK is the higher-level agent framework — this leaf. They're separate packages. The agent SDK depends on the basic SDK under the hood, but adds the five primitives and the tracing infrastructure. If you read about the "OpenAI Agents SDK" or "openai-agents," that's the framework this leaf covers.

Five primitives that map cleanly to production patterns.

Each primitive solves a specific production-agent problem. Together they cover the day-to-day shape of building agents that need to delegate to specialists, run safely, and produce auditable execution traces — without bringing in heavier framework abstractions.

Primitive 01

Agents

The unit of work. Has a model, instructions, tools, and optionally sub-agents to hand off to. Created via Agent(name, instructions, model, tools).

Primitive 02

Handoffs

Structured way for one agent to delegate to another mid-conversation. The receiving agent inherits context. Solves the "how do I escalate from triage to specialist" question cleanly.

Primitive 03

Tools

Plain functions decorated with @function_tool. The SDK introspects signatures for JSON-Schema. MCP servers, hosted OpenAI tools (web search, file search, computer use), and external APIs all integrate.

Primitive 04

Guardrails

Declarative input/output validators that run alongside the agent. Catch policy violations, flag PII, enforce structured-output schemas. Halt execution or trigger fallback behaviour.

Primitive 05

Tracing

Automatic. Every agent run produces a structured trace visible in the OpenAI Platform dashboard. Spans for handoffs, tool calls, LLM calls, guardrail evaluations. The most polished out-of-the-box observability of any framework.

Cross-cutting

Sessions

Persistent conversation history with automatic context management. The SDK handles trimming and continuation; you pass session_id and it works.

The minimal Agent in Python:

# pip install openai-agents
from agents import Agent, Runner

agent = Agent(
    name="Assistant",
    instructions="You help users analyse JSE market data.",
    model="gpt-5",
)

result = await Runner.run(agent, "What's been driving SA bond yields this quarter?")
print(result.final_output)

Tools as Python functions. Decorate; the SDK does the rest:

from agents import Agent, function_tool

@function_tool
def get_market_data(symbol: str, days: int = 30) -> dict:
    """Fetch recent market data for a JSE-listed symbol."""
    return fetch_from_jse_api(symbol, days)

agent = Agent(
    name="JSE Analyst",
    model="gpt-5",
    tools=[get_market_data],
)

Handoffs — the OpenAI SDK's signature primitive. A triage agent routes to specialist agents based on the user's intent:

from agents import Agent, handoff

billing = Agent(name="Billing",
                instructions="Handle billing-related questions.")
technical = Agent(name="Technical",
                  instructions="Handle technical issues.")

triage = Agent(
    name="Triage",
    instructions="Route to the right specialist.",
    handoffs=[billing, technical],  # SDK creates handoff tools automatically
)

Guardrails as declarative validators. The SDK halts the agent if a guardrail trips:

from agents import Agent, GuardrailFunctionOutput, input_guardrail

@input_guardrail
async def no_pii(ctx, agent, input_text):
    has_pii = await classify_pii(input_text)
    return GuardrailFunctionOutput(
        output_info={"has_pii": has_pii},
        tripwire_triggered=has_pii,
    )

agent = Agent(name="Public Assistant",
              model="gpt-5",
              input_guardrails=[no_pii])

Tracing as a structural advantage

Every agent run is automatically traced and visible in the OpenAI Platform dashboard at platform.openai.com/traces. Spans for every LLM call, every tool call, every handoff, every guardrail evaluation. You don't wire it up — it's on by default. For production debugging this is a meaningful advantage over LangGraph (where LangSmith is paid) and Anthropic SDK (where you wire up OTel yourself).

OpenAI Platform, Azure OpenAI, the broader API ecosystem.

The Agents SDK lives inside OpenAI's broader platform: the model API, the Tracing dashboard, the hosted tools (web search, file search, computer use, code interpreter), and the deployment surfaces. For SA enterprise, Azure OpenAI is the parallel surface — same models, regional residency options, Microsoft's enterprise contracting model.

Library

openai-agents

Python and TS SDKs. Open source. Self-host anywhere — Lambda, Cloud Run, Fly, your laptop, Cloudflare Workers via Node-compat.

Platform

OpenAI Platform

Hosts the API + Tracing + Evals + Files. Free tier; usage-based billing. The default deployment surface for SDK-built agents.

Enterprise

Azure OpenAI

Microsoft's parallel hosting. Same models, enterprise contracting, regional availability including SA via South Africa North. The path for SA enterprise that needs Microsoft / Azure compliance posture.

Hosted tools

Web search, file search, computer use

OpenAI hosts a small set of "first-party" tools the SDK exposes. Web search is best-known; file search is a managed RAG layer; computer use is OpenAI's vision-driven UI control.

The Realtime API is separate

OpenAI's voice / audio agents use the Realtime API — that's a separate WebSocket-based interface, not part of the Agents SDK. For text-and-tool agents, this SDK is the path. For bidirectional voice, Realtime API is. Some teams build hybrid systems where the Realtime endpoint terminates user voice and dispatches to Agents-SDK-managed text agents for actual reasoning.

Where the OpenAI SDK fits.

The OpenAI SDK and Anthropic SDK are mirror images: each is the first-party framework for one frontier vendor. Same shape (tool-use loop + sub-agent delegation + MCP) but different vendor alignment. LangGraph and ADK are the cross-vendor alternatives. Choose based on which model and cloud you're already on.

DimensionOpenAI Agents SDKAnthropic Agent SDK
Default modelGPT + o-series (works against any OpenAI-compatible API)Claude-only
Sub-agent patternHandoffs (peer transfer)Task tool (parent spawns)
Built-in tracingOpenAI Platform dashboard, on by defaultOTel + Anthropic console
GuardrailsFirst-class primitiveBuild your own with hooks
Reasoning model integrationNative (o-series)Native (extended thinking)
MCP supportNativeNative (Anthropic-originated)
Hosted toolsWeb search, file search, computer useComputer use; web search via MCP server
VoiceSeparate Realtime APISeparate audio endpoints
Best fitProduction agents on GPT, teams on OpenAI/AzureProduction agents on Claude, MCP-heavy stacks

The honest cross-SDK answer

Pick the vendor SDK that matches your model. If you're on GPT, use the OpenAI Agents SDK; if you're on Claude, use the Anthropic Agent SDK. The first-party SDKs give you tracing, model-specific optimisations, and tighter integration with their respective tooling. Use LangGraph when you want explicit graphs or vendor-neutral. Use ADK when you're on GCP. Use multiple together via A2A when production has multiple surfaces.

Where the OpenAI SDK earns its keep.

Six patterns that play to the SDK's strengths: structured handoffs, guardrails, automatic tracing, hosted tools, OpenAI's reasoning quality.

  • Customer support routing & handoff — the SDK's signature use case. A triage agent classifies and hands off to billing / technical / sales specialists. Handoff primitives + guardrails + tracing make this the cleanest framework for this pattern.
  • Function-calling-heavy backend agents — OpenAI's function-calling has been the most reliable in the field since 2023. SDK + GPT for any agent where structured tool dispatch is the load-bearing capability.
  • RAG-driven assistants — pair the SDK with OpenAI's hosted file_search tool for the path-of-least-resistance RAG. Self-hosted vector DBs work too via custom tools, but file_search is the fastest "ask the company" agent.
  • Reasoning workflows on o-series — o3 / o-series models for problems that need explicit thinking. The SDK handles routing the reasoning context cleanly; sub-agents on cheaper tiers handle the simpler steps.
  • Computer-use agents — OpenAI has its own computer-use API (vision + clicks). The SDK wraps it. Useful for legacy SaaS automation where there's no API to call.
  • Internal automation with audit trails — the automatic tracing dashboard means "every agent run, every tool call, every handoff" is searchable in the OpenAI Platform. Audit becomes a UI query rather than custom logging.

Pick the OpenAI SDK when. Skip when.

Same logic as the Anthropic SDK leaf: if you've picked GPT as the model, this SDK is the natural choice. If you haven't, the model decision drives the framework decision. Picking the SDK without GPT only makes sense if you're using its OpenAI-compatible-API support to drive Ollama or vLLM — in which case the SDK is doing less work for you than its first-party path.

Use OpenAI SDK when

  • GPT or o-series is your model — first-party SDK support is the win
  • Handoffs match your delegation pattern (peer transfer between specialists)
  • You want declarative guardrails baked in
  • Built-in tracing without setup matters — the OpenAI Platform dashboard is genuinely good
  • You're on Azure OpenAI for enterprise compliance posture
  • OpenAI's hosted tools (file_search, web_search, computer use) fit your use case
  • Function-calling reliability is load-bearing

Where this lands in SA delivery work.

Enterprise · Azure OpenAI in South Africa North

The Azure OpenAI Service hosts GPT models in Azure South Africa North (Johannesburg) for SA-resident inference, with Microsoft enterprise contracting and POPIA-compliant data handling. For SA banks, insurers, and telcos with existing Microsoft / Azure relationships, this is the structurally clean answer for OpenAI-on-OpenAI workloads. Caveats: not every model is available in every region (newest GPT releases sometimes lag US regions by weeks or months), and Azure pricing differs from OpenAI Platform pricing.

Studio · OpenAI Platform direct

For studios without enterprise residency requirements, going direct to OpenAI Platform is simpler and usually cheaper. Free tier covers pilots; usage-based billing scales to production. Tracing, evals, and prompt management all on the same Platform dashboard. The OpenAI ecosystem moves fast — new models / features land on Platform first, Azure second.

FX exposure mitigations

OpenAI is USD-billed. At pilot volume the cost is minor; at production volume it's a real line item. Same mitigations as the Claude leaf apply: tier routing (use cheaper models for routine traffic, escalate to flagship only when needed), prompt caching (OpenAI added this in late 2024 — significant cost saver for RAG and long-system-prompt agents), and the Batch API for nightly workloads (~50% discount). For SA studios watching FX, all three are worth wiring in from day one.

Where the OpenAI SDK links in the tree.

Primary sources.