LLM cost tracking by customer, team and feature, without an SDK or a proxy
The CostReveal team, , 4 minute read
An AI bill is precise about the wrong thing. It says what each model cost each day, to the token. It cannot say which customer a call was for, which feature made it, or which team owns it, because only your application knows that. This post sets out how to track LLM spend by the people and products it served: what each provider's own structure already tells you, what it cannot, and how to divide the rest without putting anything in front of your calls.
Start with what the provider already knows
Before anything is instrumented, most AI spend can be explained by how it is already organized:
- OpenAI bills each project separately. CostReveal reads the organization's costs report through OpenAI's Admin API, by model and project, and a project owned by a team explains its spend.
- Anthropic bills each workspace separately. CostReveal reads the organization's cost report, the same figures as the Cost page in the Claude Console, and a workspace owned by a team explains its spend.
- Amazon Bedrock arrives on the AWS bill split by the IAM user or role that made each call, so a caller tagged with its team or customer explains its spend.
- Gemini on Vertex AI can carry labels on each request, which Google passes into the bill, so a call labelled with its customer or feature is explained by it directly.
If one team owns a project and its spend is theirs, that is the whole answer, and nothing more is needed. The difficult case is the common one: many customers share one key.
The shared key problem
A product serving thousands of customers rarely gives each one an API key or a workspace. One key serves everyone, and the bill says what that key cost. To know what each customer cost, something has to record each call with who it was for, and that record has to be matched to the bill.
The usual answers both carry a cost. An SDK wraps every call in your code, so tracking depends on each service adopting it. A proxy sits between your application and the provider, so every call passes through one more system that can slow or fail it.
Divide the bill by what your calls report
CostReveal takes a third route. It never sits between your application and the provider. Your application, or the gateway already in front of it, reports each call with who it was for, as OpenTelemetry GenAI spans, the open standard for describing model calls, and CostReveal divides the billed cost in proportion to each one's tokens. This is how OpenAI and Anthropic spend on a shared key is divided.
- From your application, if it already emits GenAI spans, by pointing its exporter at CostReveal.
- From a gateway you already run, such as LiteLLM, whose request metadata, a customer or a feature, arrives on each span. A LiteLLM proxy's own logs can be read too.
- Nothing is slowed or blocked. If the data stops arriving, your application carries on exactly as before.
The key that sends this data is scoped to sending data only. It can read nothing, so it is safe to keep in your services.
The bill stays the bill
Dividing spend this way must never change what was spent:
- Only billed spend is divided. Usage data never adds a cent; totals stay exactly what the provider billed.
- Only what it covers. If your data reports 60 percent of the tokens a model was billed for, 60 percent of that model's unexplained cost is divided, and the rest stays Not yet explained.
- Owners come first. A workspace or project already owned by a team keeps that owner; usage data divides only what owners leave unknown.
- The basis says how. Spend divided by measured usage is marked ALLOCATED, so nobody mistakes a share for a direct charge.
What it is for
Once spend is tracked by customer, feature and team, the questions that matter can be answered. Which customers cost more to serve than they pay? Which feature's cost per request is rising? Which team's model choice doubled its spend? With Stripe connected, each customer's revenue sits beside what serving them cost, for a gross margin by customer.
What it does not claim
Division is only as complete as the calls your data reports, and the coverage of each model says how complete that is. Usage data divides OpenAI and Anthropic spend; Bedrock and Gemini spend is explained by the tags and labels their bills carry, and usage data does not yet divide it. Azure OpenAI's export names models only in its meter text, so its spend is shown by service and meter, without a model. And a share by tokens is a measured share, not a direct charge, which its basis states.
Frequently asked questions
Do I need to change my code? Not to read what each provider bills. To divide one shared key by customer, your application or gateway reports each call as an OpenTelemetry GenAI span, which many already emit.
Does CostReveal sit in front of my AI calls? No. It never sits between your application and the provider, and nothing is slowed or blocked if its data stops arriving.
Which providers does it cover? OpenAI and Anthropic directly, divided by usage data on a shared key; Amazon Bedrock and Gemini through the AWS and Google Cloud bills, by their tags and labels; and Azure OpenAI by service and meter.
What if my data covers only some calls? Only the share of tokens your data reports is divided. The rest stays not yet explained.
Can I see margin by customer? Yes. With Stripe connected, each customer's revenue sits beside what serving them cost.
Keep reading
- How to track OpenAI API costs per customer: projects, the costs report and usage data.
- How to track Claude API costs per customer and feature: workspaces and shared keys.
- Amazon Bedrock costs by model and team: AI spend on the AWS bill.
- Sending usage data: every supported span and gateway.