OpenAI's Codex API: Your Code Now Runs in Their Sandbox
OpenAI's Codex API: Your Code Now Runs in Their Sandbox
OpenAI has quietly rolled out its Agents API, turning the Codex harness into a REST service that any backend can call. The core endpoint is simple: POST https://api.openai.com/v1/agents/sessions, with a required header OpenAI-Beta: agents=v1. In plain English? OpenAI handles the heavy lifting—sessions, orchestration, context compression, recovery—while your app just supplies tools and picks where the code runs.
Four Building Blocks, One Managed Pipeline
The docs break it down into four concepts: Agent (model + instructions + tools + MCP server), Environment (optional sandbox or computer where files get read/written, skills load, commands run), Session (a persistent agent instance), and Events/items (the back-and-forth of input and output). The flow is straightforward: create a session, assign a task, stream or webhook the follow-up, then continue or intervene as needed.
What does OpenAI manage? Running commands in a sandbox, applying skills, connecting to external data via tools or MCP, letting you jump in anytime, compressing old context, delegating subtasks to subagents, and resuming from a breakpoint. Multi-agent mode is toggled via agent.multi_agent, with a max_concurrent_subagents setting. Tools come in three flavors: programmatic_tool_calling, mcp (HTTP transport), and web_search. Environments can be self_hosted or an OpenAI-managed sandbox.
The Fine Print: US-Only Data, No ZDR, and a Pricing Puzzle
Pricing follows the model: you pay for model usage, OpenAI tools at standard rates, and the managed sandbox at container rates. But two restrictions stand out. Data residency is limited to the US, and Zero Data Retention (ZDR) is not supported—even if you choose a self-hosted sandbox, it won't become ZDR-compliant. SDKs cover Python, TS/JS, Go, Java, and Ruby, all unified under client.beta.agents.sessions.create(...).
Community chatter centers on two things: whether handing sessions to OpenAI is worth it, and what exactly you'll be billed for. One user tested the sandbox network access and found three modes: enabled, disabled, and restricted. In restricted mode, hitting an external domain returns "Domain forbidden." He also questioned the billing: does each agent session spin up a new environment? Are environments billed for at least an hour? Can you close them early to save cash?
Vendor Lock-In or Just Convenience?
Why use this API instead of running the SDK yourself? The community is split. Critics say it "feels like vendor lock-in on steroids." Supporters shrug: "It saves us from maintaining a sandbox VM." Architecturally, the Agents API essentially server-izes the Codex client's harness, making long-running agents that read/write files and split subtasks a first-class API for any backend. The trade-off? You hand session state and execution environment to OpenAI.
Key Points:
- OpenAI's Agents API exposes Codex as a REST endpoint (
/v1/agents/sessions). - Managed features include sandboxes, context compression, subagents, and breakpoint recovery.
- Data stays in the US; ZDR is not supported, even with self-hosted sandboxes.
- Pricing confusion and vendor lock-in concerns dominate early community feedback.