Read this article with your own numbers
Read this article with your own numbers
Enter your numbers below and the highlighted numbers in the article body will be recalculated as estimates based on your input. Leave the fields blank and the article keeps its original example numbers.
Your input is used only to display this page. It is not stored in your browser, and it is never sent to this site's servers or to advertising companies. It does not carry over to other articles.
While this setting is on, your input is kept in this browser's temporary storage. It is never sent to this site's servers or to advertising companies. Even after you close the tab, reopening a closed tab or restoring a previous session may bring the input back. You can remove it at any time with "Clear all input".
The highlighted numbers are mechanical estimates based on your on-screen input, or on the article's own examples where fields are blank. They are not a recommendation or individual advice. Official vendor prices and measured benchmark results are never rewritten.
"Matches your input" means the condition described by the input fields is currently true. It does not mean better, appropriate, or that you should switch.
The article is currently showing its original example numbers.
An LLM API cost estimate needs more than a model’s headline price. Input and output tokens usually have different rates, repeated prompt content may qualify for cheaper cached-input pricing, cache creation can have its own cost, and asynchronous batch work may use another rate card. A useful estimate therefore separates those token classes before multiplying anything.
The calculator paired with this guide is designed for that job: enter request volume, average input and output tokens, cache assumptions, and the share of work that can run in batch. It calculates locally and does not need your prompts, API keys, or production logs. The equations below also work in a spreadsheet.
Price verification: The example rates and provider rules in this article were checked on 2026-07-24 against the official OpenAI API pricing, Anthropic pricing documentation, and Gemini Developer API pricing pages. Prices are in USD per one million tokens unless noted. Recheck those pages before approving a budget because models, regional premiums, temporary prices, and eligible processing modes can change.
The calculation rules were also checked on 2026-07-24 against three feature-specific primary sources:
- OpenAI Prompt Caching, which documents exact-prefix matching and the
cached_tokensandcache_write_tokensusage fields; - Anthropic Message Batches, which documents asynchronous processing, current limits, and the 50% batch rate;
- Gemini context caching, which documents implicit caching, minimum token thresholds, and
usage.total_cached_tokens.
These links support the mechanics, not a permanent price guarantee. Record the verification date alongside every saved rate card.
The LLM API cost equation in plain English
Start with four measurements for a representative request:
- requests during the billing period;
- uncached input tokens per request;
- cached or cacheable input tokens per request;
- output tokens per request.
For a workload without caching or batch processing, the equation is:
monthly cost = requests × ((input tokens ÷ 1,000,000 × input rate) + (output tokens ÷ 1,000,000 × output rate))
For example, 300,000 monthly requests averaging 1,200 input tokens and 300 output tokens produce 360 million input tokens and 90 million output tokens. At $1 per million input tokens and $6 per million output tokens, the estimate is:
(360 × $1) + (90 × $6) = $900 per month
That number is only an inference from average traffic. It excludes retries, failed application-level attempts, tool schemas, system instructions added by a framework, reasoning or thinking tokens billed as output, multimodal content, provider tools, taxes, currency conversion, and negotiated pricing. Add those categories when they apply.
Do not calculate from the advertised context window. A model that accepts a long prompt does not mean every request uses that many tokens. Measure actual usage fields from a representative sample, then use averages for a budget and a higher percentile for a stress case. If the application routes among providers, the routing logic described in our production OpenRouter alternatives guide should be represented as separate workload rows rather than one blended guess.
Input tokens and output tokens are separate cost centers
Input is everything sent to the model and counted by the provider: system instructions, user text, conversation history, retrieved passages, and often tool definitions. Output is what the model generates. Some APIs include hidden or visible reasoning tokens in output billing; Google’s current Gemini pricing tables explicitly state that output prices include thinking tokens. Check the chosen model’s usage schema instead of assuming the text displayed to a user equals billable output.
The output side can dominate even when responses are shorter. In the verified price snapshot below, output tokens cost several times more than ordinary input for each example model:
| Example model and mode | Input | Cached input or cache hit | Cache write | Output | Batch input / output |
|---|---|---|---|---|---|
OpenAI gpt-5.6-luna, standard short context | $1.00 | $0.10 | $1.25 | $6.00 | $0.50 / $3.00 |
| Anthropic Claude Sonnet 5, first-party API through 2026-08-31 | $2.00 | $0.20 | $2.50 for 5m; $4.00 for 1h | $10.00 | $1.00 / $5.00 |
Google gemini-3.5-flash, paid standard | $1.50 | $0.15 | Standard input applies when creating cached content; storage is $1.00 per million tokens per hour | $9.00 | $0.75 / $4.50 |
These are examples, not a ranking. OpenAI’s page also distinguishes short- and long-context prices for applicable models and lists a 10% uplift for eligible regional-processing endpoints. Anthropic says Claude Sonnet 5’s introductory $2 input and $10 output rates end after August 31, 2026, when $3 and $15 rates begin. Google’s page distinguishes Standard, Batch, Flex, and Priority modes. A preset must therefore store the provider, exact model, processing mode, context tier, region, and verification date—not just a model family.
Model choice is a quality and reliability decision as well as a rate-card decision. Our overview of OpenAI’s Sol, Terra, and Luna model tiers can help separate tasks before assigning each tier a cost row. A cheaper token is not a saving if it creates enough retries or rejected output to raise cost per accepted result.
Cache-hit math without imaginary savings
Prompt caching reduces the price of repeated input only when the provider reports a hit. Separate a prompt into:
- variable input that is billed at the ordinary input rate;
- reusable input that misses and must be written or processed;
- reusable input that hits and is billed at the cache-read rate.
Let C be the cacheable input tokens per request, H the cache-hit rate from 0 to 1, V the variable input tokens, Rin the ordinary input rate, Rwrite the cache-write rate, and Rread the cache-read rate. A simplified per-request input equation is:
input cost = (V ÷ 1M × Rin) + (C × (1 − H) ÷ 1M × Rwrite) + (C × H ÷ 1M × Rread)
Provider semantics differ, so the calculator should expose the rates rather than pretend one formula perfectly describes every API. Anthropic publishes separate five-minute and one-hour write prices plus a cache-hit price. OpenAI’s current GPT-5.6 table publishes input, cached input, and cache-write rates. Google’s explicit context caching charges a reduced token rate for cached content and a separate hourly storage fee; cache creation uses standard input pricing. Include that storage term:
cache storage cost = cached tokens ÷ 1M × storage rate per hour × stored hours
Do not infer a hit from requests that merely look similar. OpenAI reports reads in cached_tokens and writes in cache_write_tokens; Anthropic reports ordinary input, cache creation, and cache reads separately in input_tokens, cache_creation_input_tokens, and cache_read_input_tokens. Gemini’s Interactions API reports implicit cache hits in usage.total_cached_tokens. Use the provider’s returned fields as the source of truth, then compare cache-write cost with the later reads it produced. The prompt caching savings calculator covers break-even reuse in more detail.
Suppose 100,000 requests each contain 4,000 cacheable tokens and 1,000 variable tokens. With an 80% hit rate and Claude Sonnet 5’s five-minute cache rates verified above, input volume is 100 million variable tokens, 80 million cache-write tokens, and 320 million cache-hit tokens:
(100 × $2) + (80 × $2.50) + (320 × $0.20) = $464
Without caching, all 500 million input tokens would cost $1,000. The modeled difference is $536, before output charges. This result depends on the assumed hit rate and five-minute write behavior; use provider-reported cache fields in production. A nominally cacheable prefix that changes ordering, whitespace, tools, or instructions may miss and erase much of the expected saving.
Batch discounts and blended traffic
Batch processing fits work that does not need an immediate response: offline classification, extraction, evaluations, enrichment, or scheduled document processing. It is not a free speed upgrade for interactive traffic. Eligibility, completion windows, supported models, and operational limits must be checked for the selected API.
As verified on 2026-07-24, OpenAI’s Batch API reference describes asynchronous batches with a 24-hour completion window, while its pricing table shows model-specific batch rates. Anthropic’s Message Batches documentation says all usage is charged at 50% of standard API prices and that unfinished batches expire after 24 hours. The Gemini paid table likewise shows gemini-3.5-flash batch input and output at half its standard rates.
For a batch-eligible share B, estimate ordinary and batch traffic independently:
blended cost = standard workload × (1 − B) + batch-priced workload × B
If the $900 baseline example can move 60% of identical token volume to rates that are exactly half of standard, the estimate becomes:
$900 × 40% + $900 × 60% × 50% = $630
The modeled saving is $270, or 30% of the original total—not 50%—because only 60% of traffic moved. Keep cache and batch effects in separate lines before combining them. Anthropic documents that prompt caching and batch discounts can be combined, but that does not prove identical stacking behavior for every provider, model, or processing mode. Mark unsupported combinations as unavailable rather than applying two discounts mechanically.
For request formats, limits, result handling, and retry design, see the direct comparison of OpenAI Batch API and Anthropic Message Batches.
Worked monthly examples
The following examples use the verified prices in the table and rounded average tokens. They are planning scenarios, not provider bills.
Interactive support assistant
- 600,000 requests per month
- 1,500 ordinary input tokens per request
- 250 output tokens per request
- OpenAI
gpt-5.6-luna, standard short-context pricing - no batch and no assumed cache hits
Input is 900 million tokens and output is 150 million:
(900 × $1) + (150 × $6) = $1,800 per month
If response length rises from 250 to 400 output tokens while traffic stays constant, output becomes 240 million tokens and the estimate rises to $2,340. Controlling output length saves more here than trimming the same number of input tokens because the verified output rate is six times the input rate.
Cached document-analysis workflow
- 200,000 requests per month
- 2,000 variable input tokens per request
- 8,000 cacheable input tokens per request
- 75% hit rate
- 500 output tokens per request
- Claude Sonnet 5, five-minute cache-write pricing through 2026-08-31
The workload contains 400 million variable input tokens, 400 million cache-write tokens, 1.2 billion cache-hit tokens, and 100 million output tokens:
(400 × $2) + (400 × $2.50) + (1,200 × $0.20) + (100 × $10) = $3,040
Without caching, two billion input tokens plus output would be $5,000. The modeled saving is $1,960. Recalculate this scenario using Anthropic’s published post-introductory rates before September 2026 budgeting.
Mixed interactive and overnight classification
- baseline standard cost: $4,000 per month
- 70% of identical token work can use a verified half-price batch mode
- 30% remains interactive
($4,000 × 30%) + ($4,000 × 70% × 50%) = $2,600
The estimate saves $1,400. It does not include queue operations, storage, retries, or the engineering cost of running two paths. Track the batch completion rate and cost per accepted record, not just submitted tokens.
Cost controls to install before production
Estimation is useful only if actual usage can be compared with it. Before production:
- Log billable usage fields. Store provider, model, mode, input, cached input, cache creation, output, and request status without storing sensitive prompt content unnecessarily.
- Use three forecasts. Maintain expected, high-traffic, and cache-miss cases. A single average hides the conditions that break a budget.
- Set application budgets. Add daily and monthly ceilings, per-tenant quotas, maximum output tokens, and a stop or fallback rule.
- Separate retries. Network retries, rate-limit retries, and quality retries have different causes. Count all of them in cost per successful result.
- Version the rate card. Record currency, provider URL, exact model, context tier, region, processing mode, and verification date.
- Reconcile with invoices. Compare calculated token categories with provider billing exports and investigate the difference.
- Route by accepted quality. Evaluate smaller or cheaper models on the real task, then route only the workloads they pass.
Also budget non-token charges. Web search, code execution, storage, embeddings, fine-tuning, image or audio processing, provisioned throughput, regional endpoints, and third-party gateways can sit outside the text-token equation. Add them as explicit line items instead of inflating a vague contingency percentage.
Cost and capacity should be planned together. The AI API rate-limit calculator turns RPM, TPM, latency, and retry load into a sustainable throughput estimate. For a broader optimization sequence after measurement, see how to cut LLM token spend.
FAQ
How accurate is an LLM API cost calculator?
It is as accurate as the usage data and rate card supplied to it. Provider-reported token counts from representative production-like requests are stronger inputs than word-count conversions. The result remains an estimate until reconciled with the bill.
Should I use average or maximum tokens?
Use an observed average for the central forecast and a higher percentile or configured maximum for the stress case. Multiplying every request by the context limit usually overstates normal cost, while using only a low average can hide long-tail prompts and outputs.
Do cache hits reduce output cost?
Normally, cache pricing applies to eligible repeated input, not newly generated output. Calculate output at the applicable output rate unless the provider’s official pricing for the selected mode says otherwise.
Does batch always cut the entire bill by 50%?
No. A half-price batch rate cuts only the eligible token work moved to that mode. Interactive traffic and other charges remain. Model support and combination rules must also be verified.
How often should pricing be checked?
Check before a purchasing decision, after changing models or processing modes, and during regular invoice reconciliation. This article’s values were verified on 2026-07-24; it should not be treated as a permanent rate card. When comparing options, use cost per accepted result so retries, failures, and human review are not hidden by a low token rate.