Cost Attribution: Tracking LLM Spend by Feature and User
July 20, 2026 · 6 min read
Cost attribution turns a monthly LLM total into an answerable question: who and what spent it. How to tag every call and roll spend up by feature, model, and user.
"Our AI bill went up 40%" is a fact you can't act on. "The summariser's output tokens tripled after Tuesday's prompt change, and 80% of it is one enterprise customer" is a fix. The distance between those two sentences is LLM cost attribution - tagging spend so every dollar has a feature, a model, and a user attached.
Tag at the call site
Attribution starts where the request is made. Every call carries a small envelope of metadata that travels with the recorded usage:
record({
project: "prod-app", // which app/environment
feature: "summariser", // which product surface
user: currentUser.id, // who triggered it
model: res.model, // which tier
inputTokens: res.usage.input_tokens,
outputTokens: res.usage.output_tokens,
costUsd: price(res.model, res.usage),
});The dimensions to roll up
- By feature - almost always concentrated. One or two surfaces are usually the majority of spend.
- By user - long-tailed. A handful of accounts drive a disproportionate share; find them before they find your invoice.
- By model - reveals silent upgrades and mis-routed traffic.
- By time - a step-change lined up with a deploy points straight at the cause.
What attribution unlocks
- 01Targeted optimization - tune the 20% of features that are 80% of the bill, not everything.
- 02Fair per-user caps - set hard caps from real usage instead of guesses.
- 03Meaningful alerts - baseline per feature so a spike in a small surface isn't hidden by total volume. See budget alerts.
- 04Unit economics - map spend to revenue per customer and know which accounts are underwater.
Attribution is the foundation the rest of cost control stands on - it's the first thing to add when you start monitoring Claude costs, and it's what makes a Slack cost alert specific enough to act on.