induwara.lk
induwara.lkAI · Developer costs

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.

By Induwara AshinsanaUpdated Jul 15, 2026
Compare code-execution costs
Rates verified 2026-07-15
runs

Containers / sessions started per month across your agent.

hours

Anthropic only — how long each container stays up (0.1 h = 6 min).

Volume presets

Apply Anthropic free tier

Deduct the 1,550 free container-hours per month per organization.

Optional: generated-code token add-on

tokens

Generated code + explanation per run. Leave 0 to ignore.

Output price used for the generated-code token cost.

Monthly execution fee

Anthropic (Claude)
Cheapest
$0.00
$0.00/run · Per container-hour
OpenAI (Code Interpreter)
$30.00
$0.03/run · Per container session
Google (Gemini)
Cheapest
$0.00
$0.00/run · Token-billed (no fee)

Side-by-side breakdown

ProviderBilling modelExecution feeCost / run
Anthropic (Claude)100 container-h − 100 freePer container-hour$0.00$0.00
OpenAI (Code Interpreter)Per container session$30.00$0.03
Google (Gemini)Token-billed (no fee)$0.00$0.00
  • Anthropic containers persist up to 30 days for reuse, so reused short sessions can stay under the free-hour cap.
  • OpenAI containers expire after roughly 20 minutes idle — each new active container is a fresh $0.03 charge.

Sources cited:Anthropic code-execution docs·OpenAI pricing·Gemini code-execution docs

Token add-on prices (Claude Opus 4.8) come from the site's shared model price table. Rates last verified 2026-07-15. USD only. Anthropic also waives the fee entirely when code execution runs alongside the web search / web fetch tools — this toggle models the free-hour allowance, not that separate waiver.

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

1,000 short runs/month, 6-minute containers (H = 0.1)

  1. Anthropic: container-hours = 1,000 × 0.1 = 100 h
  2. 100 h ≤ 1,550 free → billable 0 → fee = $0.00
  3. OpenAI: 1,000 × $0.03 = $30.00
  4. Gemini: $0.00 (token-billed only)
  5. Cheapest execution fee: Anthropic / Gemini ($0.00)

50,000 runs/month, 3-minute containers (H = 0.05)

  1. Anthropic: container-hours = 50,000 × 0.05 = 2,500 h
  2. Billable = 2,500 − 1,550 = 950 h → 950 × $0.05 = $47.50
  3. OpenAI: 50,000 × $0.03 = $1,500.00
  4. Gemini: $0.00
  5. Cheapest: Gemini, then Anthropic ($47.50), then OpenAI ($1,500)

Token add-on: 1,000 runs × 2,000 output tokens @ Claude Opus 4.8

  1. Add-on = 1,000 × 2,000 × ($25 ÷ 1,000,000) = $50.00
  2. Anthropic total (H = 0.1, free on): $0.00 + $50.00 = $50.00
  3. Effective cost/run (Anthropic) = $50.00 ÷ 1,000 = $0.0500
  4. On Gemini this $50.00 token cost is the only execution charge.

Frequently asked questions

Sources & references

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

Rate this tool
Be the first to rate

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.