OpenAI Agents API Pricing: What a Production AI Agent Really Costs in 2026
Price the work you run through the OpenAI Agents API, not just the model call. The managed Codex harness handles sessions, tool execution and subagents. It is distinct from the Agents SDK and Responses API. The Agents API overview says OpenAI tools and hosted sandboxes use standard rates; external services charge separately. It lists no separate platform fee or custom contract quote.
The bill depends on each root or delegated model turn, tools, optional sandbox time and external services. For a broader view across providers, see our guide to the real cost of running an AI agent. This page focuses on the managed OpenAI runtime and the choice to operate its execution environment yourself.
Count every model turn
The current Agents API examples use gpt-6-astra. For standard requests under 272K tokens, its listed rates are $10 per million uncached input tokens, $50 per million output tokens and $1 per million cached input tokens. Cache writes cost $12.50 per million tokens for 30-minute retention or $25 for 12-hour retention. Output billing includes reasoning tokens. See the OpenAI API pricing page for the full rate card. A subagent adds its own context and output to the root agent's bill.
Do not compare model rates as if each completed job used the same number of tokens. Tokenizers can split code and JSON differently, and a model's reasoning output adds to its bill. Our AI API price comparison is a starting point; measure the same task before choosing a model.
Hosted sandbox rates and the billing convention
Use environment.type set to none when a task needs no hosted file or shell environment. That avoids OpenAI container charges, though your own servers still cost money if they run the tools. The Agents API settings offer small (1 GB), medium (4 GB, the default) and large (16 GB). The general rate card also lists 64 GB, but that size is not an Agents API option. The OpenAI-hosted sandbox guide confirms the available memory sizes.
| Agents API size | Memory | Listed rate per 20-minute session and container |
|---|---|---|
small | 1 GB | $0.03 |
medium (default) | 4 GB | $0.12 |
large | 16 GB | $0.48 |
The pricing page also says eligible sessions are billed by the minute with a five-minute minimum, but does not define which sessions qualify. For the examples below, I use one listed 20-minute unit per job and one container, with no extension or reuse. Treat that as a planning convention, not a promised invoice or universal minimum. Hosted sessions can stay alive between turns; closing a stream does not cancel a task. Deleting the session requests cleanup, but the docs do not say that idle time is always free.
Two monthly budgets
These examples use uncached Astra tokens, no cache writes and no paid third-party tools. They are workload assumptions, not quotes. Scenario 2 assumes one large container unit per task; actual billing can differ from the convention above.
| Monthly budget | API-only: 1,000 jobs | Hosted coding: 300 jobs |
|---|---|---|
| Tokens per attempt (input / output) | 3,000 / 800 | 15,000 / 4,000 |
| Model cost per attempt / month | $0.07 / $70 | $0.35 / $105 |
| Container convention per attempt / month | $0 / $0 (none) | $0.48 / $144 (large) |
| Total per attempt / month | $0.07 / $70 | $0.83 / $249 |
For the API-only job, 3,000 input tokens cost $0.03 and 800 output tokens cost $0.04. For the coding job, 15,000 input tokens cost $0.15 and 4,000 output tokens cost $0.20. The $0.83 figure is per attempted task under the stated container convention, not a known cost per accepted task.
Retries and the cost of accepted work
A failed task does not always consume the same resources. Check what your provider billed for the specific attempt. If you allow one repeat for jobs that miss on the first try, keep that capped rule separate from a model that retries until success.
In the API-only example, 1,000 original jobs cost $0.07 per attempt. If 90% pass first try and the other 100 jobs each get one repeat at the same cost, the total is 1,100 attempts and $77. That is $0.077 per original job submitted. Some repeats may fail too, so it is not the cost per successful result.
With independent attempts that each cost $0.07 and continue until success, expected cost per success is $0.07 / p, where p is the success probability on each attempt. At 95%, that is about $0.0737; at 85%, $0.0824; at 70%, $0.10; and at 50%, $0.14. This model assumes every try costs the same and has the same independent chance of success.
For a paid product, calculate price per accepted job minus all variable costs per accepted job. If your measured all-in variable cost is $0.83 per accepted coding job and you charge $2, the contribution is $1.17 before fixed costs. Do not use the scenario's $0.83 attempt cost as an accepted-job figure unless your measured acceptance and container billing support that assumption.
Choose the operating model with a representative task
Compare the managed harness with a self-hosted orchestration setup using the same task, quality bar and expected volume. Include latency, external tool charges and the engineering time to build and maintain each option. Open-source frameworks and the Agents SDK mean DIY does not require writing every part from scratch; a managed harness does not make MCP servers or paid APIs free. There is no universal job count at which either choice wins. Test a representative workload and use your own invoice and maintenance estimates.
Reconcile usage and check data limits
OpenAI provides a dashboard, session events and trace export for reviewing agent runs. Returned session usage is best-effort and may be null, so it is not a final invoice. Reconcile account billing for root and subagent tokens, cache writes, retries, tools and containers. A missing cache-write counter does not prove there were no billable writes. Check the Agents API observability guide alongside account billing.
The current Agents API overview says data residency is US-only and the API is not eligible for Zero Data Retention. Using your own sandbox or environment.type set to none changes where tools run; it does not change those API data terms. The Agents API overview describes these terms; check the official terms with your security team for your use case.
Common questions
Does the default medium sandbox use 16 GB?
No. medium is 4 GB at $0.12 per listed 20-minute session. large is 16 GB at $0.48. The 64 GB rate on the general card is not an Agents API size.
Can session usage reports tell me the exact invoice?
Not by themselves. Usage fields are best-effort and nullable, and may not expose every billable dimension. Reconcile them with your account billing exports, including cache writes and container sessions.
Does a self-hosted sandbox make the Agents API ZDR-eligible?
No. The overview lists US-only residency and says the Agents API is not eligible for Zero Data Retention. Moving tool execution does not change the API session's data terms.