Own Weights

LLM cost tracking: AI spend by feature and customer

LLM cost tracking by feature, team and customer: tag every call, build a chargeback view, and find the one workload to move first. Steps and trade-offs below.

Updated

LLM cost tracking means tagging every model call with the feature, team or customer that made it, then adding up spend along those tags. That shows which workload drives the bill and which one to move first.

A provider invoice usually breaks spend down by API key or project. One key often serves a chat feature, a nightly report job and a classifier. When the total jumps, the invoice tells you the bill went up and nothing about why.

How do you tag every LLM call?

Add the metadata in one wrapper function that every call passes through. Use a small fixed set of keys, such as feature, team, environment and customer_id. Store each call’s tags with its model name, input tokens, output tokens and timestamp. Calls with no tags should land in an “untagged” bucket in your report, and that bucket should shrink to zero over time.

Use customer IDs, not names. Names change and pick up typos. Map IDs to names in your billing system, not in your logs.

How to track AI costs per customer

Per-customer cost is calls times tokens per call, priced at the model’s rate, then compared with what that customer pays you. Here is a hypothetical example with round numbers. A customer pays $200 a month and generates 8 million input tokens. At the Claude Opus list price of $4 per million input tokens, the input alone costs $32 a month. That is 16% of revenue before output tokens are counted.

The customers at the top of that list are the ones to look at first. Long documents and long chat sessions push token counts up, and a few heavy accounts can hide inside an average that looks fine.

AI cost allocation by team and the LLM chargeback model

Chargeback means each team pays for the AI it uses, based on the tags. Three models are common:

  • Flat share: split the bill by each team’s share of calls. Easy to run, but a team with light use ends up paying for heavy use by others.
  • Metered: charge each team its tagged cost at list price. Teams see their own spend and change what they send.
  • Budgeted: give each team a monthly allowance, with overage approved case by case.

Use metered billing when teams control their own prompts. Use a flat share while you are still fixing tags, because a metered bill built on bad tags just moves the confusion to the teams.

Which feature is driving our AI bill?

Sort tagged spend by feature and look at the top three. For each one, ask two questions: how many calls does it make, and how large is each call? A feature with many small calls on a cheap model is usually fine. A feature with large prompts on a frontier model is usually the first place to look.

Then check the code for the common causes. Look for calls inside loops, calls with no output limit, repeated long prompts that skip prompt caching, and calls with no timeout. Once a feature is identified, compare cost per document or per call instead of cost per token. Your tags already give you that figure: divide the feature’s tagged spend by the calls or documents it handled in the same period. Check each vendor’s current pricing page before you compare options, because rates change.

Which workload should you move first?

The best first target is the feature with the highest cost and a narrow task that repeats, such as extraction or classification. Narrow tasks are where a trained model fits. Own Weights fine-tunes an open-weight model for one task like that. Frontier models cover broader work, so they remain the right choice for open-ended requests.

Before you move it, use the tags to pull that feature’s real logged inputs as the test sample, and agree the target cost per call before any candidate runs, because a cheaper model that misses the bar moves the cost into rework that never shows up in your tags. The full method is in how to build a test set.

Tracking will not always point to fine-tuning. If a feature changes every week or needs broad reasoning across many topics, a hosted frontier model may stay the right choice. A team with low call volume may find the saving is smaller than the work to train and test a model. Run a test on your own data before you switch, using the steps in how to test an LLM on your own data. For the per-call side of the math, see AI unit economics and cost per document.

Before you tag anything, run the free AI cost audit. It reads your code as text on your own machine, uploads nothing, and saves a PDF of the AI calls it finds, with models, estimated cost and checks. It is open source under the MIT license. If you want help choosing the first workload, ask us for a call.

Questions

How do I track LLM cost per feature?

Tag each model call with a feature name in one shared wrapper, then group spend by that tag. Calls with no tag go to an untagged bucket, and that bucket should shrink toward zero.

How do I track AI costs per customer?

Sum input and output tokens for each customer ID, price them at the model's list rate, and divide by what that customer pays you. The customers with the highest ratio are the first to review.

Which feature is driving our AI bill?

Sort tagged spend by feature and look at the top three. Check how many calls each one makes and how large each call is, since big prompts on a frontier model are a common cause.

What is an LLM chargeback model?

A chargeback model bills each team for the AI it uses, based on its tags. Metered billing at list price works best when teams control what they send.

What is LLM cost observability?

LLM cost observability means seeing cost and token counts for each call, tagged by feature, team and customer, in one place. It turns a monthly invoice into a report you can act on.