AI Agent Cost Calculator: per Run, Month and Successful Task
Estimate AI agent costs with growing history, cache expiry, mixed models, retries and human review. See cost per run, per month and per successful task.
This AI agent cost calculator estimates the price of one complete workflow attempt, monthly operation, and each task that actually succeeds. It is for engineers, students and builders budgeting coding agents, research assistants, data-processing workflows and other tool-using systems. It combines token billing with retries and human time so you can connect spending to useful work.
Start with the worker role. Choose a dated model price row, then enter system-prompt and tool-definition tokens, calls per attempt, fresh input, visible output and tool results. Enter additional reasoning separately only when it is not already counted as output. The retained-reasoning fraction controls how much joins later prompts. All token counts should use the selected model's tokenizer.
The model re-sends the fixed prefix and accumulated history at every call. With constant history growth, total input grows quadratically with turn count. Prompt caching changes the price of that history; it does not remove it. Select the short or long cache lifetime, then enter the time between request starts, including generation and tool time. Periodic pauses can expire the cache and force a rewrite. The worker chart compares the chosen cache policy with the same workflow without caching; the request ledger shows exactly which tokens are read, written or charged normally.
An optional branch runs a separate role on another model. Its expected charge is its probability times its number of copies times one branch's cost. It starts with a separate cold cache. Include any information passed back to the worker in the worker's tool-result tokens. Tool fees are additional to token charges: the supplied web-search example is USD 10 per 1,000 billed invocations.
Next enter a measured end-to-end success probability, a retry cap and tasks started per month. Retries stop at the first detected success. Monthly volume counts incoming tasks, including those that fail every attempt. Cost per successful task allocates all spending, including failed tasks, across expected successes. Add review time per attempt and optional one-off triage time per started task. The success-rate chart shows how reliability changes the effective cost per task.
Price presets were checked on 2026-10-27 and remain editable. They are examples, without a vendor ranking. Batch shares apply only to calls actually billed through a batch API; asynchronous scheduling can also change cache hits. The legacy GPT-4.1 cache estimate needs particular care because its breakpoints and retention depend on request settings and routing.
This is an API budgeting model, not a Claude Code cost per month subscription estimator. It does not import logs, predict success rates, model context compaction or represent correlated failures. Compare both cost and acceptance quality on your own tasks before making workflow changes.
How it is calculated
For each role independently, fixed prefix contains the system prompt and tool schemas. With fresh suffix , visible output , tool result , reasoning and retained fraction , history grows by . Request contains . With caching off, total input is : the quadratic history term described by exe.dev (2026-02-03).
The stable prefix before the current fresh suffix is . If it meets the provider minimum, it is cached at the configured token boundary. A live previous checkpoint supplies read tokens; the newly extended portion is written. A request-start gap at or above the TTL conservatively expires the checkpoint, so the full eligible prefix is written again. The current fresh suffix and any rounding remainder use ordinary input pricing. Reads refresh the checkpoint lifetime. The ledger enforces and charges . Write rates replace ordinary input rates for those tokens.
Anthropic's explicit prefix method, 5-minute / 1-hour lifetimes, write premiums, minimum lengths and read rates follow its pricing and prompt-caching pages, checked 2026-10-27 (s1, s12). The legacy GPT-4.1 estimate uses the published input/read/output prices (s2) with assumed retention and approximate cache boundaries; read the validity limits. Standard and batch charges are blended separately for each token category. Tool fees are per 1,000 invocations and receive no batch discount.
Expected branch charge is probability × copies × one independent branch. API/infrastructure plus review gives complete-attempt cost . For success probability and at most independent attempts, delivery probability is , and expected attempts stopping at first success are . Without a cap, expected attempts to first success are . Including one-off triage , cost per success is . Monthly spend is tasks started × ; expected successes are tasks started × .
The separate reliability output means all k trials succeed, in the sense of τ-bench passᵏ. It is not the retry delivery probability. For heterogeneous tasks, τ-bench averages per-task probabilities; raising a pooled success rate to k is only a homogeneous approximation.
Assumptions
- One turn is one billable model request. Each role has constant per-turn token counts and append-only history. Fixed prompt and tools remain identical. A cache breakpoint precedes the current fresh suffix; previous fresh content joins stable history on the next call.
- Each attempt, role and branch copy starts cold. There is no cross-task or cross-model cache sharing, eviction before TTL, prefix mutation, compaction or partial carry-over between retries. Thinking carried into history is explicitly controlled; actual thinking retention can be more complicated.
- The branch's success effect is already included in the supplied end-to-end success probability. Branch copies are additive cost, not an assumed accuracy improvement. Information returned to the worker belongs in its tool-result tokens.
- Attempts are independent, equally costly, and have the same success probability. A reliable evaluator detects success before retrying. Human review is charged on every attempt; one-off triage is charged on every started task.
- All money is USD, before tax. Currency values are numeric accounting amounts with USD in labels, not physical units. Time inputs have physical units and convert through hours for review. Counts and probabilities are dimensionless.
- Prices are dated examples, checked 2026-10-27. They are editable snapshots rather than live quotes. The default branch prompt remains below Haiku 4.5's cache minimum and therefore pays regular input rates.
Where it applies
Use for text-token API budgeting with 1–200 calls per role, positive success probability, and no more than 200,000 combined input and output tokens per request. The 200,000-token ceiling and 32,768-token output ceiling are conservative calculator scope limits, not claims about every model's full context window. Long-context surcharges, images, audio, storage, taxes, regional premiums, reserved capacity and subscription allowances are outside the model; enter separately billed infrastructure as an explicit fee.
Cache lifetime is measured from request start, including generation time. At exactly the stated TTL this model assumes expiry. Anthropic cache availability also requires valid breakpoints, unchanged settings and reachable history blocks. It assumes the immediately preceding checkpoint remains discoverable. Lower-than-minimum prefixes are not written.
GPT-4.1 is a deprecated legacy example. Its short TTL is a conservative 5-minute assumption; its long TTL is an optimistic 24-hour upper bound, not a guarantee. A 1,024-token minimum and 128-token rounding approximate the published behavior, but hidden system context, model-dependent checkpoint spacing, request settings, routing and early eviction can reduce actual hits. Edit these fields or choose no caching for a conservative estimate. Newer OpenAI models have different write/retention policies; do not apply this row to them unchanged.
Batch shares are only for eligible asynchronous API calls, not an automatic discount on sequential interactive work. Model the actual start intervals. Anthropic batch discounts stack with caching. The GPT-4.1 row conservatively leaves its cache-read price undiscounted because the published batch table gives no cached-input rate. Tool charges remain full price, and retrieved search content still needs token billing.
Success is a measured input, not a prediction. Correlated errors, harder retried cases, variable failure costs, evaluator mistakes and rate limits can invalidate the independent-attempt estimate. Zero success makes cost per success undefined and is excluded. Cache savings may be negative when writes do not earn enough reuse. HAL (arXiv:2510.11977) motivates evaluating cost and task quality together. Actual log import remains future work.
References
- Anthropic. API pricing and worked session example; checked 2026-10-27. https://platform.claude.com/docs/en/about-claude/pricing
- Anthropic. Prompt caching: lifetimes, minimum prefixes, thinking and cache accounting; checked 2026-10-27. https://platform.claude.com/docs/en/build-with-claude/prompt-caching
- OpenAI. GPT-4.1 model pricing; checked 2026-10-27. https://developers.openai.com/api/docs/models/gpt-4.1
- OpenAI. Prompt caching and batch pricing; checked 2026-10-27. https://developers.openai.com/api/docs/guides/prompt-caching ; https://developers.openai.com/api/docs/pricing
- Zeyliger, P. Expensively Quadratic: the LLM Agent Cost Curve. exe.dev, 2026-02-03. https://blog.exe.dev/expensively-quadratic
- Yao et al. τ-bench: A Benchmark for Tool-Agent-User Interaction in Real-World Domains, 2024. https://arxiv.org/abs/2406.12045 ; https://doi.org/10.48550/arXiv.2406.12045
- Kapoor et al. Holistic Agent Leaderboard: The Missing Infrastructure for AI Agent Evaluation. https://arxiv.org/abs/2510.11977 ; https://doi.org/10.48550/arXiv.2510.11977
- Pydantic. genai-prices (MIT): independent price-data and published usage cross-check, retrieved 2026-10-27. https://github.com/pydantic/genai-prices ; https://github.com/pydantic/genai-prices/blob/main/packages/python/README.md
Inputs
| Input | Symbol | Unit | Default |
|---|---|---|---|
| Success probability per complete attempt Measured end-to-end success, including branches and review acceptance; 0.75 means 75%. Failures must be detectable before retrying. | success_p | 0.75 | |
| Maximum attempts per started task Stop at first success; every retry starts a cold, independent copy of the full workflow. | max_tries | 3 | |
| Tasks started per month Incoming tasks, including those that exhaust their retry allowance. This is not the number of attempts or the target number of successes. | tasks_month | 1000 | |
| Human review per attempt Applied to every attempt, including failures. | review_min | min | 1 |
| Additional human time per started task One-off intake or final triage, paid even if all attempts fail. | triage_min | min | 0 |
| Human hourly rate (USD/h) Same currency as the price table. Money is shown in labels; physical time inputs convert with the metric/US switch. | hourly_usd | 60 | |
| Infrastructure and other fees per attempt (USD) Include containers, hosted runtimes or other non-token charges. Not discounted by batch. | other_usd | 0 | |
| Probability of running the optional branch Expected branch cost = probability × copies × one branch cost. Success probability above already includes the branch. | branch_prob | 0.3 | |
| Branch copies when triggered Each copy starts with its own cold cache. Shared prefix discounts between parallel copies are not assumed. | branch_copies | 1 | |
| Worker model and editable price row Prices checked 2026-10-27. Edit the row for another model or contract. All token prices are USD per million. Cache lifetimes, minimum prefix and batch multipliers are also editable. | model_a | Claude Sonnet 4.6 | 2026-10-27 | |
| LLM calls in this role One turn = one billed model request. Internal server-tool iterations must be counted too. | turns_a | 12 | |
| System prompt tokens Count actual tokenizer tokens, including any fixed orchestration overhead. | system_a | 1800 | |
| Tool definition tokens Tool schemas are re-sent as part of the fixed prefix. | tools_a | 2200 | |
| Fresh input tokens per turn Current user or external content outside the cache breakpoint. Each prior fresh input joins history on the next turn. | fresh_a | 200 | |
| Visible output tokens per turn Includes tool-call arguments. Excludes the reasoning tokens entered separately. | answer_a | 400 | |
| Additional billed reasoning tokens per turn Enter only reasoning not already included in visible output. Providers bill reasoning as output. | think_a | 200 | |
| Fraction of reasoning retained in later prompts 1 for retained thinking in a tool loop; 0 when reasoning is discarded. Match the API's actual conversation policy. | retain_a | 1 | |
| Tool result tokens added after each turn Excludes fresh input above. Earlier tool results stay in history. Last-turn results are not re-sent. | reply_a | 1000 | |
| Prompt cache policy Cache stable history before the current fresh input. New eligible history is written on every call; an expired prefix is written again. | cache_a | Short TTL from price row | |
| Time between request starts Includes response generation, tools, network time and any usual waiting. TTL starts at request start. | gap_a | min | 1 |
| Extra pause after every N turns (0 = none) A pause after turn N affects turn N+1. The ordinary interval is still added. | pause_every_a | 4 | |
| Extra periodic pause Added to the normal interval. At or above the TTL the model conservatively treats the cache as expired. | pause_a | min | 8 |
| Fraction of calls billed through batch 0 means standard API; 1 means all calls use the batch API. Only valid for workflows that can tolerate asynchronous execution. Enter actual batch timing above. | batch_a | 0 | |
| Billed tool invocations per turn Expected number, so fractions are allowed. Count search queries, not just top-level tool calls. | search_a | 0.25 | |
| Tool fee (USD per 1,000 invocations) Default $10/1,000 is published for web search by Anthropic and OpenAI. Search-content tokens must also be in the token inputs. | fee_a | 10 | |
| Branch model and editable price row Prices checked 2026-10-27. Edit the row for another model or contract. All token prices are USD per million. Cache lifetimes, minimum prefix and batch multipliers are also editable. | model_b | Claude Haiku 4.5 | 2026-10-27 | |
| LLM calls in this role One turn = one billed model request. Internal server-tool iterations must be counted too. | turns_b | 3 | |
| System prompt tokens Count actual tokenizer tokens, including any fixed orchestration overhead. | system_b | 1000 | |
| Tool definition tokens Tool schemas are re-sent as part of the fixed prefix. | tools_b | 1000 | |
| Fresh input tokens per turn Current user or external content outside the cache breakpoint. Each prior fresh input joins history on the next turn. | fresh_b | 100 | |
| Visible output tokens per turn Includes tool-call arguments. Excludes the reasoning tokens entered separately. | answer_b | 250 | |
| Additional billed reasoning tokens per turn Enter only reasoning not already included in visible output. Providers bill reasoning as output. | think_b | 0 | |
| Fraction of reasoning retained in later prompts 1 for retained thinking in a tool loop; 0 when reasoning is discarded. Match the API's actual conversation policy. | retain_b | 0 | |
| Tool result tokens added after each turn Excludes fresh input above. Earlier tool results stay in history. Last-turn results are not re-sent. | reply_b | 500 | |
| Prompt cache policy Cache stable history before the current fresh input. New eligible history is written on every call; an expired prefix is written again. | cache_b | Short TTL from price row | |
| Time between request starts Includes response generation, tools, network time and any usual waiting. TTL starts at request start. | gap_b | min | 1 |
| Extra pause after every N turns (0 = none) A pause after turn N affects turn N+1. The ordinary interval is still added. | pause_every_b | 0 | |
| Extra periodic pause Added to the normal interval. At or above the TTL the model conservatively treats the cache as expired. | pause_b | min | 0 |
| Fraction of calls billed through batch 0 means standard API; 1 means all calls use the batch API. Only valid for workflows that can tolerate asynchronous execution. Enter actual batch timing above. | batch_b | 0 | |
| Billed tool invocations per turn Expected number, so fractions are allowed. Count search queries, not just top-level tool calls. | search_b | 0 | |
| Tool fee (USD per 1,000 invocations) Default $10/1,000 is published for web search by Anthropic and OpenAI. Search-content tokens must also be in the token inputs. | fee_b | 10 |
Results
With the default inputs above, the calc gives:
| Result | Value |
|---|---|
| API + infrastructure per run (USD) | 0.3708 |
| Run including human review (USD) | 1.371 |
| Total cost per successful task (USD) | 1.828 |
| Total monthly spend (USD) | 1,799.21 |
| Monthly API + infrastructure (USD) | 486.71 |
| Monthly human time cost (USD) | 1,312.5 |
| Expected successful tasks per month | 984.4 |
| Probability of delivery within retry cap | 0.9844 |
| Expected attempts per started task | 1.3125 |
| All k trials succeed: passᵏ model | 0.4219 |
| Net cache saving per attempt (USD) | 0.2785 |
Checked against sources
Each case below was calculated by this calc and agrees with the value from its source (within the tolerance where one is shown).
Anthropic worked coding session: $0.58
Source: Anthropic pricing, 'Claude Managed Agents / Worked example', accessed 2026-10-27: 50,000 input tokens at $4/M = $0.20; 15,000 output at $20/M = $0.30; 1 hour runtime at $0.08 = $0.08; published total $0.58. The runtime is entered as an explicit other fee; this calculator does not simulate runtime. https://platform.claude.com/docs/en/about-claude/pricing#worked-example
Inputs: Worker model and editable price row = Claude Opus 5.5 | 2026-10-27; LLM calls in this role = 1; System prompt tokens = 50,000; Tool definition tokens = 0; Fresh input tokens per turn = 0; Visible output tokens per turn = 15,000; Additional billed reasoning tokens per turn = 0; Tool result tokens added after each turn = 0; Prompt cache policy = No caching; Billed tool invocations per turn = 0; Probability of running the optional branch = 0; Infrastructure and other fees per attempt (USD) = 0.08; Human review per attempt = 0 min; the others as above.
| Result | Source | This calc |
|---|---|---|
| API + infrastructure per run (USD) | 0.58 | 0.58 |
genai-prices published cache usage: 4,740 input tokens
Source: genai-prices Python README, Cached input tokens example (attached s9 p2): published usage is 4,740 total input, 4,735 written, 0 read, 255 output. Its retired Sonnet 4 model has the same $3/$3.75/$15 regular/write/output rates as the selected Sonnet 4.6 row. Independent arithmetic on those published counts: (5×3 + 4735×3.75 + 255×15)/1,000,000 = $0.02159625. The README supplies counts, not a printed total. https://github.com/pydantic/genai-prices/blob/main/packages/python/README.md
Inputs: LLM calls in this role = 1; System prompt tokens = 4,735; Tool definition tokens = 0; Fresh input tokens per turn = 5; Visible output tokens per turn = 255; Additional billed reasoning tokens per turn = 0; Tool result tokens added after each turn = 0; Billed tool invocations per turn = 0; Probability of running the optional branch = 0; Human review per attempt = 0 min; the others as above.
| Result | Source | This calc |
|---|---|---|
| Worker: input tokens re-sent [1] | 4,740 | 4,740 |
| Worker: cache-write tokens [1] | 4,735 | 4,735 |
| Worker: cache-read tokens [1] | 0 | 0 |
| Worker: regular input tokens [1] | 5 | 5 |
| Worker: billed output tokens [1] | 255 | 255 |
| API + infrastructure per run (USD) | 0.0216 | 0.0216 |
OpenAI GPT-4.1 published $2 per million input tokens
Source: OpenAI GPT-4.1 model page, Text tokens table: $2 per 1M input tokens. Five zero-output accounting requests of 200,000 input tokens total exactly 1M; expected cost is the published unit price. This is an input billing limit case, not a claim about real agent output. https://developers.openai.com/api/docs/models/gpt-4.1
Inputs: Worker model and editable price row = GPT-4.1 legacy | 2026-10-27; LLM calls in this role = 5; System prompt tokens = 200,000; Tool definition tokens = 0; Fresh input tokens per turn = 0; Visible output tokens per turn = 0; Tool result tokens added after each turn = 0; Prompt cache policy = No caching; Billed tool invocations per turn = 0; Probability of running the optional branch = 0; Human review per attempt = 0 min; the others as above.
| Result | Source | This calc |
|---|---|---|
| API + infrastructure per run (USD) | 2 | 2 |
| Worker: history growth per completed turn | 0 | 0 |







Responses