On September 10, OpenAI handed every developer with an API key the infrastructure that has been running Codex and ChatGPT for Work: managed sessions, automatic context compaction, subagent coordination, and nine partner compute environments. They’re calling it the Agents API, it’s in public beta, and there’s no extra fee. If you’ve been rebuilding session persistence and context-overflow logic from scratch in every agent project, that problem is now optional.
What You’re Actually Getting
The Agents API is not a new model and not a new pricing tier. It’s OpenAI’s internal orchestration harness, repackaged as an API endpoint. Here’s what that means in practice:
- Durable sessions: Sessions are server-keyed by
session_id. Your app sends follow-up messages and full context resumes — no manual history replay, no state management in your code. If the session hits a rate limit or a transient error, it persists and picks up where it left off. - Automatic context compaction: When a session approaches the model’s context window limit, OpenAI compacts earlier context automatically. You don’t trim message histories. You don’t hit overflow errors mid-task.
- Subagent coordination: An agent can delegate subtasks to subagents, each with their own context window. Concurrency is configurable. Long-running workflows that previously required you to build multi-agent infrastructure get this for free.
The code path is straightforward. Create a session, stream events, handle results:
from openai import OpenAI
with OpenAI() as client:
with client.beta.agents.sessions.create(
agent={
"model": "gpt-6-astra",
"instructions": "Write clean code, run it, and report the actual output.",
},
environment={"type": "openai_hosted"},
input="Create tree.py and show me the output.",
stream=True,
) as events:
for event in events:
print(event.to_json(indent=None), flush=True)
Note the client.beta.* prefix — this is still in beta, and the API surface will likely change before GA.
Three Ways to Run It
Compute is your choice. OpenAI gives you three tiers:
- OpenAI-hosted sandbox: Zero setup. OpenAI provisions compute, sets up a workspace directory, handles everything. Default for most use cases.
- Private VPC / self-hosted: You supply the compute; OpenAI handles orchestration only. For teams with data residency requirements or compliance constraints.
- Nine partner sandboxes: Blaxel, Cloudflare, Daytona, DigitalOcean, E2B, Modal, Oracle, Runloop, and Vercel — each with first-class integration. Cloudflare runs on the global edge and integrates with Workers; E2B gives you 900-second timeouts and SSH access to live sandboxes for debugging.
Pricing: The Orchestration Layer Is Free
There is no separate Agents API fee. You pay standard token rates for the model your agent uses, standard rates for any tool or web search calls, and standard sandbox compute if you use hosted execution. For teams already on OpenAI’s API, adding the Agents API costs nothing extra — the orchestration comes with the account.
Connecting Agents to Your Data
The API supports MCP (Model Context Protocol) natively. Agents connect to local MCP servers via stdio or remote servers via SSE. Tool list caching is built in for performance. Beyond MCP, standard function-calling works the same way it always has. The security guidance from OpenAI is worth reading: least-privilege credentials, tokens in auth headers not URLs, and approval gates for sensitive operations.
The Lock-In Math
Here’s the honest part. The Agents API only runs OpenAI models. If you wire OpenAI as your model, context manager, orchestration layer, and execution environment, you’re building on one vendor’s infrastructure all the way down. Migration later gets expensive.
The counter-argument is reasonable: if your product’s differentiation is in your tools, your data, and your workflows — not in the agent loop itself — then letting OpenAI own the plumbing is the same trade developers made with AWS RDS. You stop managing the database because managing databases isn’t your job.
Early beta users are reporting 4x latency reductions, 60% lower cost per task, and 86% fewer failed responses compared to DIY setups. Those numbers come from self-reported beta participants, so treat them as directional. But the direction is plausible: OpenAI has been running this infrastructure at Codex-scale for months. The alternative — LangChain, AutoGen, or rolling your own — gives full model flexibility at the cost of building session management, context compaction, and error recovery yourself.
Where It Stands Now
The Agents API is in public beta, available to all developers today. No GA date is announced. The beta prefix on the API endpoints signals that breaking changes are possible. OpenAI’s safety system has also been cutting off some agent workflows mid-task in early testing — something to account for when building reliability into long-running processes.
If you’re already running agent workflows on OpenAI models, this is worth evaluating now. The session and compaction infrastructure alone eliminates a significant amount of boilerplate. If you need multi-model flexibility or data residency requirements that VPC deployment can’t meet, keep watching but don’t block other work on it.













