AI Code Execution Cost Calculator
Estimate and compare the code interpreter / sandbox container fee that Anthropic, OpenAI, and Gemini bill separately from model tokens. Enter your runs and container uptime to see each execution fee, the cost per run, and the cheapest provider. No signup, sources cited below.
How it works
When an AI agent runs code — analysing a CSV, rendering a chart, or executing a generated script — the provider spins up an isolated sandbox container. That container is billed on a separate meterfrom the input and output tokens, and each provider prices it differently. This calculator models the three billing shapes directly from each provider's documentation.
Anthropic (per container-hour). The Claude code execution tool runs in a container with 1 CPU, 5 GiB RAM, and 5 GiB disk that persists up to 30 days for reuse. It is billed at $0.05/hour/container after 1,550 free container-hours per month per organization. So fee = max(0, N×H − 1,550) × 0.05, where N is runs per month and H is average container uptime in hours. Because billing tracks uptime rather than run count, short reused sessions often stay under the free cap entirely.
OpenAI (per container session). The Code Interpreter tool (Assistants and Responses API) is billed at fee = N × $0.03 per active container session, with no free-tier allowance. A container expires after roughly 20 minutes idle, so every new active container is a fresh charge — the cost grows linearly with run count.
Google Gemini (token-billed).The Gemini API charges no separate container fee. The generated code is billed as output tokens and the intermediate results as input tokens, at the model's standard per-token rate. The optional token add-on captures that: token_cost = N × T × (P_out ÷ 1,000,000), where T is output tokens per run and P_out is the model's output price per million tokens. The same add-on applies to Anthropic and OpenAI on top of their container fee — for Gemini it is the only execution charge.
The effective cost per run is (execution fee + token add-on) ÷ N (guarded when N = 0). The Anthropic figure is independently cross-checked by an alternate per-minute formula in the source module, so the per-hour and per-minute paths must agree to the cent before a number is shown.
Worked examples
Frequently asked questions
Sources & references
- Anthropic — Code execution tool (container pricing & free hours)
- OpenAI — Pricing → Built-in tools (Code Interpreter session fee)
- Google Gemini API — Code execution (token-billed, no container fee)
The execution rates and free-tier figures on this page were last cross-checked against the sources above on 2026-07-15. Provider pricing can change without notice — confirm against the linked docs before committing to a budget. Figures are USD only.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.