LLM cost calculator

See how prompt caching, output and retries add up to the cost of an accepted task.

Method & assumptions

Planning arithmetic, not an invoice forecast. Initial rates remain hypothetical: $4 ordinary input, $1 cache reads, $6 cache writes and $12 output per million tokens. Optionally select a dated official-source provider preset or enter manual rates. No live price fetching, automatic cache-hit assumptions or provider requests. Explicit share links store your numeric scenario in the URL fragment.

Token cost estimate

Browser calculations · explicit URL sharing

Estimated cohort spend · USD

$0.50

All four token buckets × 10 identical requests, including billed retries.

Ordinary input
$0.08
Cache reads
$0.18
Cache writes
$0.12
Output
$0.12
Per identical request
$0.05

Cost per accepted task

$0.0625

Total cohort spend divided by 8 accepted tasks, including the cost of failed attempts.

Same-token uncached baseline

$1.00

$0.50 less than the baseline.

Same input tokens, output tokens and request count. All input is repriced at the ordinary rate; output is unchanged. This is not a prediction of cache hits or quality.

USD, displayed to at most four decimals; positive amounts below $0.0001 are marked. Very large values use scientific notation. Totals use unrounded values, not invoice rounding.

No prompts, API keys or provider calls. Inputs are not automatically stored or sent. Reload returns to defaults unless the URL contains a shared scenario. This tool does not estimate token counts from text.

Tokens per request

Four separate billing buckets. Ordinary input excludes both cache reads and cache writes.

Tokens neither read from nor written to cache. Do not enter total input here.

Input tokens billed as cache hits, excluding ordinary input and writes.

Input tokens billed as cache creation. Count each token in only one input bucket.

All billable output, including reasoning tokens when your provider bills them.

Editable rates

Defaults are hypothetical USD per million tokens—not provider quotes. Choose a dated provider snapshot or enter your own rates. Changing a rate switches to manual mode; selecting manual keeps the current numbers.

Snapshots reviewed November 11, 2026; not live prices. All four rates stay editable. Confirm current billing before budgeting.

Preset sources: Anthropic pricing · OpenAI pricing.

The ordinary uncached input rate for your model and pricing tier.

The full rate for cached input, not a discount percentage.

The full write rate, including base input cost—not an extra surcharge. One write lifetime per calculation.

The billable output rate for the same model and pricing tier.

Requests & accepted tasks

Retries are already part of the request count, not an extra multiplier. Failed work stays in the total.

Include initial calls, billed retries and repair calls. Every counted request uses the same buckets and rates. Minimum 1.

Finished tasks accepted across this entire cohort, not per request. Enter 0 if none succeeded.

View estimate ↑

Updates as you type. Counts must be whole numbers up to 9,007,199,254,740,991; rates may be fractional. Zero is allowed except for request count.

Sharing explicitly includes every numeric assumption in the URL fragment, not a server query. No automatic input storage. Keep sensitive values out of shared links; browser history and anyone receiving the link can retain them.

Under the arithmetic

Separate the buckets. Keep the failed work.

Use your provider’s billable usage, not visible text length. U is ordinary input, R is cache reads, W is cache writes, O is output, N is identical-request count, and A is accepted-task count. Rates are USD per 1,000,000 tokens.

One rate per input token

request = (U × inputRate + R × readRate + W × writeRate + O × outputRate) / 1,000,000

Ordinary input, reads and writes are mutually exclusive. Enter the full cache-write price, not a surcharge on top of ordinary input. If your model bills newly cached input only at the ordinary rate, put those tokens in ordinary input and set write tokens to zero.

Provider usage fields differ. Some input totals already include cached tokens; others report ordinary input separately. Normalize the ledger before entering numbers.

Retries still cost money

total = request × N
cost per accepted task = total / A

N includes all billed calls, including retries, failed attempts and repair turns. It repeats the entire entered token mix, not just ordinary input. A is the accepted-task count for that whole cohort. If A is zero, the total remains visible but cost per accepted task is unavailable.

Each counted request must have the same buckets and rates. For varied requests at the same rates, sum tokens into the four buckets and set N to 1; the “per request” result then represents that aggregate. Do not multiply an already-summed ledger again.

Same work, no cache rate

baseline = ((U + R + W) × inputRate + O × outputRate) × N / 1,000,000

The baseline holds every token count and the request count constant. It reprices all input at the ordinary rate and leaves output untouched. The displayed difference is baseline minus estimated spend; cache writes can make the estimate more expensive.

This is a price comparison, not evidence that caching preserves quality or reduces retries. Compare actual accepted outcomes and include unsuccessful tasks in your evaluation cohort.

Know the edges

Your rates. Your usage. Explicit limits.

One model and pricing tier
Presets are dated snapshots, not a live rate card. Check the exact model, endpoint, region, tier and current date. This calculation uses one rate per bucket; mixed models, write lifetimes or pricing tiers need separate calculations and summed costs. The calculator does not automatically switch rate tiers when token counts change.
No cache simulation
Repeating a prompt does not guarantee a hit. Minimum prefix lengths, expiry, routing, changed context and cache lifetime affect the billable buckets. Enter measured usage or clearly stated assumptions; the tool does not infer these.
Token charges only
Tool calls, cache storage, hosted runtimes, search fees, taxes, credits, minimum charges and subscription costs are excluded. Include billable reasoning or other output tokens where applicable. Reconcile the result with the provider’s usage and billing records.
Estimates, not financial precision
Arithmetic uses JavaScript floating-point numbers and unrounded intermediate values. Counts must be safe whole numbers; blank, negative, nonfinite or overflowing values hide the estimate. Tiny positive displayed amounts are marked rather than rounded to a free result.

Primary references

Check the billing definitions

Initial defaults are invented examples. Optional provider presets copy the explicitly named tier and cache lifetime from official pricing, reviewed November 11, 2026. Rates remain editable and may change after review. Shared links include the entered numeric rates rather than silently updating them to future prices.

  1. OpenAI: Prompt caching

    Model-specific read/write pricing, matching prefixes and retention. Confirm how your endpoint reports the separate usage buckets.

  2. Anthropic: Prompt caching

    Ordinary input, cache creation and cache reads, including different write lifetimes and rates.

  3. Anthropic: Official model pricing

    Source for Claude Sonnet 4.6 standard global API rates with 5-minute cache writes and Claude Haiku 4.5 with 1-hour writes.

  4. OpenAI: Official API pricing

    Source for GPT-6.1 Sol standard short-context rates (up to 272K input tokens), with 30-minute cache writes. Other context tiers, cache lifetimes and processing speeds use different prices.

Keep your context

Price the workflow, not just the model.

Building a tool around your own engineering assumptions? Get in touch with Shipfoundary.