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.

#AI agents #cost estimation #human review #prompt caching #retries #task reliability #token pricing

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 F=S+TF=S+T contains the system prompt and tool schemas. With fresh suffix qq, visible output oo, tool result vv, reasoning rr and retained fraction ff, history grows by g=q+o+v+frg=q+o+v+fr. Request tt contains It=F+q+(t−1)gI_t=F+q+(t-1)g. With caching off, total input is n(F+q)+gn(n−1)/2n(F+q)+g n(n-1)/2: the quadratic history term described by exe.dev (2026-02-03).

The stable prefix before the current fresh suffix is Lt=It−qL_t=I_t-q. 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 It=Ut+Ht+WtI_t=U_t+H_t+W_t and charges (UtPi+HtPh+WtPw+(o+r)Po)/106(U_tP_i+H_tP_h+W_tP_w+(o+r)P_o)/10^6. 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 CC. For success probability p>0p>0 and at most kk independent attempts, delivery probability is Q=1−(1−p)kQ=1-(1-p)^k, and expected attempts stopping at first success are A=Q/pA=Q/p. Without a cap, expected attempts to first success are 1/p1/p. Including one-off triage DD, cost per success is (AC+D)/Q=C/p+D/Q(AC+D)/Q=C/p+D/Q. Monthly spend is tasks started × (AC+D)(AC+D); expected successes are tasks started × QQ.

The separate reliability output pkp^k 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

InputSymbolUnitDefault
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_p0.75
Maximum attempts per started task
Stop at first success; every retry starts a cold, independent copy of the full workflow.
max_tries3
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_month1000
Human review per attempt
Applied to every attempt, including failures.
review_minmin1
Additional human time per started task
One-off intake or final triage, paid even if all attempts fail.
triage_minmin0
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_usd60
Infrastructure and other fees per attempt (USD)
Include containers, hosted runtimes or other non-token charges. Not discounted by batch.
other_usd0
Probability of running the optional branch
Expected branch cost = probability × copies × one branch cost. Success probability above already includes the branch.
branch_prob0.3
Branch copies when triggered
Each copy starts with its own cold cache. Shared prefix discounts between parallel copies are not assumed.
branch_copies1
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_aClaude 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_a12
System prompt tokens
Count actual tokenizer tokens, including any fixed orchestration overhead.
system_a1800
Tool definition tokens
Tool schemas are re-sent as part of the fixed prefix.
tools_a2200
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_a200
Visible output tokens per turn
Includes tool-call arguments. Excludes the reasoning tokens entered separately.
answer_a400
Additional billed reasoning tokens per turn
Enter only reasoning not already included in visible output. Providers bill reasoning as output.
think_a200
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_a1
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_a1000
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_aShort TTL from price row
Time between request starts
Includes response generation, tools, network time and any usual waiting. TTL starts at request start.
gap_amin1
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_a4
Extra periodic pause
Added to the normal interval. At or above the TTL the model conservatively treats the cache as expired.
pause_amin8
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_a0
Billed tool invocations per turn
Expected number, so fractions are allowed. Count search queries, not just top-level tool calls.
search_a0.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_a10
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_bClaude 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_b3
System prompt tokens
Count actual tokenizer tokens, including any fixed orchestration overhead.
system_b1000
Tool definition tokens
Tool schemas are re-sent as part of the fixed prefix.
tools_b1000
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_b100
Visible output tokens per turn
Includes tool-call arguments. Excludes the reasoning tokens entered separately.
answer_b250
Additional billed reasoning tokens per turn
Enter only reasoning not already included in visible output. Providers bill reasoning as output.
think_b0
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_b0
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_b500
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_bShort TTL from price row
Time between request starts
Includes response generation, tools, network time and any usual waiting. TTL starts at request start.
gap_bmin1
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_b0
Extra periodic pause
Added to the normal interval. At or above the TTL the model conservatively treats the cache as expired.
pause_bmin0
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_b0
Billed tool invocations per turn
Expected number, so fractions are allowed. Count search queries, not just top-level tool calls.
search_b0
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_b10

Results

With the default inputs above, the calc gives:

ResultValue
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 month984.4
Probability of delivery within retry cap0.9844
Expected attempts per started task1.3125
All k trials succeed: passᵏ model0.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.

ResultSourceThis calc
API + infrastructure per run (USD)0.580.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.

ResultSourceThis calc
Worker: input tokens re-sent [1]4,7404,740
Worker: cache-write tokens [1]4,7354,735
Worker: cache-read tokens [1]00
Worker: regular input tokens [1]55
Worker: billed output tokens [1]255255
API + infrastructure per run (USD)0.02160.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.

ResultSourceThis calc
API + infrastructure per run (USD)22
Worker: history growth per completed turn00

Related Resources

Responses

Your email address will not be published. Required fields are marked *

L ading...