Guide
LLM cost per customer: how to measure it and protect your margin
Published
If your product calls OpenAI, Anthropic or another model provider on your customers' behalf, every customer has an AI cost. Your provider bill shows the total, never the split. This guide shows how to get the split, turn it into margin, and know how far to trust it.
What is LLM cost per customer?
LLM cost per customer is the model spend one customer causes in a period: the tokens their requests used, priced at your rates. Set against what that customer pays you, it gives their AI margin. It is the number you need to price a plan, set usage limits, and spot the customers who cost more to serve than they bring in.
Why can't you get it from your provider invoice?
Because the invoice has no customer field. A provider knows an API key spent $4.02 on a model today, not whether that was one customer running a heavy report or a thousand customers sending one message each. Usage exports have the same gap, and it can't be filled in afterwards: the only moment you know which customer a call served is when your code makes it.
How do you attribute each LLM call to a customer?
Tag the call with the customer when you make it. With Token Meter there are two ways, and both record the customer, the feature and the team that caused the spend.
The SDK (Python or TypeScript). Wrap the provider client you already construct, then open an action() scope with the customer's id around the calls it covers. Usage is read from the response the provider already returned, so there is no proxy and no extra network hop, and the SDK never throws into your code.
import OpenAI from "openai";
import { TokenMeterClient, wrapOpenAI, action } from "@tokenmeter/sdk";
const tl = new TokenMeterClient({ apiKey: process.env.TOKEN_METER_KEY! });
const openai = wrapOpenAI(new OpenAI(), tl);
await action("generate-report", { customerRef: "acme", feature: "reports" }, async () => {
await openai.chat.completions.create({ ... });
});The same wrapper shape covers Anthropic, Gemini, Bedrock and Azure OpenAI. Use an opaque customer id, not an email or a name.
The router. If you'd rather not change code, point an OpenAI-compatible or Anthropic Messages client at Token Meter's router by changing its base URL, and send the customer as a field in the request body (customer_ref). The router forwards the call with your own provider key and meters it.
Details: Attribution, Quickstart and Router.
How do you turn cost per customer into margin?
Margin is the customer's revenue for the month minus their AI cost for that month. Token Meter lists every customer your calls are tagged with as soon as their usage arrives; there is no customer list to create first. You add revenue as one figure per customer per month in US dollars, one at a time or by pasting customer_ref,month,revenue_usd rows. Token Meter doesn't read revenue from a billing system.
Each customer then shows revenue, cost and margin for the month, a cost trend, their newest requests, and the most expensive actions they trigger, so you can see which feature drives the cost.
How accurate is cost per customer?
As accurate as your metering is complete, which is why Token Meter checks it against the bill. Each month it compares your metered cost with what your providers actually billed, and labels every margin with one of three states rather than presenting a guess as fact:
| State | When | What you see |
|---|---|---|
| Confirmed | Billing is reconciled for the month and metered cost is within tolerance of the bill. | One figure. |
| Range | The bill is higher than metered cost by more than the tolerance: some spend wasn't metered. | A range. The high end assumes none of the unmetered spend was this customer's; the low end assumes their cost was under-metered by the same ratio as the whole workspace. |
| Not yet reconciled | No reconciliation has run for the month, or the totals are too far apart to compare. | One figure, never labelled confirmed. |
The range uses one workspace-wide coverage ratio: metered cost divided by billed cost for the month, applied to every customer the same way. See Customers and AI Bill for how bills are brought in.
A worked example
Illustrative numbers
A made-up month, to show how the range is worked out.
- Customer
acmepays $4,200 for the month. Its tagged calls cost $1,050. - Across the workspace, metered cost is $9,000 and the provider bills total $10,000, so the coverage ratio is 0.9: $1,000 of spend wasn't metered.
- High end of the margin: $4,200 − $1,050 = $3,150 (none of the unmetered spend was acme's).
- Low end: $4,200 − $1,050 ÷ 0.9 = $3,033 (acme's share of the unmetered spend matches its share of the metered).
- Acme's margin shows as a range, $3,033 to $3,150, until the gap is closed.
The gap usually means some calls aren't going through a wrapped client or the router yet. Finding and wrapping them narrows the range to one confirmed figure.
What should you do with the numbers?
- Find margin-negative customers. Customers whose AI cost this month is higher than their revenue are counted separately, so they don't hide in an average.
- Fix the expensive feature, not the customer. A customer's most expensive actions show which part of your product drives their cost.
- Cap a customer's spend. A budget can be a monthly cap on one customer, with alerts at the thresholds you choose (50%, 80% and 100% by default) and a warning when the month's projection goes over. See Governance and alerts.
- Price from evidence. Cost per customer over several months shows what each plan really costs to serve before you change its price or limits.
Start measuring
Create a workspace, add an ingest key, wrap one client and tag one call with a customer. It shows up on the Customers page as soon as the usage arrives.