Agents
9 min read

OpenAI Agents API Explained: How It Works, What It Costs, and How It Compares to Claude's Agent SDK and Managed Agents

OpenAI's Agents API runs the Codex harness as a hosted service: you send a task, tools and a sandbox choice, and OpenAI runs the loop. Here is how it works, what it costs, its limits, and how it compares with the Claude Agent SDK and Claude Managed Agents.

OpenAI Agents API Explained: How It Works, What It Costs, and How It Compares to Claude's Agent SDK and Managed Agents

OpenAI's Agents API went into public beta on September 10, 2026. It lets a developer start a long-running agent with one API call while OpenAI runs the agent loop on its own servers. That loop is the same harness that runs Codex. The name causes confusion, because OpenAI also ships an Agents SDK and Anthropic ships both a Claude Agent SDK and a hosted product called Claude Managed Agents.

This explainer covers what the Agents API does, what it costs, and where it is limited. It then compares it with the Claude Agent SDK and Claude Managed Agents. All facts come from OpenAI and Anthropic documentation as of October 2026.

The short version

  • What it is: a hosted agent service. You send a task, a model, tools, and an environment. OpenAI runs the loop, keeps the session, and manages context.
  • What it is not: the OpenAI Agents SDK. The SDK is a library that runs the loop inside your own application.
  • Where code runs: in an OpenAI-hosted sandbox, in a sandbox you run yourself, or nowhere at all if the agent only calls tools.
  • Cost: OpenAI charges no extra fee for the API. You pay model tokens, tool fees, and container rates for hosted sandboxes.
  • Main limits: it is a beta, data residency is United States only, and it is not eligible for Zero Data Retention.
  • Closest Claude equivalent: Claude Managed Agents, not the Claude Agent SDK.

What the Agents API does

The Agents API overview describes four building blocks:

  • Agent: the model, instructions, tools, and MCP servers the agent can use.
  • Environment: an optional sandbox or computer where the agent reads files, loads skills, and runs commands.
  • Session: a durable instance of the agent that works on tasks and accepts more input.
  • Events and items: the inputs you send and the output the agent produces.

A typical run has four steps. You create a session, give it a task, follow progress through streaming or webhooks, and then send a follow-up or steer the agent while it works. In the sessions guide, each cycle of work is a "turn." A message sent to an idle session starts a new turn. A message sent during an active turn steers that turn. Turns run asynchronously, so your application does not have to hold a connection open while the agent works.

The launch post's code sample shows the idea. It creates a session on gpt-6-astra with an MCP server for observability data, enables subagents with a limit of three running at once, attaches a credential vault, and asks the agent to investigate a rise in 5xx errors and save its findings to /workspace/outputs. (For the model itself, see our GPT-6 Astra explainer.)

What the managed harness handles for you

The selling point is the parts of an agent that most teams end up building by hand. OpenAI's launch post and docs list these:

  • Context compaction. As a session nears the model's context limit, the API compacts earlier context automatically, so a task can span more than one context window.
  • Tool search. Tool definitions load only when they are relevant, which OpenAI says reduces token use and keeps the prompt cache intact.
  • Programmatic tool calling. The agent can run tool calls in parallel, chain them, and filter results in code, so only the useful part comes back into context.
  • Subagents. With multi-agent support on, the main agent splits a task and hands pieces to subagents that each keep their own context. The multi-agent guide sets the default limit at six concurrent subagents, not counting the coordinator.
  • Resume and steering. Sessions keep their state, so the agent can pick up where it left off.
  • Tools. The API supports MCP servers, custom functions that your code runs, and built-in tools such as web search.

OpenAI says the harness is the open-source Codex harness, so developers can read the logic that coordinates model calls, tools, and context. OpenAI runs and updates it, and the launch post says new model capabilities arrive as versioned harness updates with each model launch.

Three environment options

The architecture page gives three choices for where the agent works.

No environment. Set environment.type to none for an agent that only answers questions or calls remote tools. In this mode the built-in Bash and apply-patch tools, workspace files, and executor MCPs are not available.

