AI Tools
What does the OpenAI Agents API cost per session?
OpenAI Agents API pricing has no separate platform fee. You pay the selected model's per-token rate, plus OpenAI-hosted sandbox containers at $0.03 for 1 GB up to $1.92 for 64 GB per 20-minute session, plus $10 per 1,000 web search calls. Session state lives in the US only, and the API is not Zero Data Retention eligible.
What matters
- The overview's pricing section lists three meters and no platform fee: model tokens at API rates, OpenAI tools at standard rates, and OpenAI-hosted sandboxes at container rates.
- OpenAI-hosted containers cost $0.03 (1 GB) to $1.92 (64 GB) per 20-minute session per container, while the docs' own examples run on gpt-6-astra at $10 per 1M input and $50 per 1M output tokens.
- Session usage is best-effort and cannot price cache writes: the usage fields do not expose a cache-write count, so gpt-6-astra's $12.50 per 1M cache-write rate is invisible to the API.
- Choosing a self-hosted sandbox does not buy Zero Data Retention, because the Agents API is US-residency only and not ZDR-eligible at all.
- On headline rates gpt-6-astra matches Claude Fable 5.1 at $10 input and $50 output per 1M tokens, but cached input costs $1.00 per 1M on OpenAI against $0.25 per 1M cache hits on Anthropic.
What the OpenAI Agents API actually runs
The OpenAI Agents API is a managed agent runtime: OpenAI runs the Codex harness, keeps the session state, and can provision the sandbox where the agent executes code, edits files and reaches MCP servers. Your application sends the task and receives events.
Four objects make up a session, per the overview: the agent (model, instructions, tools, MCP servers), the environment (none, openai_hosted or self_hosted), the session itself, and the events and items produced while it works. OpenAI's own code sample runs gpt-6-astra with subagents enabled at max_concurrent_subagents: 4.
Two setup details cost time if you miss them. Requests carry the OpenAI-Beta: agents=v1 header, which the SDKs add for you but curl callers must set. Your API key needs api.agents.read, api.agents.write and api.responses.write permissions. The quickstart also says to keep that key outside the sandbox, and the hosted-sandbox docs reject OPENAI_API_KEY as a sandbox environment variable, so the agent cannot read it from its own shell.
OpenAI Agents API pricing: the three meters
The Agents API overview answers the pricing question in three lines. Model usage bills at the selected model's API rates. OpenAI tools bill at their standard rates. OpenAI-hosted sandboxes bill at standard container rates. No per-seat, per-session or platform fee appears anywhere in that section.
Model tokens. Each model call bills input tokens (instructions, tool definitions, conversation history, uploaded files, tool results), cached input tokens at the cached rate, and output tokens. Reasoning tokens are billed as output tokens, per the observability docs, so a long reasoning turn costs more than its visible answer suggests.
Containers. An OpenAI-hosted sandbox costs $0.03 for 1 GB, $0.12 for 4 GB, $0.48 for 16 GB or $1.92 for 64 GB, per 20-minute session per container. That is the meter most launch coverage skips. It is per container, so a workflow that needs a second container pays twice.
Tools. Web search costs $10 per 1,000 calls plus search content tokens billed at model rates. File search costs $0.10 per GB per day of storage with the first GB free, and $2.50 per 1,000 tool calls.
Sanity check on the mix: 100,000 input tokens and 10,000 output tokens on gpt-6-astra at $10 and $50 per 1M tokens is $1.00 plus $0.50, while a 20-minute 1 GB container is $0.03. That is arithmetic on published rates, not a measured benchmark, and it is the right mental model. Tokens dominate the bill until you leave sandboxes running.
The model you pick moves the bill more than anything else
Because billing follows "the selected model's" rates, the model choice outweighs every other lever. Short-context standard rates per 1M tokens on OpenAI's pricing page currently run: gpt-6-astra $10 input, $1.00 cached input, $12.50 cache writes, $50 output; gpt-5.6-sol $4 / $0.40 / $5 / $20; gpt-5.6-terra $2 / $0.20 / $2.50 / $12; and gpt-5.6-luna $0.20 / $0.02 / $0.25 / $1.20.
Moving a coding agent from gpt-6-astra to gpt-5.6-terra cuts the published token rates by 5x on input and roughly 4x on output. The same page also lists a long-context column group for each model, which for gpt-6-astra reads $20 input, $2 cached input, $25 cache writes and $75 output. Read the column group before quoting a price.
Cache writes are the rate worth understanding. gpt-6-astra charges $12.50 per 1M tokens to write input into the cache, more than its own uncached input rate. Sessions that keep rewriting a large prefix pay that repeatedly.
Where the bill gets hard to predict
Three mechanics make an Agents API invoice harder to forecast than a plain chat completion call.
- Cache writes are invisible in the usage API. The observability docs state that the usage fields do not expose a separate cache-write count, so they cannot determine the exact model charge when cache-write pricing applies. With $12.50 per 1M cache writes on gpt-6-astra, that gap is not a rounding error.
- Usage is best-effort. Session and turn usage can be null when unknown, and recorded counts can change as accounting arrives. Missing usage is not zero usage, and the docs call these counts "not a final bill".
- Subagents, retries and tool calls all add model calls. OpenAI advises counting root-agent and subagent work plus retries, tool, sandbox compute and third-party charges. Prompt caching only helps when successive calls share a stable prefix, and the docs warn that a high cached-input percentage does not measure savings on total task cost.
One operational catch carries a direct cost: deleting a session does not stop a self-hosted environment. The lifecycle docs state that deleting a session neither stops its environment nor emits a deletion webhook. If you run your own executor, shutdown is your job and uninterrupted compute is your bill.
Agents API vs Agents SDK vs Responses API
OpenAI publishes its own runtime comparison, and the cost difference follows from who runs the agent loop.
- Agents API: OpenAI runs a managed Codex harness, integration effort is low, state lives as saved session configuration, turns and items, and the environment can be OpenAI-hosted, self-hosted or none.
- Agents SDK: the SDK runs inside your application, effort is medium, and you own deployment, storage and approvals. You trade container rates for your own compute.
- Responses API: your application drives model calls with manual history or response chaining, and effort is high. Cheapest control path if you already own the orchestration.
Pick the Agents API when the task is long-running and you would rather not build session persistence, context compaction and recovery yourself. Pick the SDK when the environment must stay inside your network and you already operate that runtime.
OpenAI vs Anthropic on the same agent workload
gpt-6-astra and Claude Fable 5.1 carry identical headline rates: $10 per 1M input tokens and $50 per 1M output tokens, on OpenAI's pricing page and Anthropic's model pricing doc. The divergence is in cached tokens, and cached tokens are what an agent session spends most of its input on.
OpenAI lists gpt-6-astra cached input at $1.00 per 1M tokens. Anthropic lists Fable 5.1 cache hits and refreshes at $0.25 per 1M tokens, with 5-minute cache writes at $12.50 and 1-hour writes at $20. Where a session replays a long instruction and tool prefix, that is a 4x gap on the largest input category. Anthropic's cheaper tiers sit lower again: Opus 5 lists $5 input and $25 output per 1M tokens.
Cache-write pricing lands on both rate cards at $12.50 per 1M tokens, so a workload that rewrites its prefix constantly is expensive on either platform. Keep instructions and tool definitions stable and put new detail in follow-up messages, which is also what the Agents API caching guidance recommends.
Who should build on it, and who should not
Build on the Agents API if your task runs long, needs a sandbox with code execution and files, and your data can sit in the United States. What you are buying is session persistence, compaction, recovery and multi-agent orchestration, billed as tokens plus container time.
Stay on the Agents SDK if you need Zero Data Retention or EU data residency. The overview is explicit: the Agents API supports data residency only in the United States, does not support ZDR, and a self-hosted sandbox does not change that. For a buyer with a compliance review, those two sentences end the evaluation.
Skip the managed runtime as well if you already run orchestration and only want cheaper inference. The Responses API or the SDK on your own compute removes the container meter, and one internal detail is worth a look before you commit: cached input still bills, so the cheaper path is not automatically the one with the smaller number of calls.
For a first agent that must survive a 30-minute coding task without you writing session storage, the Agents API is the shortest route from idea to working loop. For anything under a data-processing agreement, it is the wrong tool until that residency note changes.
At a glance
| Meter | Official rate | When it applies |
|---|---|---|
| Model tokens (gpt-6-astra, short context) | $10.00 input / $1.00 cached input / $12.50 cache writes / $50.00 output per 1M tokens | Every model call, root agent and subagent |
| Model tokens (gpt-5.6-luna, short context) | $0.20 input / $0.02 cached input / $0.25 cache writes / $1.20 output per 1M tokens | Same harness on the cheapest listed model |
| OpenAI-hosted container | 1 GB $0.03 / 4 GB $0.12 / 16 GB $0.48 / 64 GB $1.92 per 20-minute session per container | environment.type set to openai_hosted |
| Web search tool | $10.00 per 1,000 calls plus search content tokens at model rates | web_search tool calls |
| File search | $0.10 per GB per day of storage (first GB free) and $2.50 per 1,000 calls | file search storage and tool calls |
| Platform fee | None documented | Creating or keeping sessions |
FAQ
Is the OpenAI Agents API free?
No. OpenAI documents no separate charge for the API surface itself, but every session bills the selected model's token rates, standard rates for OpenAI tools and container rates for OpenAI-hosted sandboxes.
Does the OpenAI Agents API support Zero Data Retention?
No. The overview states that the Agents API supports data residency only in the United States, does not support ZDR, and that choosing a self-hosted sandbox does not make it ZDR-eligible.
Is the Agents API cheaper than the Agents SDK?
It depends on where you already run compute. The SDK avoids container rates because the agent loop runs in your application, but you pay your own infrastructure and own deployment, storage and approvals.
Related reading
GPT-6 Astra API pricing, GPT-6 Astra vs Claude Fable 5.1, the full ToolBistro radar index
Sources
- OpenAI docs: Agents API overview (pricing, core concepts, data controls)
- OpenAI docs: Agents API quickstart (beta header, key permissions)
- OpenAI docs: API pricing (model rates, containers, built-in tools)
- OpenAI docs: Agents API observability and usage (cost contributors, best-effort usage)
- OpenAI docs: compare agent runtimes (Agents API vs Agents SDK vs Responses API)
- OpenAI docs: OpenAI-hosted environments (sandbox config, container rates)
- OpenAI docs: sandbox lifecycle (session deletion does not stop the environment)
- Anthropic docs: model pricing (Fable 5.1 and Opus 5 token and cache rates)