Skip to main content
株式会社オブライト
AI2026-09-117 min read

OpenAI Agents API: Pricing, Sandboxes & Quickstart (2026)

Sept 10, 2026: OpenAI's Agents API entered public beta, exposing the managed Codex harness for agent loops and sandboxes. This guide covers pricing and setup.


On September 10, 2026, OpenAI released the Agents API in public beta. It's available to all developers, and there's no extra charge for the Agents API itself — you pay only for tokens, tools, and container time. Under the hood, it's a managed service that exposes the open-source Codex harness, hosted and maintained by OpenAI. OpenAI handles the agent loop (coordinating model calls and tool execution), session orchestration, context management, and recovery. Developers only choose the agent's capabilities (tools, etc.) and where code runs. This guide covers what it is, pricing, how to use it, and how it compares to existing offerings.

What Is the OpenAI Agents API

The Agents API exposes the loop that the Codex harness already uses to coordinate model calls and tool execution, made accessible over the API. Developers no longer need to write their own agent loop — OpenAI handles continuing the loop, persisting sessions, managing context, and recovering from errors. Four core concepts make up the model.

ConceptDescription
AgentA combination of model, instructions, tools, and MCP servers
EnvironmentAn optional sandbox for file operations and command execution
SessionA persistent agent instance that keeps working on a task, retaining state across turns, and can be deleted when no longer needed
Events and itemsThe session's inputs and outputs (progress events and generated artifacts)
Architecture of the OpenAI Agents API: your app calls it through the SDK or POST /v1/agents/sessions and receives progress via streaming or webhooks; inside the OpenAI-managed Codex harness (agent loop, automatic context compaction, recovery) sit the Agent, Session and Events/items; and the environment can be openai_hosted, self_hosted, or a partner sandbox such as Cloudflare, E2B, Modal or Vercel

What It Can Do

- Automatic context compaction: older context is automatically compressed as a session approaches its limit
- Tool search: tool definitions are loaded on demand, reducing tokens compared to loading everything upfront
- Programmatic tool calling: parallel execution and chaining of operations, handled programmatically
- Subagents: multi-agent setups with independent contexts, including subagents running in parallel
- Connect MCP servers, custom functions, and web search as tools
- Receive progress via streaming or webhooks, and continue by sending additional tasks to the same session

Pricing

There's no fee for the Agents API itself — billing covers model tokens and sandbox (container) uptime. Per the official pricing page, gpt-6-astra, the model used in the official samples, is priced as follows (per 1M tokens).

ItemShort contextLong context
Input$10$20
Cached input$1$2
Output$50$75

Container pricing shares the same structure as Hosted Shell and Code Interpreter, billed per minute per 20-minute session, with a 5-minute minimum per session.

Container sizePrice per 20-min session
1GB$0.03
4GB$0.12
16GB$0.48
64GB$1.92

Example estimate: running a 16GB container for one hour (three 20-minute sessions) costs $0.48 x 3 = $1.44 in container fees alone, plus gpt-6-astra token costs (e.g., roughly an extra $3.5 for 100K input and 50K output tokens at short-context rates: $1.0 input + $2.5 output). Actual costs vary with tool-call volume and context length, and the community has flagged that you should estimate container launch counts and costs upfront. Verify exact pricing on the official pricing page.

Quickstart

1. Get an OpenAI API key
2. Update your SDK to the latest version (Python, JS, and Go are supported)
3. Create a session with POST /v1/agents/sessions, passing an agent definition and input
4. Receive progress (events and items) via streaming or webhooks
5. Send additional tasks to the same session to continue the work

# Python minimal example
from openai import OpenAI
client = OpenAI()
session = client.beta.agents.sessions.create(
    agent={"model": "gpt-6-astra", "instructions": "..."},
    input=[{"role": "user", "content": [{"type": "input_text", "text": "..."}]}]
)
// JavaScript minimal example
const client = new OpenAI();
const session = await client.beta.agents.sessions.create({
  agent: { model: "gpt-6-astra", instructions: "..." },
  input: [{ role: "user", content: [{ type: "input_text", text: "..." }] }],
});