OpenAI-hosted sandbox. Set the type to openai_hosted and OpenAI provisions a Linux workspace with Python, Node.js, and command-line tools. According to the hosted sandbox docs, you can:

  • pick a size: small (1 vCPU, 1 GB), medium (2 vCPU, 4 GB, the default), or large (4 vCPU, 16 GB)
  • install Python, system, or npm packages
  • supply input files
  • run setup commands before the agent starts
  • control network access

Files under /workspace/outputs are published as immutable artifacts at the end of each turn, and those copies stay downloadable after the sandbox is gone. One detail to plan around: if activity and keep-alives stop for an hour, the sandbox can be deleted, and that timeout cannot be changed.

Self-hosted sandbox. Set the type to self_hosted when the agent needs your own image, compute, or private network. You run codex exec-server, which OpenAI calls the executor, inside your environment. It registers with a restricted API key, connects out over WebSocket, and runs the commands the harness requests. The self-hosted guide says the environment can be a laptop, a container, or a remote sandbox. You own provisioning, reconnection, and shutdown. OpenAI also lists sandbox partners with integrations: Blaxel, Cloudflare, Daytona, DigitalOcean, E2B, Modal, Oracle, Runloop, and Vercel. Our earlier comparison of agent sandboxes covers several of these providers.

Diagram comparing who runs the agent loop: OpenAI Agents SDK and Claude Agent SDK run in your app, OpenAI Agents API and Claude Managed Agents run on the vendor's servers

Keeping secrets out of the sandbox

Agents that call real services need credentials, and a key pasted into a prompt or a sandbox can leak. The Agents API uses vaults for this. You attach a vault to a session with vault_ids.

  • For MCP servers that OpenAI connects to, a vault holds a static bearer token or MCP OAuth credentials.
  • For API calls from a hosted sandbox, the sandbox gets only a placeholder in an environment variable. A network proxy swaps in the real secret, and only for the exact hosts you approve.

Printing the variable inside the sandbox shows the placeholder, not the token. The placeholder method works only in OpenAI-hosted environments. It does not supply credentials to self-hosted environments or to function tools your application runs.

What it costs

OpenAI's launch post says "there are no additional fees for using the Agents API." The overview's pricing section breaks the bill into three parts:

  • model tokens at the selected model's normal API rates
  • OpenAI tools at their standard rates
  • OpenAI-hosted sandboxes at standard container rates

On OpenAI's pricing page as of October 2026, containers cost $0.03 for 1 GB, $0.12 for 4 GB, and $0.48 for 16 GB per 20-minute session per container. The page says eligible container sessions are billed by the minute with a 5-minute minimum. A self-hosted sandbox avoids OpenAI's container charge, but you pay for that compute yourself.

Limits to know before you build

  • Beta. Requests need the OpenAI-Beta: agents=v1 header (the SDKs add it), and OpenAI says it will iterate quickly as it works toward general availability.
  • Data residency and retention. The overview says the Agents API "currently supports data residency only in the United States and does not support Zero Data Retention." OpenAI adds that choosing a self-hosted sandbox does not make the Agents API eligible for Zero Data Retention.
  • API key scopes. The quickstart asks for api.agents.read and api.agents.write for sessions, plus api.responses.write for model calls.
  • Function tools need a live handler. If your function handler is down, the agent can sit waiting for a result.

Agents API vs the OpenAI Agents SDK

The two names differ by one word, and they are different products. OpenAI's runtime comparison puts it this way:

  • Agents API: OpenAI runs a managed Codex harness. OpenAI rates integration effort as low. Session configuration, turns, and items are saved for you.
  • Agents SDK: the SDK runs inside your application. OpenAI rates integration effort as medium. State lives in your storage and SDK sessions.
  • Responses API: you call models directly and build the agent yourself. OpenAI rates integration effort as high.

In practice, the Agents SDK suits teams that want the loop, approvals, and storage in their own process. The Agents API suits teams that would rather not run agent infrastructure at all.

How it compares with Claude

Anthropic has two products that people compare with the Agents API, and only one is a direct match.

The Claude Agent SDK is, in Anthropic's words, a way to "build production AI agents with Claude Code as a library." The Agent SDK overview says it gives you the tools, agent loop, and context management that power Claude Code, in Python and TypeScript. It includes:

  • built-in tools for files, commands, and web search
  • hooks, subagents, and MCP
  • permissions, sessions that can resume or fork, and skills
  • plugins and project memory from .claude/ folders

