Guides · Unit economics

How to calculate your LLM cost, and margin, per customer

The short answer

Tag every model call with a customer ID, sum tokens per customer per month, price them, and join the result to revenue per customer from Stripe. Margin per customer is (revenue − AI cost) ÷ revenue. Sort ascending. The bottom of that list is where your gross margin went, and in most AI products it is a short, specific list of names.

Plenty of guides cover tracking LLM costs for engineering purposes. Almost none of them finish the job, which is joining cost to revenue so you can see margin per customer and make a pricing decision. This one goes end to end, with a worked example. It assumes nothing more than API logs and a Stripe account.

Step 1: Attribute every model call to a customer

The prerequisite is a customer identifier on every request. Three ways to get it, in increasing order of effort:

If you can only reconstruct the last 30 days, start there. A month of real attribution beats a year of blended averages.

Step 2: Price the usage

Multiply tokens by your actual per-token rates, per model, remembering that input and output are priced differently and that cached input is usually cheaper. Then add the per-request costs that are easy to forget: embeddings, vector database queries, transcription, image generation, web search calls. For most products these secondary costs are 10 to 30 percent on top of raw inference, and for retrieval-heavy products they can rival it.

Step 3: Join against Stripe revenue

Export monthly revenue per customer (invoice totals or subscription MRR). Join on your account ID. You now have three columns per customer: revenue, AI cost, and margin. This is the join almost nobody does, because cost lives in engineering dashboards and revenue lives in Stripe, and no single tool owns both. It is also the only join that turns cost data into a pricing decision.

Step 4: Read the distribution, not the average

Compute three numbers over cost per customer: the median (P50), the 90th percentile (P90), and the 99th (P99). AI usage is power-law distributed; a small share of accounts consumes most of the compute. The blended margin can look respectable while the tail bleeds.

A worked example. Say you charge a flat $99/month and serve 100 customers, with this month's attributed AI costs:

CustomerRevenue / moAI cost / moMarginReading
P50 customer (typical)$99$1189%Great. Funds everything.
P90 customer$99$5643%Thin but positive.
P99 customer$99$380−284%You pay them $281/mo to stay.
Blended (all 100)$9,900$2,15078%Looks fine. Hides the tail.

The blended number says 78 percent and everything is fine. The per-customer view says your two or three heaviest accounts are consuming a quarter of your model bill and paying 3 percent of your revenue. Both statements are true. Only one of them tells you what to do.

Why your most engaged user may be your worst customer

This is the uncomfortable part. In a flat-priced AI product, engagement and unprofitability are the same variable. The customer who loves the product most, runs it hardest, and evangelizes it loudest is also the one consuming $400 of inference against a $99 subscription. The reported Copilot numbers made this famous: an average loss of $20 per user per month, with some users costing $80, on a $10 plan. You cannot see this condition in retention dashboards, where it looks like success. It only shows up in margin per customer.

Step 5: Decide what to do with the bottom decile

Three moves, in order of preference:

Frequently asked questions

How much does it cost to run an AI chatbot per conversation?

It depends on model, context length, and turns, which is exactly why you should compute it from your own logs rather than a benchmark: total tokens per conversation times your rates, plus retrieval costs. The useful version of this number is the P90 conversation cost, not the average, because pricing has to survive the tail.

Do I need an observability tool to do this?

No. A tool like Helicone or Langfuse makes attribution easier, but a logged customer ID, token counts, and a spreadsheet join against a Stripe export produce the same answer. The join is the point, not the tooling.

Why do my AI costs rise even though token prices keep falling?

Because usage per customer grows faster than prices fall: longer contexts, more agentic steps, and heavier features. Falling per-token prices do not fix a pricing model that lets the heaviest decile scale their consumption for free.

AI Pricing Reset

This is the exact map we build for you

The AI Pricing Reset computes margin per customer from your real Stripe and usage data, ranks your profit makers and margin bombs, simulates three pricing models on your history, and hands you the blueprint plus migration pack. Delivered in 10 business days. One-time fee, no subscription.

See the AI Pricing Reset

$1,500 founding rate · first 10 AI SaaS · $2,995 list