Home › Blog › How to Calculate LLM Cost Per Request
How to Calculate LLM Cost Per Request
Your total API bill goes up when your product grows, which is good. Cost per request tells you whether each request is getting cheaper or more expensive, which is what you actually control.
Cost per request = (input tokens × input price + output tokens × output price) ÷ 1,000,000, with cached input tokens priced at the lower cached rate. Track it per route, every day.
The formula
A worked example
Example prices: $2.50 per million input tokens, $0.25 per million cached input tokens, $10 per million output tokens. One request sends 3,000 input tokens, 2,000 of them read from the cache, and gets 500 tokens back.
| Part | Tokens | Price per 1M | Cost |
|---|---|---|---|
| Uncached input | 1,000 | $2.50 | $0.0025 |
| Cached input | 2,000 | $0.25 | $0.0005 |
| Output | 500 | $10.00 | $0.0050 |
| Total per request | $0.0080 |
At 50,000 requests a day, that's $400 a day, or about $12,000 a month. Without the cache, the same request costs $0.0125, more than 50% more.
Why it beats watching the total bill
- Growth doesn't hide problems. If traffic doubles and the bill doubles, cost per request is flat and all is well. If the bill triples, something got more expensive.
- It points at a route. Measured per feature, it tells you exactly where to look.
- It's fair to guarantee. It's how apicuts measures the 20% cut, so your growth never counts against you.
Pick the right unit of work
A request isn't always the right unit. A chat app may care about cost per conversation, a document tool about cost per document, and a B2B product about cost per active user. For agents, measure cost per completed task, including retries and every tool call it took to finish.
How to track it
- Log the usage data from every response with the route name, model and release version.
- Compute the daily average cost per request for each route.
- Chart it, and alert when a route jumps after a deploy. That's cost regression protection.
Want us to find your 20%?
Book a free 15-minute API cost teardown. Bring last month's provider usage and we'll show you your biggest waste and the first fix we'd ship.
Get My Free 15-Minute API Cost TeardownFrequently asked questions
What's a good cost per request?
It depends on what the request earns you. Compare it with revenue per request or per user rather than with other companies.
Should I count failed requests?
Yes. You pay for errors and retries too, so include them, or measure cost per completed task.
How do I count cached tokens?
OpenAI and Anthropic both report cached input tokens separately in the usage data. Price them at the cached rate.