OpenAI · 2026-09-10 · major
OpenAI Agents API — the Codex harness opens up to developers
OpenAI's Agents API is in public beta. It gives any app the managed Codex harness, so OpenAI handles session state, context compaction and recovery while your code supplies the tools and picks where the agent runs.

The harness behind Codex, now a managed API: OpenAI runs the agent loop, your app brings the tools.
Quick facts
| Maker | OpenAI |
|---|---|
| Status | Public beta |
| Beta header | OpenAI-Beta: agents=v1 |
| Model in the docs | gpt-6-astra |
| Environments | OpenAI-hosted or self-hosted sandbox |
| Extra fees | None beyond model, tool and container rates |
| Data residency | United States only; no zero data retention |
What is it?
The Agents API hands applications the same managed harness that runs Codex. OpenAI keeps the session alive, compacts the context when it fills up, and recovers after failures, while your application supplies the instructions, the tools and the MCP servers. Public beta opened on September 10, 2026.
How does it work?
Four objects make up the design: an Agent (model, instructions, tools and MCP servers), an optional Environment sandbox, a durable Session, and the events that session streams back. Inside a session the Agents API can run code, edit files, search the web, apply skills, produce artifacts and split work across subagents with a set concurrency limit. Sandboxes run either on OpenAI's infrastructure or on your own, and every call carries the header OpenAI-Beta: agents=v1.
Why does it matter?
Teams building long-running agents normally write the hard parts themselves — resuming a session, trimming context before the window fills, retrying after a crash, coordinating subagents. Moving all four to OpenAI costs nothing beyond the usual model, tool and container rates, so a small team can ship a durable agent without owning an orchestration layer. The catch is residency: the Agents API is United States only and is not eligible for zero data retention, even on a self-hosted sandbox.
Who is it for?
developers building long-running agents
Frequently asked questions
- How much does the OpenAI Agents API cost?
- The Agents API adds no fee of its own. OpenAI bills model usage at the selected model's normal API rates, plus standard charges for OpenAI-provided tools and for container usage. A session driven by gpt-6-astra therefore costs what those same tokens cost through any other OpenAI endpoint, with sandbox container time billed on top.
- Can the Agents API run inside my own infrastructure?
- Yes. The Agents API offers two environment types: an OpenAI-hosted sandbox and a self-hosted sandbox you provide. OpenAI's documentation is explicit that choosing the self-hosted option does not make the Agents API eligible for zero data retention, so regulated workloads still have to account for retained session data.
- Is the OpenAI Agents API available outside the United States?
- Data residency for the Agents API is limited to the United States during the public beta, and zero data retention is unsupported no matter which sandbox type is selected. Teams that must keep agent sessions inside the EU or another region cannot meet that requirement with the Agents API today.
- How does the Agents API differ from writing my own agent loop?
- A hand-built loop makes your code responsible for session state, context compaction, crash recovery and subagent coordination. The Agents API keeps all four on OpenAI's side and streams progress events back, which leaves your application to define instructions, tools and MCP servers and to choose where code actually executes.
Try it
pip install --upgrade openai