Most teams can tell you their total LLM bill. Almost none can tell you which feature, tenant, or user drove it. Attribute every request to a feature, tenant, and user at call time, and the spend distribution almost always turns out to be a Pareto curve: a small slice of usage — often one aggressive tenant or one runaway feature — accounts for the majority of cost.
Quick answer: Tag every LLM call with
feature_id,tenant_id, anduser_idmetadata at the point of the request, pipe it into your usage logs, and aggregate cost by dimension. Without that tagging, you're optimizing a blended average that no single customer or feature actually resembles.
Why a Blended AI Bill Lies to You
A single monthly number from your model provider tells you what you spent, not why. It averages together a low-cost autocomplete feature, a token-hungry document summarizer, and one enterprise tenant running batch jobs overnight. Optimizing against that average means you're guessing.
The blended bill problem is structurally the same one finance teams solved decades ago with activity-based costing: you can't manage a cost center you haven't decomposed into its actual cost drivers. Robert Kaplan and Robin Cooper's original activity-based costing research at Harvard Business School made the case that overhead allocated by broad averages (like headcount or revenue share) systematically misattributes cost to the wrong products — and management acts on the wrong signal as a result. LLM spend is overhead with the same failure mode, just newer.
Three symptoms tell you your organization has this problem:
- Nobody can answer "which feature is our most expensive to run" without a special one-off analysis.
- Pricing and packaging decisions are made off gross margin, not feature-level margin.
- A single customer complaint about "AI is slow" can't be traced to whether that tenant is simply sending 50x the request volume of everyone else.
Instrument Every Call: The Metadata Checklist
Attribution is only as good as the metadata attached at request time — retrofitting it from logs after the fact is unreliable because raw provider logs rarely preserve business context. Add a structured metadata block to every LLM call before you ship the feature, not after finance asks for a breakdown.
At minimum, tag each request with:
| Field | Purpose | Example |
|---|---|---|
feature_id | Which product surface issued the call | search-summarize, email-draft, support-triage |
tenant_id | Which customer account owns the call | acct_9182 |
user_id | Which individual user triggered it | usr_4471 |
model | Exact model + version used | gpt-4.1-mini, claude-sonnet-4-5 |
input_tokens / output_tokens | Raw token counts, not just cost | 1,204 / 340 |
cache_status | Whether the call hit a cache | hit, miss, partial |
request_type | Interactive vs. batch vs. background job | sync, async, cron |
timestamp | For time-series and anomaly detection | ISO 8601 |
Where This Metadata Lives
Most teams pass this as a wrapper object around their model client call, then emit it to whatever event pipeline already handles product analytics — Segment, a Kafka topic, or a warehouse table. The point isn't the specific tool; it's that cost data joins the same dimensional model as your product usage data, so you can slice cost by the same feature and account IDs your product analytics already use.
Handling Multi-Step and Agentic Calls
A single user action can trigger a chain of model calls — a planning call, tool calls, a synthesis call. Tag every step with a shared trace_id and the same feature_id/tenant_id, or you'll undercount the true cost of agentic features by only capturing the final call. This matters more every quarter as agentic workflows spread; see our breakdown of routing requests to cheap, fast, or default-tier models for how step-level tagging also unlocks per-step routing decisions.
Build the Attribution Pipeline, Not Just a Dashboard
A cost dashboard that shows "total spend over time" is not attribution — it's a restatement of the invoice. Real attribution requires a join between your usage events and either your billing API's per-request cost or a computed cost model based on token counts and published per-token pricing.
The pipeline has three stages:
- Capture — every call emits the metadata block above, logged at request time, not reconstructed later.
- Cost — join token counts against current model pricing (or your provider's cost API where available) to get a dollar figure per call.
- Aggregate — roll up by
feature_id,tenant_id, anduser_idindependently, so you can answer "which feature" and "which tenant" as separate questions.
Keep the raw per-call records, not just aggregates. When a monthly total spikes, you'll want to drill from feature-level to tenant-level to individual-request level without re-instrumenting.
What to Watch Weekly
Once the pipeline exists, a few standing views catch most problems early:
- Cost per feature, week over week — catches a feature whose prompt or context window silently grew.
- Cost per tenant vs. tenant's contract tier — catches free-tier or lower-tier accounts consuming disproportionate spend.
- Cost per active user, by feature — catches abuse or bot-like usage patterns hiding inside a normal-looking tenant total.
The Pareto Distribution Attribution Reveals
Once you split blended spend into feature x tenant x user, the shape is rarely flat. It resembles the classic 80/20 pattern Vilfredo Pareto first observed in wealth distribution and that Joseph Juran later generalized into quality management as the "vital few and trivial many" — a small number of causes driving most of the effect.
A realistic (illustrative, not a live customer) breakdown might look like this:
| Segment | Share of Total Requests | Share of Total Cost |
|---|---|---|
| Top 1 tenant | 4% | 31% |
| Next 9 tenants | 21% | 34% |
| Remaining ~90 tenants | 75% | 35% |
The top handful of accounts routinely account for a wildly disproportionate share of spend relative to their request volume — usually because they're sending longer inputs, requesting larger outputs, or hitting a feature with a bloated system prompt.
The Enterprise-Tenant Abuse Pattern
A common pattern once you look at tenant-level attribution: one enterprise account, often your largest logo, dominates total AI cost — not because of malice, but because of an integration pattern nobody reviewed. A batch job re-summarizing an entire document library nightly. A support-triage feature re-sending full conversation history on every turn instead of just the delta. A power user with a script calling your API in a loop.
None of these show up in a blended average. They only surface when you can filter cost by tenant_id and feature_id simultaneously and see one cell in that matrix light up. Once you can see it, the fix is usually cheap: cap context window growth, add pagination to batch jobs, or move the tenant to a rate-limited plan tier — all far less expensive than model-level cost cuts. Two levers worth checking first are whether a semantic cache would deduplicate repeated queries from that tenant, and whether prompt caching mechanics apply to a system prompt that's being resent unchanged on every call.
Turn Attribution Into Pricing and Roadmap Decisions
Attribution data is only valuable if it changes a decision. The two decisions it should inform most directly are pricing (does this tenant's usage pattern fit their contract) and roadmap (which feature's cost trajectory needs engineering attention before it needs a price increase).
Pricing Decisions
| Signal from Attribution | Likely Pricing Action |
|---|---|
| One tenant's cost >> their contract tier implies | Move to usage-based add-on or higher tier |
| A feature's cost per active user is rising steadily | Investigate before repricing — may be a fixable inefficiency, not a real cost floor |
| Cost concentrated in free/trial tier | Add rate limits or a feature gate before conversion |
| Cost evenly distributed across paid tiers | Blended per-seat pricing is probably still fine |
Roadmap Decisions
Feature-level attribution turns "AI is expensive" from a vague finance complaint into a specific, scoped engineering problem: this feature, this cost driver, this fix. That's a fundamentally different conversation than asking engineering to "reduce AI costs" against no target.
It also sharpens trade-off conversations between features competing for the same optimization budget — the same discipline covered in our complete guide to trade-off analysis for product teams, which walks through weighing competing constraints (cost, latency, quality) against each other systematically rather than by gut feel.
Where Prodinja Fits
Key Takeaways
- A single blended LLM bill hides which feature, tenant, or user actually drives cost — you need dimensional attribution to see it.
- Tag every call with
feature_id,tenant_id,user_id, model, token counts, and cache status at request time, not reconstructed after the fact. - Cost attribution almost always reveals a Pareto distribution: a small share of requests, often from one enterprise tenant, drives a disproportionate share of spend.
- Multi-step and agentic calls need a shared
trace_idso you don't undercount chained model calls as a single cheap request. - Attribution data should directly change two decisions: whether a tenant's contract tier matches their usage, and which feature's cost trajectory needs engineering attention.
- Checking for caching opportunities (semantic and prompt-level) is usually the cheapest fix once you've identified the cost driver.
Frequently Asked Questions
How do you track LLM cost per feature?
Track LLM cost per feature by attaching a feature_id tag to every model call at request time, then joining that tag against token counts and current model pricing in your usage pipeline. Retrofitting feature attribution from raw provider logs afterward is unreliable because those logs rarely preserve product-level context.
What is per-tenant cost tracking and why does it matter for B2B SaaS?
Per-tenant cost tracking attributes AI spend to individual customer accounts (tenant_id) rather than reporting one blended total. It matters for B2B SaaS because pricing tiers are usually set on assumed usage patterns, and one tenant's abuse pattern or heavy integration can quietly erode margin on that account without ever showing up in an aggregate bill.
How much of AI spend is typically driven by a small number of users or tenants?
There's no universal fixed percentage, but attribution work consistently surfaces a Pareto-shaped distribution where a small fraction of tenants or requests account for a disproportionate share of cost — directionally consistent with the 80/20 pattern Vilfredo Pareto and later Joseph Juran documented across many cost and quality domains. The exact split depends on your product and usage patterns, so measure it rather than assume a number.
What metadata should every LLM API call include for cost attribution?
At minimum, every LLM call should include feature_id, tenant_id, user_id, the exact model name and version, input and output token counts, cache hit/miss status, and a timestamp. For multi-step or agentic workflows, also add a shared trace_id so chained calls roll up under one logical request.
Should cost attribution change how we price AI features?
Yes, but only after you've ruled out fixable inefficiency. If one tenant's usage genuinely exceeds their contract tier's assumptions, a usage-based add-on or tier move makes sense. If a feature's rising cost per user turns out to be an unoptimized prompt or missing cache, fix the inefficiency before repricing around it as a permanent cost floor.