OpenAI Agents API: The Codex Harness, Now Public
OpenAI put its Agents API into public beta on September 10, 2026, and the thing to understand about it is that it is not really a new model or a new framework. It is the harness. The same orchestration layer that runs Codex, OpenAI’s coding agent, and that underpins the agentic parts of ChatGPT, is now exposed behind a single API call. If you are tracking the best AI tools 2026 has produced for building agents, this one changes the calculus, because it shifts a big chunk of the plumbing you currently write yourself onto OpenAI’s infrastructure.
The pitch is straightforward: you bring your tools and choose your execution environment, and OpenAI manages the parts that are genuinely hard and boring. Sessions, orchestration, context compaction, and recovery from failed runs all become someone else’s problem. Your application stops being a state machine you maintain and starts being a loop you describe. Whether that trade is worth it depends on how much of that plumbing you are currently maintaining by hand, and for a lot of teams the answer is “more than I want to admit.”
What the Agents API actually gives you
The headline capability is the Codex harness as a managed service. Codex has spent years tuning the machinery that lets a model work on a real task for a long time: it opens files, runs code in a sandbox, edits things, recovers when a step fails, and keeps its context coherent across hours of work. The Agents API exposes that same machinery to your application.
The individual pieces matter because they are the parts most developers hand-roll today. There are managed sessions, which hold the state of a running agent so you do not have to persist and restore it yourself. There is automatic context compaction, which decides when the conversation has grown too long and summarizes the old parts so the model does not run out of context window. There is recovery, which means a run that crashes mid-task can resume rather than starting over. There are subagents, so a parent agent can spawn focused workers for subtasks. And there is tool use, including MCP, the Model Context Protocol, which lets you attach external tools and data sources the way a USB-C port standardizes peripherals.
The execution side is flexible in a way that matters. You can use OpenAI-hosted sandboxes, or bring your own, and the beta launched with a set of partner sandboxes. Agents run in a sandbox where they can execute code, edit files, connect to MCP servers, and produce artifacts, which is exactly the environment a coding or operations agent needs to do real work.
What building on it looks like
The shape of the API is deliberately small. You create a session, which is the persistent thread your agent works in, you define what tools it can call, and you hand it a task. The loop that runs “model decides, model calls a tool, tool returns a result, model decides again” is handled for you, as is the bookkeeping of keeping that session alive across minutes or hours.
from openai import OpenAI
client = OpenAI()
# A long-running agent session, managed by the harness
session = client.agents.sessions.create(
model="gpt-6-astra",
instructions="You are a release engineer. Investigate and fix the failing build.",
tools=[
{"type": "mcp", "server": "https://mcp.example.com/build-tools"},
{"type": "sandbox_shell"},
],
)
run = client.agents.sessions.runs.create(
session_id=session.id,
input="The CI pipeline is red on the deploy step. Find out why.",
)
The notable part of that snippet is what is not in it. You are not writing a retry loop, not chunking the context yourself, and not persisting state between calls. The harness owns those, and the abstraction is that a session is a durable thing you keep poking rather than a stateless request you keep re-issuing. That is a meaningfully different programming model from a chat completion, and it is the reason the API exists as its own product rather than a wrapper.
There is a trade baked into that convenience worth naming early. The more the harness owns, the less you see of what it is doing under the hood. For a build-fix agent that trade is almost always worth it. For a task where you need to prove to an auditor exactly what the agent did and why, the opacity becomes a cost. Which side of that line you are on is the first question to answer before you reach for this API.
Pricing: the harness is free, the tokens are not
The pricing model is the second thing worth understanding, because it is unusual. During the public beta, OpenAI is not charging a separate fee for the Agents API itself. You pay for the model tokens your agent consumes, for any paid tools, and for the container or sandbox time. The harness, the orchestration layer that would have been a product on its own, is free.
In practice, that means your bill is dominated by the model you point the agent at. If you run an agent on GPT-6 Astra, you are looking at roughly $10 per million input tokens and $50 per million output tokens, plus whatever the sandbox costs. If you run it on a cheaper model, your costs drop accordingly. The strategic read here is clear: OpenAI is betting that giving away the orchestration will drive a lot of token consumption, and that the lock-in from your agents living on OpenAI’s harness is worth more than charging for the harness directly.
An AI agent framework comparison: how it stacks up
The right way to evaluate the Agents API is against the other ways you could build an agent in 2026. Here is how it compares to the three main alternatives.
OpenAI Agents SDK. This is the library OpenAI already ships for building agents in Python and TypeScript, and it is worth being precise about the difference. The SDK is code you run yourself; the Agents API is a hosted service that manages the execution for you. The SDK gives you control and portability, and it runs anywhere, including against other model providers. The Agents API gives you managed infrastructure but ties you more tightly to OpenAI’s cloud. They are not competitors so much as two points on a spectrum, and the API is likely to matter most to teams that want the harness without operating it.
LangChain and LangGraph. These are the open-source stalwarts, and they are the strongest “control and no lock-in” answer. LangGraph gives you explicit graph-based orchestration where you can see and modify every transition. The Agents API gives you a managed loop where OpenAI handles the details and you give up some visibility. If you have a team that maintains a LangGraph deployment, the Agents API is not obviously better. If you are a smaller team that does not want to run that infrastructure, the API is the faster path to something working.
Claude Code and other managed coding agents. These are products, not platforms, but they are relevant because they prove the value of the harness model. Claude Code and Codex both work well because someone spent enormous effort on the orchestration underneath. The Agents API is OpenAI’s bet that you want that orchestration for your own agent, not just for a coding assistant, and that you are willing to build your tooling on their rails to get it.
Rolling your own harness. This is the baseline most teams forget to price. Sessions, compaction, recovery, sandbox management, and tool routing are all things you can build, and they are all things that take real engineering time to make robust. The Agents API’s value proposition is essentially “stop building this.” Whether that is a good deal depends on your team’s size and how differentiated your orchestration needs actually are.
Who should use it
Use it if you are building an agent that needs to run for a long time, execute code, and edit files, and you do not have a dedicated team to maintain the orchestration layer. The managed sessions and automatic compaction solve the two problems that kill most long-running agents, and you get them for free during the beta.
Use it if you are already committed to OpenAI’s models and you want to ship an agent quickly. The token pricing is the dominant cost either way, so if you are already paying for GPT-6 Astra or similar, adding the harness does not change your economics much, and it accelerates your timeline.
Use it if you want MCP and custom tools wired into a managed environment without building the integration yourself. The standardization MCP brings is real, and having it managed for you removes a chunk of boilerplate.
Who should not use it
Skip it if you need to run against multiple model providers or self-host your inference. The Agents API is an OpenAI service, and while it can attach external tools, the orchestration and the default model ecosystem are OpenAI’s. If you are running open models on your own GPUs, you will want the SDK or an open framework instead.
Skip it if you need full visibility and control over every step of the orchestration. Managed services abstract away the details, and if your use case is sensitive enough that you need to audit exactly how context is compacted or how a run was recovered, the black box will frustrate you.
Skip it if you are worried about lock-in. The harness being free is a classic land-and-expand move, and once your agents are built on OpenAI’s orchestration, moving them elsewhere is not free. If portability is a hard requirement, the open frameworks remain the safer bet.
Limitations and caveats
It is a public beta, and that word should carry weight. APIs change, features get pulled, and the pricing could shift when the beta ends. The fact that there is no separate fee today is a beta policy, not a commitment, and you should build with the understanding that the economics may look different in six months.
The lock-in concern is the second caveat, and it cuts deeper than usual because this is orchestration, not just a model. Swapping a model is easy; swapping the harness your entire agent is built on is not. The more of your agent’s behavior lives in OpenAI’s managed sessions and compaction, the more it costs to leave.
Finally, managed context compaction is a double-edged sword. It keeps long runs alive, but it also means the model is sometimes working from a summarized view of its own history rather than the raw transcript, and summaries lose information. For tasks where a dropped detail is catastrophic, you will want to understand exactly what the harness is doing to your context before you trust it with the critical path.
Sources
- OpenAI: Introducing the Agents API
- OpenAI API docs: Agents API overview
- The Decoder: OpenAI’s new Agents API gives developers the infrastructure behind Codex and ChatGPT
- AiCybr: OpenAI Agents API — Codex Harness, hosted sandboxes, subagents and pricing
- MarkTechPost: OpenAI Launches the Agents API in Public Beta