# LLM API Cost Calculator

Project monthly and annual LLM API spend from request volume, average token counts, per-token pricing, and prompt caching discounts.

---

- **Canonical URL:** https://dothecalculation.com/calculators/llm-api-cost-calculator
- **Category:** AI & Tech Development
- **Publisher:** Do The Calculation (https://dothecalculation.com)
- **Cost:** Free, no account or sign-up required
- **Privacy:** Runs entirely in the browser; inputs are never sent to a server
- **Methodology:** https://dothecalculation.com/methodology

---

## LLM API Cost Calculator

Project your monthly and annual LLM API spend from expected request volume, average token counts, and your provider's per-token pricing — including prompt caching discounts.

- Monthly and annual cost projection at your expected request volume
- Separate input vs. output token cost breakdown
- Prompt caching discount modeling for repeated system prompts

## Quick Answer — How Much Will My LLM API Usage Cost?

**The core formula:** Cost per request = (Input tokens ÷ 1,000,000 × Input price) + (Output tokens ÷ 1,000,000 × Output price). Monthly cost = Cost per request × Requests per month.

**Quick reference (no caching):**

• 50,000 requests/month, 800 input + 300 output tokens, $0.15/$0.60 per 1M → **$15.00/month** ($180.00/year)

• 2,000,000 requests/month, 200 input + 20 output tokens, $0.15/$0.60 per 1M → **$84.00/month** ($1,008.00/year)

• 5,000 requests/month, 4,000 input + 1,000 output tokens, $3.00/$15.00 per 1M, 40% cache hit rate at 50% discount → **$123.00/month** ($1,476.00/year)

**Worked example:** a customer-support bot handling 50,000 requests/month, averaging 800 input tokens and 300 output tokens per request, on a model priced at $0.15 per 1M input tokens and $0.60 per 1M output tokens. Cost per request = (800/1,000,000 × $0.15) + (300/1,000,000 × $0.60) = $0.00012 + $0.00018 = **$0.0003**. At 50,000 requests: **$15.00/month**, or **$180.00/year**.

## How to Use This Calculator

Enter your **expected monthly request volume** — the total number of API calls you expect to make in a typical month.

Enter the **average input tokens** and **average output tokens** per request. If you don't know these precisely, the [AI tokens & cost calculator](/calculators/ai-tokens-calculator) can estimate token counts for a specific prompt and response you provide.

Enter your model's **input price** and **output price** per 1 million tokens — check your provider's current pricing page, since rates vary by model and change over time.

If your provider supports **prompt caching** (discounted pricing for input tokens that repeat across requests, such as a shared system prompt or long context), enter the share of requests that hit the cache and the discount rate applied to cached tokens.

**Example input:** 5,000 requests/month • 4,000 input tokens • 1,000 output tokens • $3.00/1M input • $15.00/1M output • 40% cache hit rate • 50% cache discount.

**Output:** Effective input price = $3.00 × (1 − 0.40 × 0.50) = **$2.40/1M** • Cost/request = (4,000/1,000,000 × $2.40) + (1,000/1,000,000 × $15.00) = $0.0096 + $0.015 = **$0.0246** • Monthly = **$123.00** • Annual = **$1,476.00**.

## The Formula This Calculator Uses

**Effective input price:** Input price × (1 − Cache hit% × Cache discount%). This blends the standard input price with the discounted price applied to the portion of requests that hit a prompt cache. With no caching (0% hit rate), the effective price equals the standard input price.

**Cost per request:** (Input tokens ÷ 1,000,000 × Effective input price) + (Output tokens ÷ 1,000,000 × Output price). Providers price per-million-tokens, so token counts are divided by 1,000,000 before multiplying by the per-1M rate.

**Monthly cost:** Cost per request × Requests per month.

**Annual cost:** Monthly cost × 12 — a straight-line projection assuming volume stays constant, not a forecast of actual future usage or pricing changes.

**Why input and output are priced separately:** most providers charge meaningfully more for output tokens than input tokens, since generating each output token requires a full forward pass through the model at inference time, while input tokens are processed together in a single pass. This means response length often drives cost more than prompt length, even when prompts are much longer than responses.

## Step-by-Step Worked Derivation

Take the high-volume classification example — 2,000,000 requests/month, 200 input tokens, 20 output tokens, $0.15/$0.60 per 1M, no caching — and work through it by hand.

**Step 1 — Input cost per request.** 200 ÷ 1,000,000 × $0.15 = **$0.00003**.

**Step 2 — Output cost per request.** 20 ÷ 1,000,000 × $0.60 = **$0.000012**.

**Step 3 — Total cost per request.** $0.00003 + $0.000012 = **$0.000042**.

**Step 4 — Monthly cost.** $0.000042 × 2,000,000 = **$84.00**.

**Step 5 — Annual cost.** $84.00 × 12 = **$1,008.00**.

**Answer:** even at a fraction of a cent per request, 2 million requests a month adds up to $84/month — a reminder that per-request cost alone doesn't tell the full budgeting story without volume.

## Why Prompt Caching Changes the Math

Many providers now offer discounted pricing for input tokens that repeat exactly across consecutive requests — most commonly a long system prompt, a set of few-shot examples, or a large shared context document that doesn't change between calls.

**The mechanic:** rather than reprocessing the same input tokens from scratch every request, the provider caches the internal computation for that repeated portion and charges a reduced rate for cache hits, while the non-repeated portion of the input (and all output) is billed at standard rates.

**Why this calculator models it as a blended rate:** rather than requiring you to split input tokens into 'cached' and 'uncached' buckets manually, this tool applies the discount proportionally across your cache hit rate — Effective price = Standard price × (1 − Hit rate × Discount rate). A 40% hit rate at a 50% discount reduces the effective input price by 20% overall (40% × 50%), not by the full 50% discount rate.

**When caching matters most:** workloads with a long, stable system prompt and short, varying user input see the largest savings, since the stable portion (the expensive part to reprocess) is what gets cached. Workloads where every request's input is substantially unique see little benefit from caching regardless of the discount rate offered.

## Realistic Scenarios

**Scenario 1 — A customer support chatbot.** 50,000 requests/month, 800 input + 300 output tokens, budget-tier pricing ($0.15/$0.60 per 1M), no caching: **$15.00/month**.

**Scenario 2 — A coding assistant with a long system prompt.** 5,000 requests/month, 4,000 input + 1,000 output tokens, mid-tier pricing ($3.00/$15.00 per 1M), 40% cache hit rate at 50% discount: **$123.00/month**.

**Scenario 3 — High-volume text classification.** 2,000,000 requests/month, 200 input + 20 output tokens, budget-tier pricing ($0.15/$0.60 per 1M), no caching: **$84.00/month**.

**The general pattern:** cost per request and total request volume interact multiplicatively — a workload with a tiny per-request cost can still be your largest line item at sufficient volume (Scenario 3), while a workload with a much higher per-request cost stays a modest total at low volume (Scenario 2).

## Common LLM Cost Estimation Mistakes

• **Using list price without checking for volume discounts or committed-use pricing.** Many providers offer reduced rates at higher committed volumes that this calculator's simple per-token pricing won't reflect.

• **Ignoring output token cost because prompts look longer than responses.** Output is typically priced several times higher than input — a short but detailed response can cost more than a long input prompt.

• **Applying a cache discount rate as if it applied to 100% of requests.** The discount only applies to the portion of input tokens that actually hit the cache, which is why this calculator asks for a hit rate separately from a discount rate.

• **Treating a monthly projection as a guarantee.** This is a projection at the volume and pricing you enter — actual usage, provider pricing changes, and request patterns can all shift the real bill.

• **Forgetting retries and errors add to volume.** Failed requests that get retried, or requests that get regenerated for quality, count as additional API calls even though they don't show up as 'real' user traffic.

## What This Calculator Can and Cannot Do

**It can:**

• Project monthly and annual API cost from your expected volume, token counts, and pricing

• Break down cost between input and output tokens

• Model the effect of prompt caching on your effective input price

• Show how cost scales at different volume levels

**It cannot:**

• Fetch or measure your actual usage from any provider's account or billing dashboard

• Predict future pricing changes from any provider

• Account for volume discounts, committed-use contracts, or enterprise pricing tiers not reflected in the simple per-token rate you enter

• Estimate token counts for you — pair it with the [AI tokens & cost calculator](/calculators/ai-tokens-calculator) to estimate tokens for a specific prompt first

**The honest summary:** this calculator gets the multiplication right for the volume, tokens, and pricing you provide. The inputs themselves — your actual request volume and current provider pricing — are estimates you supply, and the accuracy of the projection depends entirely on how close those inputs are to reality.

## Final Summary

**The formula worth remembering:** Monthly cost = Requests/month × [(Input tokens ÷ 1M × Input price) + (Output tokens ÷ 1M × Output price)], with prompt caching discounting the effective input price when a portion of requests reuses cached content.

**Quick reference:** output tokens typically cost several times more per token than input tokens, so response length often matters more for cost than prompt length — and at high volume, even fractions of a cent per request add up quickly.

**The one thing to actually do:** check your provider's current pricing page before budgeting, since per-token rates vary by model and change over time, and re-run this calculator whenever request volume or model choice shifts meaningfully.

If you're evaluating self-hosting as an alternative to API costs, see the [GPU VRAM & AI model training estimator](/calculators/gpu-vram-estimator) and the [LLM quantization VRAM & perplexity estimator](/calculators/llm-quantization-vram-calculator) for the infrastructure side of that comparison, and the [vector DB storage & RAM estimator](/calculators/vector-db-storage-calculator) if your workload includes a RAG pipeline.

## Frequently asked questions

### How do I estimate my monthly LLM API cost?

Multiply your expected requests per month by the cost per request. Cost per request = (input tokens ÷ 1,000,000 × input price per 1M) + (output tokens ÷ 1,000,000 × output price per 1M). This calculator does that math for you and adds prompt caching if applicable.

### Why is output token pricing higher than input token pricing?

Generating each output token requires a full forward pass through the model at inference time, one token at a time, while input tokens can be processed together in a single pass. This makes output generation more computationally expensive per token, which most providers reflect in higher output pricing.

### What is prompt caching and how does it reduce cost?

Prompt caching lets a provider reuse the computation for input tokens that repeat exactly across requests — like a shared system prompt — instead of reprocessing them from scratch. Cached tokens are billed at a discounted rate, reducing the effective input price for workloads with a stable, repeated prompt structure.

### How is this different from the AI Tokens & Cost Calculator?

The AI tokens calculator analyzes token counts and pricing for a single prompt and response. This calculator projects total monthly and annual spend across your expected request volume — a project-level budgeting tool built on top of that same per-request math.

### Does this calculator know my actual API usage or billing?

No. It projects cost from the volume, token counts, and pricing you enter — it doesn't connect to any provider account or fetch real usage data. Check your provider's billing dashboard for actual historical spend.

### Why did my actual bill differ from this projection?

Common causes: actual request volume or average token counts differed from your estimate, the provider changed pricing, retried or regenerated requests added volume that wasn't in your original count, or you're on a volume-discounted or enterprise pricing tier this calculator doesn't model.

### Should I self-host instead of using an API?

That depends on your volume, latency requirements, and engineering capacity to manage infrastructure. At high enough volume, self-hosting can be cheaper per request, but requires GPU infrastructure — see the GPU VRAM estimator and LLM quantization VRAM calculator to size that alternative.

### Is this LLM API cost calculator free?

Yes — completely free, no registration, and no data leaves your browser. Every figure recalculates instantly as you change an input.

## Related concepts

- **Input vs. output tokens** — Input tokens are the prompt and context sent to the model; output tokens are the generated response. Most providers price these separately, with output typically costing more per token.
- **Prompt caching** — A pricing mechanism where repeated input content (like a system prompt) is billed at a discounted rate on subsequent requests, since the provider can reuse prior computation rather than reprocessing it.
- **Cost per request vs. total volume** — A tiny per-request cost can still produce a large total bill at sufficient request volume — total monthly cost is the product of both figures, not either alone.

## Related guides

- [LLM Token Pricing: Estimate API Cost Correctly](https://dothecalculation.com/blog/tech/llm-tokens-pricing-guide) — Estimate LLM API cost from input, cached input, output, sessions, and chat-history growth—then verify current provider rates before budgeting.
- [How to Use Do The Calculation Calculators: A Practical Step-by-Step Guide](https://dothecalculation.com/blog/site-guides/how-to-use-calculators) — Learn the fastest reliable workflow for using Do The Calculation calculators, reading results, checking formulas, and using save, print, share, and export actions correctly.
- [Understanding Calculator Formulas: How DTC Turns Inputs into Results](https://dothecalculation.com/blog/site-guides/understanding-calculator-formulas) — Understand how Do The Calculation formulas are presented, what the explanation blocks mean, and how to verify calculator logic before using a result in a real decision.

## Related calculators

- [AI Tokens & Cost Calculator](https://dothecalculation.com/calculators/ai-tokens-calculator) — Estimate tokens, simulate prompt caching savings, compare API costs across leading LLM models, and calculate multi-turn chat context growth.
- [CDN Edge Caching & Egress Savings Calculator](https://dothecalculation.com/calculators/cdn-edge-caching-cost-calculator) — Estimate origin egress bandwidth cost savings and CDN return on investment based on cache hit rate and request volume, free.
- [Average Revenue Per Account (ARPA) Calculator](https://dothecalculation.com/calculators/average-revenue-per-account-calculator) — Calculate average revenue per subscriber or account over monthly or annual periods to track recurring revenue growth and pricing health.
- [API Rate Limiting & Token Bucket Simulator](https://dothecalculation.com/calculators/api-rate-limiter-calculator) — Simulate token bucket algorithms, peak traffic rejections, and optimal API rate limiting rules for backend systems and services.
- [Cache Hit Rate & CDN Cost Savings Calculator](https://dothecalculation.com/calculators/cache-hit-rate-calculator) — Project origin server load reduction, bandwidth savings, and network cost return on investment when using a CDN, instantly and free.
- [Data Storage Calculator (GB/TB/photos/videos)](https://dothecalculation.com/calculators/data-storage-calculator) — Calculate total storage needed for photos, videos and documents in GB and TB, plus an estimated monthly cloud storage cost.

---

_This calculator projects API cost from the request volume, token counts, and pricing you provide — it does not connect to any AI provider's account or measure real usage. Provider pricing changes over time and varies by model; always confirm current rates on your provider's official pricing page before budgeting against this projection._

---

_Source: [Do The Calculation](https://dothecalculation.com/calculators/llm-api-cost-calculator). Quote freely with attribution and a link to this page._
