OpenAI’s Agents API puts the Codex harness in the cloud
By AgentRiot Editorial
Public beta. No extra API fee. You pick the sandbox. OpenAI runs the loop.

OpenAI opened the Agents API in public beta on September 10, 2026. It is not a new chat model and it is not the Agents SDK that already runs inside your process. It is the Codex harness, the same loop that drives Codex and ChatGPT for Work, exposed as client.beta.agents.sessions.create.
OpenAI Developers put it in one sentence: they handle orchestration, long-running sessions, and context management; you define what makes the agent yours. The launch post says there is no extra fee for the API itself. You pay model tokens and tools, plus container rates if you use an OpenAI-hosted sandbox.
That split is the product. Most agent stacks still make you own the loop, the session store, compaction, and the machine the model shells into. Agents API keeps the loop on OpenAI’s side and lets you choose whether compute lives in their sandbox, in a partner VM, or on a box you start yourself.
What you actually call
The quickstart is a coding assistant that writes tree.py, runs it, and prints the tree. The request sets agent.model (the examples use gpt-6-astra), short instructions, environment.type: "openai_hosted", and a user task. SDKs talk to beta.agents. Raw HTTP needs OpenAI-Beta: agents=v1.
The key is not a normal inference-only secret. Create an application key with api.agents.read and api.agents.write for sessions, plus api.responses.write for the model calls the harness makes. Keep that key outside the sandbox. A self-hosted executor gets a separate restricted environment key that can only connect compute.
Docs break the product into four objects:
- Agent: model, instructions, tools, MCP servers.
- Environment: optional sandbox or computer for files, skills, and commands.
- Session: a durable instance that takes tasks and can be resumed.
- Events and items: the stream of input, output, and lifecycle updates.
You create a session, wait until the environment is ready, send work, then either stream events or take webhooks. You can send another task to the same session or steer the current turn. Closing the event stream does not cancel the job.
Three places the agent can run
The architecture guide is the part that matters for builders.
No environment (type: "none"). The harness still calls the model, remote MCP, web search, and your function tools. There is no Bash, no apply-patch, no workspace files. This is the research/coordinator shape: subagents can even run here with environment.type set to none.
OpenAI-hosted (type: "openai_hosted"). OpenAI provisions a Linux workspace with Python, Node, and CLI tools. Working directory is /workspace. You can pin packages, run setup commands, drop files in, set env vars (reserved names like PATH, CODEX_*, and OPENAI_API_KEY are rejected), and attach skills or plugins. Network is enabled by default, or disabled, or restricted to 1-100 exact hostnames. Files under /workspace/outputs become immutable artifacts when a turn finishes. Idle sandboxes can be deleted after an hour without keep-alives; that timeout is not configurable. Delete the session to request cleanup. A 409 means setup or execution is still finishing.
Self-hosted (type: "self_hosted"). You run codex exec-server inside your laptop, container, Lambda, or partner VM. The executor opens outbound connections only: https://api.openai.com to register, wss://codex-cloud-environments.chatgpt.com for commands. OpenAI never inbound-SSHs your box. You own provision, reconnect, and shutdown.
The launch names first-class sandbox partners: Blaxel, Cloudflare, Daytona, DigitalOcean, E2B, Modal, Oracle, Runloop, and Vercel. Those firms already sell isolated compute. Agents API is the orchestrator that talks to them, not a replacement for a raw E2B session you drive yourself.
What the harness is doing while you wait
OpenAI’s pitch is that model upgrades used to mean rewriting your agent loop. The API versions the harness next to the model.
Compaction. The launch says the API automatically compacts earlier context as a session nears its limit, so multi-window jobs do not require your own summarizer. That is a session feature. Do not copy the separate Responses context_management request fields onto this API unless you are on Responses.
Tool search and programmatic tool calling. Tool search loads relevant tool definitions on demand so a fat catalog does not blow the prompt or the cache. Programmatic tool calling lets the agent run calls in parallel, chain them in code, and bring only filtered results back into context. MCP, custom functions, and built-in web search are supported. Function tools still execute in your app; if your handler is down, the agent waits.
Subagents. Set agent.multi_agent.enabled and a max_concurrent_subagents cap. The harness injects tools to create, message, wait, and interrupt workers. Each subagent has its own context. The multi-agent guide is blunt about when not to use them: short work and dependent file edits stay on the parent.
The loop itself is inspectable. OpenAI says the API is powered by the open-source Codex repo (Apache-2.0, described there as a lightweight terminal coding agent). You can read the harness. You cannot run OpenAI’s hosted session fabric from that repo alone.
Observability in beta is dashboard-first: platform logs for Agents, event streams, and turn traces. The docs say trace retrieval and external exporters are not part of the public beta API.
Similar tools, mapped by who owns the loop
The useful comparison is not “which chatbot.” It is who runs the agent loop, and where the shell lives.
OpenAI Agents SDK is the in-process sibling. OpenAI’s own table says use the API for long-running tasks where OpenAI saves progress, the SDK when your app owns tools, storage, and approvals, and Responses when you want to call models directly. The SDK already has sandboxes, handoffs, and guardrails. If you need to block a tool until a human clicks, that is still the SDK path.
Claude Managed Agents is the closest hosted peer. Anthropic’s overview uses the same four nouns: agent, environment, session, events. It offers a cloud sandbox or a self-hosted one, steering mid-run, compaction, and scheduled deployments. Claude Agent SDK is the other Anthropic product: Claude Code’s loop as a Python/TypeScript library in your process, like OpenAI’s Agents SDK, not like Agents API.
Cursor Cloud Agents run the Cursor agent in isolated VMs with your repo cloned, tests, MCP, and PR handoff (Cursor docs). You kick them from the IDE, web, Slack, GitHub, Linear, or an API. That is a coding-workspace product with a cloud VM, not a generic “give me a Codex session” HTTP API you embed behind any UI. Cursor also documents self-hosted machines if tool execution must stay on hardware you manage.
Google ADK (adk.dev) is an open-source framework in Python, TypeScript, Go, Java, and Kotlin. You write Agent(...), tools, and deploy it. Google does not host a Codex-style session API in that kit. Same bucket as rolling your own loop.
Cloudflare Agents (developers.cloudflare.com/agents) give each session a durable identity, SQL storage, WebSockets, and scheduled work on Cloudflare’s network, with sandbox, browser, and MCP tools. Cloudflare is also on OpenAI’s partner list, so it can be the environment under Agents API or a runtime of its own.
E2B, Daytona, Modal, and the rest of the partner row sell the computer. E2B’s docs still start at “run a sandbox.” Under Agents API they become the room the Codex harness walks into.
OpenClaw and Hermes Agent, which AgentRiot already covers as self-hosted gateways, stay in the SDK-shaped bucket: you run the loop and the host. They are not a substitute for beta.agents.sessions. They are what you keep when you do not want OpenAI holding session state.
What to pick
Use Agents API when the job is “keep a Codex-class agent alive for hours, compact the window, fan out subagents, and give me events,” and you do not want to operate that loop. Hosted sandbox is the demo path. Self-hosted or a partner VM is the path when files, secrets, or GPUs cannot leave your network.
Use the Agents SDK, Claude Agent SDK, ADK, or a self-hosted gateway when the loop is product logic: custom storage, approval gates, or a runtime OpenAI does not offer.
Use Cursor Cloud Agents when the unit of work is a git repo and a PR, not an embeddable session in your own app.
Use Responses or the Messages API when there is no agent loop to hide.
The beta is explicit. OpenAI says it will iterate toward general availability from feedback. Sandboxes can vanish after an hour idle. Traces do not export through the public beta API. Function tools still fail closed if your handler is gone. None of that is a reason to ignore the ship: the Codex harness is no longer only a product UI. It is a session you can start with one call, then decide whose Linux it gets to touch.

