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.
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,000Estimate boundary: add retry traffic, tool-call fees, cache storage, images, retrieval, and other provider-specific charges only when they apply to your workload.
Compare monthly cost using real workload shapes
These examples reuse the same editable assumptions as the corresponding StackLens workload calculators.
Customer support chatbot
100,000 calls · 1,200 input · 350 output · 20% cache hit
Open calculator Editable scenarioDocument summarization
10,000 calls · 50,000 input · 2,500 output · 10% cache hit
Open calculator Editable scenarioDeveloper assistant backend
50,000 calls · 5,000 input · 1,500 output · 20% cache hit
Open calculatorCustomer 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.
| Model | Input cost | Output cost | Monthly estimate | Assumptions |
|---|---|---|---|---|
| Gemini 2.5 Flash-Lite | $9.84 | $14.00 | $23.84 | 20% cache hit |
| GPT-4o mini OpenAI | $16.20 | $21.00 | $37.20 | 20% cache hit |
| Gemini 2.5 Flash | $29.52 | $87.50 | $117.02 | 20% cache hit |
| Claude Haiku 4.5 Anthropic | $98.40 | $175.00 | $273.40 | 20% cache hit |
| Claude Sonnet 5 Anthropic | $196.80 | $350.00 | $546.80 | 20% 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.
Document summarization API cost
Document summarization is input-heavy, while requested summary length and repeated boilerplate determine how much output and cache pricing matter.
| Model | Input cost | Output cost | Monthly estimate | Assumptions |
|---|---|---|---|---|
| Gemini 2.5 Flash-Lite | $45.50 | $10.00 | $55.50 | 10% cache hit |
| GPT-4o mini OpenAI | $71.25 | $15.00 | $86.25 | 10% cache hit |
| Gemini 2.5 Flash | $136.50 | $62.50 | $199.00 | 10% cache hit |
| Claude Haiku 4.5 Anthropic | $455.00 | $125.00 | $580.00 | 10% cache hit |
| Claude Sonnet 5 Anthropic | $910.00 | $250.00 | $1,160.00 | 10% 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.
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.
| Model | Input cost | Output cost | Monthly estimate | Assumptions |
|---|---|---|---|---|
| Gemini 2.5 Flash-Lite | $20.50 | $30.00 | $50.50 | 20% cache hit |
| GPT-4o mini OpenAI | $33.75 | $45.00 | $78.75 | 20% cache hit |
| Gemini 2.5 Flash | $61.50 | $187.50 | $249.00 | 20% cache hit |
| Claude Haiku 4.5 Anthropic | $205.00 | $375.00 | $580.00 | 20% cache hit |
| Claude Sonnet 5 Anthropic | $410.00 | $750.00 | $1,160.00 | 20% 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.
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.
| Model | Provider | Combined monthly estimate | Decision boundary |
|---|---|---|---|
| Gemini 2.5 Flash-Lite | $129.84 | Test quality, retries, latency, and routing fit separately. | |
| GPT-4o mini | OpenAI | $202.20 | Test quality, retries, latency, and routing fit separately. |
| Gemini 2.5 Flash | $565.02 | Test quality, retries, latency, and routing fit separately. | |
| Claude Haiku 4.5 | Anthropic | $1,433.40 | Test quality, retries, latency, and routing fit separately. |
| Claude Sonnet 5 | Anthropic | $2,866.80 | Test quality, retries, latency, and routing fit separately. |
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.
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.
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 promptReconcile 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 estimateQuestions 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.