Skip to content

How to track Claude API costs per customer and feature

The CostReveal team, , 4 minute read

A product rarely has one AI feature for long. Summaries, search, drafting, an agent: each calls Claude, often through the same API key, and each has its own economics. Anthropic's reports say what each workspace spent on each model, each day. They cannot say which feature or which customer a call served, because only your application knows that. This post covers how to see Claude spend by feature and by customer with CostReveal, including the parts of a Claude bill that are not tokens.

What Anthropic's reports say

Anthropic reports usage and cost by day, by workspace and by model, with tokens stated by kind: uncached input, cached input, cache writes and output. Web search and code execution are billed apart from tokens, without a model. CostReveal reads all of it with an admin key, and shows the service and the model with the DIRECT basis, as Anthropic stated them.

That is spend by model and by workspace, exactly. Spend by feature or by customer is a different question, and the answer comes from two places.

Workspaces: the first split

A workspace is the closest thing a Claude bill has to an owner. CostReveal reads a workspace's team, feature and customer in this order:

  1. an owner you name for the workspace under Connections, Workspace owners;
  2. the workspace's own tags in the Claude Console, read with your project's tag keys;
  3. otherwise the spend is UNKNOWN, shown as such and never spread across teams.

Spend explained this way carries the INFERRED basis. Naming an owner, or tagging a workspace, explains every past period again. If each feature already has its own workspace and key, you have spend by feature now. If several features share a workspace, or customers do, the split has to come from the calls.

The calls: who and what each one was for

Your application knows the feature and the customer behind each call. CostReveal reads them from OpenTelemetry GenAI spans, from LiteLLM or Portkey logs, or from events sent to its usage events endpoint, with attributes such as app.customer and app.feature. No prompt or response is read, and CostReveal never sits between your application and Anthropic, so nothing is slowed or blocked.

It then divides what workspace owners and tags leave unknown, model by model and day by day, in proportion to each feature's and customer's measured tokens, and marks it ALLOCATED. The division follows how Claude is priced.

Prompt caching, divided fairly

Claude prices tokens by kind. Cached input costs a fraction of uncached input, and writing to the cache costs more. A feature built around a long, cached system prompt can use many tokens and still cost little; one that rarely hits the cache costs more per call.

So when your data reports cached tokens, cached input and cache writes are divided as pools of their own, each by the tokens of that kind your data reports. The feature that pays for the cache writes is charged for them, and the one that reads from the cache is charged the cached price. OpenTelemetry's GenAI conventions carry both counts, gen_ai.usage.cache_read.input_tokens and gen_ai.usage.cache_write.input_tokens.

Web search and code execution, too

Tool fees are where a feature's cost often hides. A research feature that searches the web on every call costs more than its tokens suggest.

  • Web searches are billed by the request, so they are divided by the searches each feature's calls reported.
  • Code execution is billed by the time its containers ran, which no call states, so it is divided by each feature's share of the code executions reported.

Neither is ever divided by tokens. A fee no call reports stays Not yet explained. The GenAI conventions have no attribute for either yet, so send them as events, or read them from LiteLLM's logs, which state web searches.

Coverage, not guesses

Usage data never adds a cent; totals stay exactly what Anthropic billed. If your data reports 60 percent of a model's billed tokens, 60 percent of what is unexplained is divided, and the rest stays Not yet explained, never spread to look complete. Coverage is shown per model, so a gap points straight at the feature whose calls are not instrumented.

What you can do with it

Business shows each feature beside the customers it served, with its cost per call and per customer, and each customer's cost beside the calls made for them. Explore groups Claude spend by feature, then by model, to show which feature runs on which model, and what each costs. A budget can watch a single feature, and alert before it passes its limit.

Frequently asked questions

Do I need a workspace per feature? No. Workspaces explain what they can; usage data divides the rest by feature and customer.

Does CostReveal read my prompts? No. Only the model, the tokens and who and what the call was for.

How is prompt caching handled? Cached input and cache writes are divided as their own pools, by the tokens of each kind your data reports.

What about web search and code execution fees? They are divided by the searches and code executions your calls report, never by tokens.

Is Claude on Amazon Bedrock divided the same way? No. Claude on Bedrock is billed on your AWS bill, and AI spend on a cloud bill is not divided by usage data.

Keep reading