How to calculate LLM cost per user
Calculate LLM API cost per request and per user from tokens, model prices, caching and usage — with a worked example and the mistakes that underestimate cost.
October 3, 2026 · 1 min read
The formula
Prices are quoted per million tokens. If part of the input is served from a prompt cache, price that share at the cached rate.
Worked example
A model priced at $3 per million input tokens, $0.30 cached input and $15 per million output tokens. Each request sends 2,000 input tokens (half cached) and receives 500 output tokens; users make 300 requests a month.
- Input: 1,000 × $3 + 1,000 × $0.30 = $0.0033
- Output: 500 × $15 = $0.0075
- Per request: $0.0108, per user: $3.24/month
At a $20 plan, AI alone takes about 16% of revenue.
Mistakes that underestimate cost
- Forgetting the system prompt and retrieved context in input tokens.
- Using the average user when a few heavy users drive most cost.
- Ignoring retries, tool calls and agent loops that multiply requests.
- Using last quarter's prices — check the provider's pricing page.
Use the LLM cost per user calculator to compare models, then track the real cost by model in MarginMeter.
Frequently asked questions
How do I estimate tokens per request?
Log token counts from your provider's API responses for a sample of real requests. Include the system prompt, retrieved context and conversation history in input tokens.
Why are output tokens more expensive?
Providers price output tokens higher because generating them is more compute-intensive than reading input. That's why long responses dominate cost for many products.
Related
- How to calculate SaaS gross margin (with a worked example)The SaaS gross margin formula, what belongs in COGS, a worked example with AI and cloud costs, and the mistakes that make margin look better than it is.
- What counts as COGS for a SaaS company?A practical list of what belongs in SaaS cost of goods sold — hosting, AI APIs, payment fees, support — what doesn't, and how to treat staging, credits and tools.
- AI SaaS gross margins: what to expect and how to improve themWhy AI products often run lower gross margins than classic SaaS, which costs drive the gap, and practical levers — model mix, caching, pricing — to improve margin.
- How to price an AI SaaS product without losing moneyPrice AI features from cost per user and target margin: estimate inference cost, add payment fees, choose a margin, and protect yourself from heavy users.
See your real margin in five minutes.
Connect Stripe and your cost providers with read-only access. Free for two connections — no card required.