It runs in a process you operate. That makes it closer to the OpenAI Agents SDK than to the Agents API. Use of the SDK falls under Anthropic's Commercial Terms of Service. Anthropic also says third-party developers may not offer claude.ai login or its rate limits in their products unless Anthropic approved it in advance, so SDK apps use API keys.

Claude Managed Agents is the real counterpart. The Managed Agents overview describes a "pre-built, configurable agent harness that runs in managed infrastructure," built on four concepts that line up closely with OpenAI's: agent, environment, session, and events. Sessions run in an Anthropic-managed cloud sandbox or in a self-hosted sandbox on your own infrastructure. Built-in tools cover Bash, file operations, web search and fetch, and MCP servers. Anthropic also lists scheduled deployments that run agents on a cron schedule. Managed Agents is in beta behind the managed-agents-2026-04-01 header. Like the Agents API, it is not eligible for Zero Data Retention, and Anthropic adds that it is not covered by a HIPAA Business Associate Agreement.

The pricing models differ. Anthropic's pricing page bills Managed Agents on tokens plus $0.08 per session-hour. Runtime counts only while a session's status is "running." Idle time spent waiting for your next message or a tool confirmation is not billed. That runtime charge replaces container-hour billing, and web search inside a session costs the standard $10 per 1,000 searches. Anthropic's worked example is a one-hour coding session on Claude Opus 5.5 with 50,000 input tokens and 15,000 output tokens, which comes to $0.58 in total. (Our Claude Opus 5.5 explainer covers the model's own pricing.)

Panel comparing extra charges beyond tokens: OpenAI Agents API has no API fee and charges container rates for hosted sandboxes; Claude Managed Agents charges $0.08 per session-hour of running time

Side by side, as of October 2026:

  • Who runs the loop: OpenAI for the Agents API, Anthropic for Managed Agents. With either SDK, you do.
  • Sandbox choices: the Agents API offers OpenAI-hosted, self-hosted, or no sandbox. Managed Agents offers an Anthropic cloud sandbox or a self-hosted one.
  • Extra fee beyond tokens and tools: the Agents API charges container rates only when OpenAI hosts the sandbox. Managed Agents charges $0.08 per running session-hour, with container time included.
  • Scheduling: Anthropic documents cron-based scheduled deployments for Managed Agents. OpenAI's Agents API docs describe webhooks and asynchronous turns.
  • Status: both are in beta, and neither is eligible for Zero Data Retention.

Which one to pick

Pick by where you want the agent loop to live, then by model.

  • You want to own the loop, logs, and storage. Use the OpenAI Agents SDK or the Claude Agent SDK. The Claude SDK is the quicker path if you want Claude Code's built-in file and shell tools as they are.
  • You want a hosted agent and already build on OpenAI models. The Agents API removes the work of running agent loops, compaction, and subagent orchestration. The vault proxy is a useful feature of OpenAI-hosted sandboxes for agents that call third-party APIs.
  • You want a hosted agent on Claude models. Claude Managed Agents is the equivalent. Its runtime fee is a flat hourly rate, and idle time is not billed.
  • You have strict data rules. Check residency and retention first. Both hosted options keep session state on the vendor's side and neither offers Zero Data Retention.

Model quality matters as much as the harness for coding work. Our Cursor vs Claude Code vs Codex comparison covers how the two labs' agents perform as products.

What OpenAI's customers said

The launch post quotes beta customers. These are results the customers reported and OpenAI chose to publish, not independent tests. SafetyKit reported "a 60% reduction in cost per case" after moving a case review workflow. Hypha said separating the harness from the sandbox "reduced failed agent responses by 86%." Ciridae said its evaluation score rose from 0.71 to 0.85 and that subagent support gave it "a 4x latency reduction."

What to watch

The Agents API is still a beta, so check the docs again before you build on fields like environment types or vault settings. OpenAI's overview also points to Bedrock Managed Agents, an AWS service built on the Agents API, and Anthropic offers Managed Agents on Claude Platform on AWS. So both labs now offer hosted agents through AWS as well as through their own APIs. The next questions are when each product leaves beta, and whether either adds Zero Data Retention or data residency outside the United States.

Sources

AgentsOpenAIAnthropic