If your workflow involves heavy code execution, it helps to review GPT-6 Astra pricing and benchmarks first to understand per-token costs and context-length behavior before estimating your budget.

Choosing a Sandbox

The Environment type can be openai_hosted (default) or self_hosted, and you can also choose a first-class partner sandbox integration.

TypeDescription
openai_hostedOpenAI-managed sandbox (default). Supports code execution, file operations, and artifact generation. You can upload files, install packages, and add skills/plugins
self_hostedRuns on your own infrastructure via codex exec-server, connecting via outbound-only WebSocket
Partner sandboxesFirst-class integrations with Blaxel, Cloudflare, Daytona, DigitalOcean, E2B, Modal, Oracle Cloud, Runloop, and Vercel, offering CPU/GPU/memory configurations, VPC deployment, and file/secret storage options

If you've already worked with the Codex harness directly, the OpenAI Codex beginner's guide is a good refresher on Codex fundamentals before mapping them onto the Agents API.

How It Differs From Agents SDK, Responses API, and Claude Managed Agents

OfferingProviderDescription
Agents APIOpenAIOpenAI manages the agent loop, sessions, and sandboxes end to end; the Codex harness exposed via API
Agents SDKOpenAIA library for running orchestration inside your own app; added sandbox support and a model-native harness in April 2026
Responses APIOpenAIA lower-level API where you manage conversation history and tool loops yourself
Claude Managed AgentsAnthropicServer-side agents hosted on the Anthropic API, with per-session containers, vault-stored secrets, SSE streaming, and native MCP support; Claude models only

If you're deciding among coding agents in general, see this comparison of Codex, Claude Code, Cursor, and Copilot as well. The Agents API suits teams that want to hand harness management to OpenAI; the Agents SDK or Responses API fit better if you want to build your own orchestration.

Things to Watch (Beta, Data Residency, ZDR, Cost)

- It's still in public beta, so specifications may change
- Data residency is limited to the United States
- Zero Data Retention (ZDR) is not supported, even when using a self_hosted sandbox
- Containers are billed per session, per minute, with a 5-minute minimum — costs can add up if you don't track how many you launch
- Check the official documentation for the latest details and specifications

FAQ

What is the OpenAI Agents API?

It's a managed service that exposes the Codex harness, hosted and maintained by OpenAI, over the API. OpenAI handles the agent loop, session orchestration, context management, and recovery, so developers only need to choose tools and where code executes. It entered public beta on September 10, 2026.

How much does the Agents API cost?

There's no extra fee for the Agents API itself. You pay for model tokens (gpt-6-astra is $10 input / $50 output per 1M tokens at short context) and for sandbox container uptime (e.g., $0.48 per 20-minute session for a 16GB container).

How is the Agents API different from the Agents SDK?

The Agents SDK is a library for running agent orchestration inside your own application. The Agents API instead has OpenAI manage the agent loop, session handling, and sandboxes for you.

Does using a self_hosted sandbox give me Zero Data Retention?

No. The Agents API explicitly does not support Zero Data Retention (ZDR), even with a self_hosted sandbox.

Which models can I use?

The available fact sheet shows examples using gpt-6-astra. Check the official documentation for the full list of supported models.

Summary

The OpenAI Agents API makes the agent loop and session management that already power the Codex harness available directly over the API, as a managed service. There's no extra fee for the API itself — cost comes down to tokens and container uptime. You get flexibility in choosing openai_hosted, self_hosted, or partner sandboxes, but it's worth remembering this is still public beta, data residency is US-only, and ZDR isn't supported. If you'd rather build your own orchestration, weigh the Agents SDK or Responses API against this managed option.

Feel free to contact us

Contact Us