# AI cost per customer: attribution and LLM unit economics

AI cost per customer is the billed AI spend attributed to that customer's requests in a period: each day's provider bill split by the customer's share of request cost. Divide it by the customer's revenue for the same period to get AI cost as a share of revenue, the number that shows whether an account is profitable.

**Key takeaways**

- Split the billed total by each customer's share of estimated request cost, so customer figures add up to the invoice.
- Keep untagged spend in its own no-customer line; spreading it silently raises every customer's cost and hides the gap.
- Rank customers by AI cost as a share of revenue, not by AI cost alone.
- AI contribution is revenue minus allocated AI cost; gross margin also subtracts hosting, support and other cost of revenue.

Published 2026-10-22, updated 2026-11-29, by AI Spendbook. Web page: https://www.aispendbook.com/blog/ai-cost-per-customer

When AI features are part of the product, their cost belongs in cost of goods sold, and it varies by customer far more than hosting does. One customer's heavy usage of a long-context feature can cost more than a hundred light users combined. Unit economics make that visible.

## Which AI unit economics numbers should you track?

| Metric | Formula | What it tells you |
| --- | --- | --- |
| Cost per request | AI spend ÷ requests | Whether a feature got more expensive per use (bigger prompts, a pricier model) |
| Cost per active user | AI spend ÷ monthly active end users | What one engaged user costs, for seat-based pricing |
| Cost per customer | Spend attributed to the customer's requests | Which accounts drive the bill |
| AI cost share of revenue | Cost per customer ÷ customer revenue | Whether that account is profitable after AI cost |

## How do you allocate one OpenAI or Anthropic bill per customer?

