How to Calculate LLM Gross Margin Per Customer for an AI Product
If you sell an AI product, blended gross margin is not enough. You need to know whether each customer still makes sense after tokens, embeddings, retries, routing choices, and variable infrastructure are attached to that account.
Calculate LLM gross margin per customer by subtracting all customer-attributed variable AI serving costs from that customer's revenue, then dividing the remaining gross profit by revenue. Use monthly numbers when you want to compare it against MRR or subscription pricing.
The formula AI builders should use
The mistake is treating the model provider invoice as one company-wide line item. That invoice tells you whether spend is rising. It does not tell you which customer, workspace, agent, or plan is causing margin compression.
Start with a customer-level view. For each account, collect monthly revenue and every variable cost created by that account's AI usage. Then run the formula below.
This is not financial or tax advice. It is operating math for founders deciding whether pricing, limits, routing, and caching are aligned with actual usage.
Illustrative worked example
The numbers below are illustrative. Imagine a customer pays $79/month for an AI research assistant. During the month, that customer triggers 1,200 LLM workflows. The team has already blended provider pricing into a rough average cost per workflow and separately tracks retrieval, retries, and variable serving costs.
| Line item | Illustrative calculation | Monthly result |
|---|---|---|
| Monthly price | $79 per customer | $79.00 |
| LLM calls | 1,200 calls × $0.018 blended cost | $21.60 |
| Embeddings + retrieval | 1,200 workflows × $0.003 | $3.60 |
| Retries and evals | 180 extra runs × $0.018 | $3.24 |
| Other variable serving cost | Vector DB, job queue, logging | $4.00 |
| Variable cost per customer | $21.60 + $3.60 + $3.24 + $4.00 | $32.44 |
| Gross profit per customer | $79.00 - $32.44 | $46.56 |
| Gross margin per customer | $46.56 ÷ $79.00 | 58.9% |
In this illustrative example, the customer looks healthy at the top line but only keeps 58.9% gross margin after AI serving costs. That may be acceptable for one plan and unacceptable for another. The useful part is not the specific percentage; it is knowing which inputs move it.
Where LLM margin leaks happen
Margin leaks usually show up before they are visible in revenue reporting. If a customer is highly engaged, every small workflow inefficiency repeats hundreds or thousands of times.
Premium models on routine paths
If every classification, rewrite, and retry goes to the most expensive model, low-risk tasks quietly subsidize your demos and power users.
No cache for repeated context
Support bots, research copilots, and internal agents often re-read the same policy, document, or account history. Re-paying for repeated context is a margin leak.
Retries counted as engineering noise
Timeouts, validation failures, JSON repair loops, and eval runs are real variable costs. Track them against the customer that triggered them.
Flat pricing with uncapped heavy users
A flat monthly plan can work, but only if you know which accounts are using the product like usage-based infrastructure.
What to track before changing pricing
Before you raise prices or add usage limits, join revenue and AI usage by customer. At minimum, track monthly revenue, active users or seats, LLM requests, input and output token cost, embeddings, retrieval cost, retries, failed generations, and any queue or storage cost that scales with usage.
Then segment customers into three groups: clearly profitable, borderline, and negative gross margin. The right action depends on the segment. Profitable customers may only need better packaging. Borderline customers may need caching, smaller models on routine paths, or soft usage guardrails. Negative-margin customers need a pricing or product decision quickly.
Calculate your AI product margin in minutes.
Use the free MarginTrace calculator to estimate revenue per customer, LLM cost per customer, and gross margin. If you want customer-level tracking over time, create a free MarginTrace account.
Bottom line
The search query sounds like accounting, but the answer is product strategy. Once you know LLM gross margin per customer, you can decide where to cache, where to route cheaper, where to meter, where to cap, and which customers are worth expanding.
Do not wait until the blended model bill gets uncomfortable. Calculate margin at the customer level while the product is still small enough to fix.