DEV Community

doret
doret

Posted on

How to calculate LLM cost per customer (and why the average misleads)

If you run a product on OpenAI or Anthropic models, your cost isn't per customer. It's per token. To price your product sanely you need to turn one into the other.

Step 1: cost per request

cost per request = input_tokens × input_price / 1,000,000
                 + output_tokens × output_price / 1,000,000
Enter fullscreen mode Exit fullscreen mode

Example: Claude Sonnet 5.5 at $2 input and $10 output per million tokens, a chat reply with 2,000 input and 400 output tokens:

2,000 × $2 / 1M  = $0.004
  400 × $10 / 1M = $0.004
                   ------
                   $0.008 per request
Enter fullscreen mode Exit fullscreen mode

Don't forget the input side includes everything you send: system prompt, conversation history, retrieved documents, tool results. For agents the input usually dominates.

Some models charge a higher rate above a context threshold. For example, Claude Haiku 5.5 at 150,000 input / 1,000 output tokens is billed at the long-context rate ($0.50 / $2.50 per 1M), so a request costs $0.0775.

Step 2: cost per customer

cost per customer = cost per request × requests per customer per month
Enter fullscreen mode Exit fullscreen mode

At 300 requests a month: $0.008 × 300 = $2.40 per customer. With 200 customers: $480 a month.

Step 3: don't stop at the average

$2.40 is the average, and averages hide the distribution. In most products a minority of customers makes most of the requests.

Say 10% of customers make half the requests. With 200 customers and 60,000 requests a month:

  • 20 heavy customers share 30,000 requests: 1,500 each, so $12 per customer, 5× the average
  • 180 other customers share the other 30,000: about 167 each, so $1.33 per customer

On a cheap chat product that's fine. On an agent product it isn't. At 30,000 input / 2,000 output tokens per step and $1/$5 per million tokens, a step costs $0.04. At 1,000 steps a month the average customer costs $40. Under the same 10%/50% split, a heavy customer costs $200, twice the price of a $99 plan.

Step 4: measure the real distribution

The 10%/50% split is an assumption. To know your real numbers you need usage per customer, which you can get by:

  • tagging every request with a customer id in your own logs
  • using a separate API key or project per customer, then reading the provider's usage report per key
  • routing requests through a gateway that records the customer

Calculator

To skip the arithmetic, I made a free calculator with current OpenAI and Anthropic prices. No signup needed: https://doretprism.com/calculator?utm_source=devto

It uses standard list prices; prompt caching and batch discounts can lower real costs.

Top comments (0)