![Three trays hold different amounts of gold counters.](https://www.aispendbook.com/blog/ai-cost-per-customer-detail.webp)

This is [AI cost attribution](https://www.aispendbook.com/glossary/ai-cost-attribution). Start from [billed spend](https://www.aispendbook.com/glossary/billed-spend) per day and provider, then split it in proportion to each customer's estimated cost from request data on that day and provider:

```
customer share of the day = customer's estimated cost ÷ total estimated cost of attributed requests
```

Splitting the billed total this way keeps the customer figures adding up to the invoice. Using raw token estimates instead would drift from the bill whenever list prices, discounts or cache pricing differ from what the estimate assumed.

Worked example (illustrative): on one day the Anthropic bill is $1,000. Request data prices that day's attributed requests at $900 in total: customer A $540, customer B $360. A's share is $540 / $900 = 60%, B's is $360 / $900 = 40%. A is allocated 60% x $1,000 = $600 and B 40% x $1,000 = $400, which add up to the $1,000 billed. The $100 gap between the estimate and the bill (a cache discount, say) is spread in proportion instead of disappearing.

### Shared and unattributed spend

- **Background jobs** such as nightly summarization or embeddings for search often serve everyone. Tag them as their own feature, then either allocate them by usage or keep them as platform cost.
- **Unattributed spend** is billed cost with no matching request data: traffic from a service you haven't instrumented, a teammate's experiments, or the last day of billing before request data catches up. Show it as its own line and drive it down; don't spread it silently.

### When only part of the traffic is tagged

Suppose 80% of request cost carries a customer id and 20% does not. Illustrative numbers: on a day with $10,000 of billed spend, $8,000 is allocated to customers by their share of request cost and $2,000 sits in a no-customer bucket. Spreading that $2,000 across customers silently would raise every customer's cost by a quarter and hide the gap.

- **Find the source.** Untagged cost usually comes from one service, job or feature. Group the untagged requests by feature or API key.
- **Fix it at the source.** Set the customer id once per incoming request, not at each model call. See [gateway, SDK or OpenTelemetry for LLM cost tracking](https://www.aispendbook.com/blog/llm-cost-tracking-gateway-sdk-opentelemetry).
- **If a report needs a full allocation,** spread the untagged share pro rata as a stated policy, and show the amount spread next to the result.

## How do you calculate AI cost as a share of revenue and gross margin per customer?

Revenue per customer usually comes from your billing system. Pull paid invoices per customer per month, match them to the same customer ids used in your AI requests, and compute the share. A practical reading:

- Rank customers by AI cost share, not by AI cost. A large account with a low share is healthy; a small account with a high share needs a usage limit or a different plan.
- Watch the trend per feature. A rising [cost per request](https://www.aispendbook.com/glossary/cost-per-request) with flat usage usually means prompts grew or a feature moved to a more expensive model.
- Compare against the gross margin you need. If AI is 25% of a customer's revenue and you target 75% gross margin overall, there is nothing left for hosting and support.

Revenue minus allocated AI cost (and per-customer non-token costs such as telephony or human review) is the customer's AI contribution. It is not gross margin yet. Gross margin per customer also subtracts the other cost of revenue: hosting, support, payment fees. Allocate each of those monthly lines by a stated key (revenue share, AI cost share, request share, or directly to one customer) and show the two figures in separate columns.

| Line (illustrative) | Customer A | Customer B |
| --- | --- | --- |
| Revenue | $12,000 | $3,000 |
| Allocated AI cost | $1,800 | $1,500 |
| AI contribution | $10,200 (85%) | $1,500 (50%) |
| Other cost of revenue, by revenue share | $1,200 | $300 |
| Gross margin | $9,000 (75%) | $1,200 (40%) |

*Illustrative numbers. Hosting and support of $1,500 a month are split 80/20 by revenue.*

How each figure is derived: A's AI contribution is $12,000 minus $1,800 = $10,200, which is 85% of $12,000. B's is $3,000 minus $1,500 = $1,500, or 50%. Total revenue is $15,000, so A carries $12,000 / $15,000 = 80% of the $1,500 other cost ($1,200) and B 20% ($300). Gross margin is then $10,200 minus $1,200 = $9,000 (75%) for A and $1,500 minus $300 = $1,200 (40%) for B. B looks fine on revenue and is the account to reprice.

For the company-wide view that adds hosting and support, see [AI gross margin and board reporting](https://www.aispendbook.com/blog/ai-gross-margin-board-reporting), or run your own numbers through the [AI gross margin calculator](https://www.aispendbook.com/tools/ai-gross-margin-calculator).

## How do you know which AI feature is losing money?

Run the same split by feature instead of by customer. For each feature, set its allocated AI cost against the revenue it brings in: a usage charge, the plan it sits on, or the expansion it drives. A feature whose cost per request rises while usage is flat usually got longer prompts or a pricier model. A feature with no revenue line of its own still needs a cost ceiling that someone owns.

## How do you set up AI cost per customer, step by step?

1. **Get the billed total per day and provider** from each provider's cost API or billing export.
2. **Tag every model request with a customer id and feature,** set once per incoming request rather than at each model call.
3. **Price each request** at your rates to get an estimated cost, used only for shares.
4. **Split each day's bill** by each customer's share of that day's estimated cost; keep untagged cost as a no-customer line.
5. **Add per-customer non-token costs** (telephony, speech, human review) and match revenue per customer per month from your billing system.
6. **Report AI cost, AI contribution and gross margin** per customer, and track the untagged share as a number to drive down.

## What are common mistakes in AI cost attribution?

- **Summing token estimates and calling it cost.** It will not match the invoice; use estimates only to split the billed total.
- **Spreading untagged spend silently.** It inflates every customer and hides the tagging gap.
- **Mixing billing periods.** Compare a month of AI cost with the same month of revenue, not an annual contract value.
- **Calling AI contribution gross margin.** Hosting, support and payment fees still have to come off.
- **Ranking by absolute AI cost.** The biggest account is often the healthiest; rank by share of revenue.

## When is per-customer AI cost not worth measuring yet?

Before revenue, with one or two design partners, or when AI cost is a small share of total cost, a monthly provider total and a cost per request are enough. Per-customer attribution earns its setup cost once a few accounts drive most of the bill, pricing is being set or renegotiated, or the board asks for gross margin by segment. If no request can carry a customer id (for example, a batch pipeline shared by all customers), allocate by a stated key such as usage volume and say so.

## What should you do with AI cost per customer numbers?

[Unit economics](https://www.aispendbook.com/glossary/ai-unit-economics) turn vague worries into specific decisions: move one feature to a cheaper model after testing it, add prompt caching to the feature with the longest system prompt, set a monthly budget per customer, or price a usage-heavy feature separately. The [cost reduction guide](https://www.aispendbook.com/blog/reduce-llm-costs) covers the levers in order of risk.

## How do you show AI cost per account in Salesforce or HubSpot?

Sales and customer success want AI cost next to the account. Key every request by the customer id your CRM already uses (or keep a mapping table), then write a monthly AI cost and margin % into two custom fields on the account or company. A monthly CSV loaded with the CRM's import tool works; so does an integration that writes the fields directly, as long as someone checks the values before they land on every account.

AI Spendbook computes all four metrics from provider billing and your request data, and shows AI cost as a share of revenue when Stripe, another [billing system or a revenue CSV](https://www.aispendbook.com/docs/billing-systems-and-crm) is connected. The [customer margin report](https://www.aispendbook.com/docs/customer-margin) shows allocated AI cost, AI contribution and, once you add other cost of revenue lines, gross margin per customer and per plan. The [Salesforce](https://www.aispendbook.com/integrations/salesforce) and [HubSpot](https://www.aispendbook.com/integrations/hubspot) connectors read each account's owner, segment, ARR and renewal date onto the customer page. Writing AI cost and margin % back to the CRM is off until you turn it on and name the fields, and every write is previewed for one month and then confirmed. The connectors are built from each vendor's public API documentation and tested with recorded responses; none has been run against a live account yet.

## Frequently asked questions

### What is a good AI cost as a share of revenue for one customer?

There is no published standard. Work back from your gross margin target: if you need 75% gross margin and hosting and support take 10% of revenue, AI cost has to stay under about 15% of that customer's revenue.

### Should unattributed AI spend be spread across customers?

Not silently. Show it as its own line and fix the tagging at the source. If a report needs a full allocation, spread it pro rata as a stated policy and show the amount spread next to the result.

### Is AI cost per customer billed or estimated?

It should start from the provider's billed spend for each day, split by each customer's share of estimated request cost. Days the provider has not billed yet use the estimate and should be labelled as such.
