How the numbers are worked out
API cost per user = requests × (uncached input tokens × input price + cached input tokens × cache-read price + output tokens × output price), with the official per-million-token prices for the model you pick. Haiku 5.5 requests with a prompt over 100,000 tokens use its long-prompt rates.
Gross margin = (price − payment fees − other cost per user − API cost) ÷ price. Payment fees default to 5% + $0.50, which is the standard Lemon Squeezy rate; Stripe alone is usually lower, but you then handle sales tax yourself. Change both fields to match your provider.
Usage cap is the API spend that leaves exactly your target margin: price × (1 − target) − fees − other costs. Dividing it by the cost of one request gives the request cap, and multiplying that by tokens per request gives a token cap you can enforce in code.
Why a flat price needs a cap
Usage in AI products is lopsided. Most users make a few requests; a small share makes ten or twenty times more. With a flat price and no cap, those heavy users can cost more than they pay, and they are also the users most likely to stay. The table above shows what happens at 3× and 10× a typical user's usage.
A monthly cap per plan, checked before each request, keeps every user profitable. When a user reaches it, offer an upgrade or paid overage instead of a hard stop. Our post How to meter Claude API costs per user in a Next.js SaaS shows how to record each call and enforce the cap, and Model prices change. Snapshot them on every usage row explains how to keep those numbers stable when prices change.
What this calculator leaves out
- Cache-write surcharges (paid once per cache window), extended thinking tokens (add them to output) and tool-result tokens (add them to input).
- Free-plan users, who cost tokens but pay nothing. Spread their cost over paying users if your free tier is large.
- Refunds, chargebacks and taxes. With a merchant of record such as Lemon Squeezy, sales tax is handled for you; otherwise budget for it.
For the raw cost of a workload without a plan price, use the Claude API Cost Calculator.