AI Tools Developer Tools

OpenAI Agents API Opens in Public Beta With the Codex Harness Built In

OpenAI's Agents API gives developers the Codex agent harness through one API, with hosted or self-hosted sandboxes.

Building an AI agent that works for hours takes more than a good model. The agent needs a harness, the software that manages its memory, calls its tools and coordinates helper agents. It also needs a safe place to run code and keep files. OpenAI has now opened up its own version of both. The OpenAI Agents API, in public beta, gives developers the same harness and infrastructure that power Codex, OpenAI’s coding agent.

OpenAI says it built this from running Codex and ChatGPT for Work for millions of people. The Agents API is available to all developers, and there is no extra fee for the API itself. Customers pay for the tokens and tools their agents use.

What the API Does

With the Agents API, a developer creates an agent in one call by naming the task, the model, the tools and the environment it runs in. OpenAI hosts and maintains the harness. According to the documentation, OpenAI handles sessions, orchestration, context compaction and recovery, while the developer’s application supplies the tools and picks where the agent runs.

The documentation describes four building blocks:

  • Agent: the model, instructions, tools and MCP servers it can use.
  • Environment: an optional sandbox or computer where the agent reads files, loads skills and runs commands.
  • Session: a lasting instance of the agent that works on tasks and responds to input.
  • Events and items: what goes into the agent and what comes out during a session.

A developer creates a session, gives it a task and follows progress through a live stream or webhooks. The agent can be steered while it works, given another task in the same session, or resumed later where it stopped.

Where Agents Run

There are three options for the agent’s computer. OpenAI offers a hosted sandbox that uses the same infrastructure as Codex and ChatGPT, and can be loaded with files, packages, skills and plugins. Teams can also run the environment on their own infrastructure.

The third option is a partner. OpenAI names Blaxel, Cloudflare, Daytona, DigitalOcean, E2B, Modal, Oracle, Runloop and Vercel. These cover needs such as running inside a company’s private cloud network, specific ways of storing files and secrets, and different CPU, GPU and memory setups.

What the Harness Adds

OpenAI’s argument is that a harness needs constant work every time models improve. With the Agents API, OpenAI maintains it alongside its models and offers versioned access with each model launch. The announcement highlights three recent improvements:

  • Long sessions. As a session nears the model’s context limit, the API automatically compacts earlier context and keeps what the agent needs. Developers do not have to write their own compaction, a technique explained in our guide to context engineering for AI agents.
  • Many tools. Tool search loads tool definitions only when needed, which saves tokens. Programmatic tool calling lets the agent run calls in parallel, chain them and filter results in code, so only the relevant results come back into its context. The API supports MCP, custom functions and built-in tools such as web search.
  • Subagents. The API can split a task into independent parts and hand them to subagents working in parallel, each with its own context, while a main agent combines the results.

The harness itself is open source. OpenAI runs and maintains it in the API, but the code is public in the Codex repository on GitHub, so developers can see how it coordinates model calls, tools and context.

Pricing and Limits

Model use is billed at the chosen model’s normal API rates. OpenAI’s tools use their standard prices, and OpenAI-hosted sandboxes are billed at standard container rates.

The documentation lists two limits that matter for many companies. The Agents API currently keeps data only in the United States. It also does not support Zero Data Retention, OpenAI’s option for not storing request data. According to the documentation, running the sandbox on a company’s own servers does not change that.

As a public beta, the API may still change. OpenAI says it will iterate quickly based on feedback before general availability.

Questions Before Building on It

  • Does the lack of Zero Data Retention and the US-only data residency fit the company’s data rules?
  • Should the agent run in OpenAI’s sandbox, on the company’s own infrastructure or with a partner?
  • How will costs be tracked when a single session can run for hours and start several subagents?
  • Is it acceptable to depend on a harness that OpenAI updates alongside its models?

For teams that do not want to build and maintain their own agent harness, the Agents API removes much of that work. The trade-off is less control over data handling and closer ties to OpenAI’s platform.

Sources