API cost guide

How to estimate monthly LLM API cost

Turn token prices into a workload budget using request volume, input and output tokens, caching, retries, and source-tracked model rates.

Updated 2026-07-15Calculated from StackLens model data
Direct answer

Monthly LLM cost starts with four inputs

Estimate the number of model calls per month, average uncached and cached input tokens, average generated output tokens, and the applicable model prices. Keep tool fees and other non-token charges separate so the estimate remains auditable.

Monthly token cost
= requests per month
× ((uncached input tokens × input price)
 + (cached input tokens × cached input price)
 + (output tokens × output price))
÷ 1,000,000

Estimate boundary: add retry traffic, tool-call fees, cache storage, images, retrieval, and other provider-specific charges only when they apply to your workload.

Monthly example

Customer support chatbot API cost

Support assistants combine repeated instructions with high request volume, so small changes in routing and output length can materially change monthly spend.

ModelInput costOutput costMonthly estimateAssumptions
Gemini 2.5 Flash-Lite
Google
$9.84$14.00$23.8420% cache hit
GPT-4o mini
OpenAI
$16.20$21.00$37.2020% cache hit
Gemini 2.5 Flash
Google
$29.52$87.50$117.0220% cache hit
Claude Haiku 4.5
Anthropic
$98.40$175.00$273.4020% cache hit
Claude Sonnet 5
Anthropic
$196.80$350.00$546.8020% cache hit

The lowest token estimate is a budgeting signal, not a quality ranking. Change the customer support chatbot assumptions before using the result in a purchase decision.

Monthly example

Document summarization API cost

Document summarization is input-heavy, while requested summary length and repeated boilerplate determine how much output and cache pricing matter.

ModelInput costOutput costMonthly estimateAssumptions
Gemini 2.5 Flash-Lite
Google
$45.50$10.00$55.5010% cache hit
GPT-4o mini
OpenAI
$71.25$15.00$86.2510% cache hit
Gemini 2.5 Flash
Google
$136.50$62.50$199.0010% cache hit
Claude Haiku 4.5
Anthropic
$455.00$125.00$580.0010% cache hit
Claude Sonnet 5
Anthropic
$910.00$250.00$1,160.0010% cache hit

The lowest token estimate is a budgeting signal, not a quality ranking. Change the document summarization assumptions before using the result in a purchase decision.

Monthly example

Developer assistant backend API cost

Code context, generated patches, and repeated agent calls make both input and output rates relevant to a developer assistant budget.

ModelInput costOutput costMonthly estimateAssumptions
Gemini 2.5 Flash-Lite
Google
$20.50$30.00$50.5020% cache hit
GPT-4o mini
OpenAI
$33.75$45.00$78.7520% cache hit
Gemini 2.5 Flash
Google
$61.50$187.50$249.0020% cache hit
Claude Haiku 4.5
Anthropic
$205.00$375.00$580.0020% cache hit
Claude Sonnet 5
Anthropic
$410.00$750.00$1,160.0020% cache hit

The lowest token estimate is a budgeting signal, not a quality ranking. Change the developer assistant backend assumptions before using the result in a purchase decision.

Combined scenario

What the three workloads cost together

This total combines the three example workloads above. It does not assume the same model should handle every task.

ModelProviderCombined monthly estimateDecision boundary
Gemini 2.5 Flash-LiteGoogle$129.84Test quality, retries, latency, and routing fit separately.
GPT-4o miniOpenAI$202.20Test quality, retries, latency, and routing fit separately.
Gemini 2.5 FlashGoogle$565.02Test quality, retries, latency, and routing fit separately.
Claude Haiku 4.5Anthropic$1,433.40Test quality, retries, latency, and routing fit separately.
Claude Sonnet 5Anthropic$2,866.80Test quality, retries, latency, and routing fit separately.
Budget gap

Why the real API bill can be higher

  • System prompts, tool schemas, retrieved documents, and conversation history add input tokens.
  • Long answers, hidden reasoning usage, retries, and agent loops add output or repeated calls.
  • Failed requests and automatic retries can consume usage outside the successful request count.
  • Web search, storage, images, files, embeddings, and provider tools may have separate charges.
  • Cache writes, storage duration, and partial cache hits may not match a simple discount assumption.
Cost controls

How to reduce monthly LLM API cost

  • Route routine requests to a lower-cost model only after testing acceptance criteria.
  • Cap output length and measure the output-token distribution by feature.
  • Trim repeated context and measure actual cache-hit rates.
  • Track retries, failed calls, tool use, and agent loops separately.
  • Evaluate batch or lower-priority processing for work that is not latency-sensitive.
  • Compare cost per accepted result, not token price alone.
Before launch

Use representative traffic

Count tokens from real prompts, tool definitions, and conversation history. Sample P50, P95, and unusually large requests rather than relying only on one average.

Count a representative prompt
After launch

Reconcile estimates with usage

Measure input, cached input, output, retries, and cost by product feature. Update the forecast when model routes, prompt templates, or provider prices change.

Update the monthly estimate
FAQ

Questions teams ask before choosing

How do I calculate monthly LLM API cost?

Multiply monthly requests by the input and output tokens used per request, apply the model's per-million token rates, and then account separately for caching, retries, tool fees, and other provider charges.

Why can output tokens dominate LLM cost?

Output tokens often have a higher per-million rate than input tokens. Long answers, reasoning, retries, and agent loops can therefore increase total cost faster than request count alone suggests.

Does prompt caching always reduce the bill?

No. Savings depend on the provider's cache pricing, repeated-prefix eligibility, cache-hit rate, write cost, and storage or time-to-live charges. Model the measured hit rate rather than assuming every request is discounted.

Why can the real API bill be higher than the estimate?

System prompts, tool definitions, retrieved context, conversation history, retries, failed calls, images, storage, and provider-specific tools may add usage that a simple input-plus-output estimate excludes.

Does the lowest estimated token cost identify the best model?

No. Cost tables do not establish equal quality, latency, reliability, or output length. Test representative requests and include retries and human review when comparing total workflow cost.