# LLM API Cost Calculator

- **URL:** https://codeasystem.com/calculators/developer/llm-api-cost-calculator/
- **Category:** developer
- **Description:** Project monthly LLM API spend from per-call token usage, input/output pricing and call volume across your traffic mix.
- **Primary output:** Estimated monthly API cost: $40.50

## Inputs
- Input tokens per call (name: `inputTokens`, type: number, example: 2000)
- Output tokens per call (name: `outputTokens`, type: number, example: 500)
- Input price (name: `inputPrice`, type: number, prefix: $, example: 3)
- Output price (name: `outputPrice`, type: number, prefix: $, example: 15)
- Calls per day (name: `callsPerDay`, type: number, example: 100)
- Days per month (name: `daysPerMonth`, type: number, example: 30)

## Outputs
- Estimated monthly API cost: $40.50
- Cost per call: $0.0135
- Daily cost: $1.35
- Calls per month: 3,000
- Input share of spend: 44.4%

## Formula / methodology
```
perCall = in/1M × $in + out/1M × $out
monthly = perCall × calls/day × days
```

Token counts convert to dollars through each side’s per-million rate, summing input and output because providers price them differently. Multiplying per-call cost by daily volume and active days yields the monthly projection, with a daily figure for sprint-level sanity checks.

## Assumptions & limitations
- List prices entered per million tokens, no volume discounts.
- Uniform call shape; mixed workloads need weighted averages.
- Retries and failed calls billed by providers still count.

## How to use
1. **Measure a representative call**; Use the token counter on a typical prompt and response pair.
2. **Enter both prices**; Output tokens usually cost 3–5× input; leaving defaults skews nothing structurally.
3. **Scale by traffic**; Calls/day × days/month converts unit economics into a budget line.

## Example
A chat feature averaging 2,000-token prompts and 500-token replies at $3/$15 per million, called 100 times daily, spends about $40.50 per 30-day month.

Result for these inputs:

```
Estimated monthly API cost: $40.50
```

## About this calculator
### Inputs dominate at scale

Because output tokens cost multiples of input ones, teams obsess over reply length while shipping enormous system prompts and full conversation histories every call. Trimming context, caching prefixes and summarizing history routinely halve bills without touching model quality settings.

### Model choice moves the decimal point

Flagship models often cost 10–30× their smaller siblings. Routing easy tasks to mini-class models and reserving flagships for hard steps frequently cuts blended spend by an order of magnitude at negligible quality loss; model this by running the calculator once per tier.

## FAQs
### Are cached input tokens cheaper?

Many providers discount cache hits 50–90%. Model that by lowering the effective input price for the cached fraction.

### Do I enter prices per 1K or 1M tokens?

Per 1M here; matching how major providers quote. Divide legacy per-1K quotes by one thousand... i.e. multiply by 1000 to convert per-1K to per-1M.

### Batch APIs?

Off-peak batch endpoints typically halve prices; enter half-price values to model them directly.

## Related calculators
- [LLM Token Counter](https://codeasystem.com/calculators/developer/llm-token-counter/)
- [Context Window Calculator](https://codeasystem.com/calculators/developer/context-window-calculator/)
- [RAG Chunking Calculator](https://codeasystem.com/calculators/developer/rag-chunking-calculator/)

---
Last updated: 2026-08-23 · Version: 1.0.0 · [HTML version](https://codeasystem.com/calculators/developer/llm-api-cost-calculator/)
