How to track OpenAI API costs per customer
The CostReveal team, , 4 minute read
Every product built on the OpenAI API reaches the same question as it grows: which customers is the bill for? OpenAI's costs report says what each project spent on each model, each day. It cannot say which of your customers a call was made for, because that is something only your application knows. This post walks through how to answer it with CostReveal, from what OpenAI already reports to the calls your application already records, and what stays unexplained until the data covers it.
What OpenAI's bill can and cannot tell you
OpenAI reports costs by day, by project and by line item. A line item names a model and a kind of usage, such as gpt-5, input_tokens, with the tokens it was billed for. That is enough to see spend by model and by project exactly, and CostReveal shows it that way, with the DIRECT basis, as OpenAI stated it.
What the report cannot do is split one project's spend between the customers it served. Projects carry no tags, and when many customers share one project and one API key, the cheapest customer and the most expensive one look identical on the invoice.
Step one: give each project an owner
Projects are the first split, and often the right one for teams and features. Under Connections, Project owners, name the team, feature or customer each project belongs to. That explains the project's spend with the INFERRED basis, for every past period too, since naming an owner explains history again. Costs OpenAI reports outside any project are listed as No project, and can be given an owner as well.
If each of your largest customers has a project of its own, this alone answers the question for them. For most products it does not: customers share a project, and the split has to come from the calls.
Step two: report who each call was for
Your application, or the gateway in front of it, already knows the customer behind each call. CostReveal reads that from what you can already emit:
- OpenTelemetry GenAI spans, from your application or a gateway such as LiteLLM, with the customer as an attribute such as
app.customer; - a gateway's own logs, read from LiteLLM or Portkey with a key that can read them;
- the usage events endpoint, one event per call, for code that sends no telemetry.
An event names the provider, the model, the tokens and who the call was for:
{
"id": "req_7f31a2",
"timestamp": "2026-11-03T09:14:52Z",
"provider": "openai",
"model": "gpt-5-2025-08-07",
"inputTokens": 3200,
"outputTokens": 640,
"customer": "cust-1042",
"feature": "summaries"
}
Send identifiers, never email addresses. No prompt or response is read, and CostReveal never sits between your application and OpenAI: nothing is slowed or blocked, and if the data stops arriving, your application carries on exactly as before.
How OpenAI spend is divided
CostReveal divides the spend that project owners, tags and rules leave unknown, model by model and day by day, in proportion to each customer's measured tokens, and marks it ALLOCATED. For OpenAI, three details matter:
- Input is one pool and output another. Input of every kind, cached and audio included, is divided by the input tokens your data reports. OpenAI does not document a list of its kinds, so cached input is not divided apart: a customer whose calls hit the cache more is charged the pool's average price per input token.
- Only what is counted in tokens. A line counted in anything else, such as images, stays Not yet explained rather than being divided on a guess.
- Snapshots match their model.
gpt-5-2025-08-07in your data matchesgpt-5on the bill, however each side writes it.
Coverage, not guesses
Usage data never adds a cent. Totals stay exactly what OpenAI billed. If your data reports 60 percent of the tokens a model was billed for, 60 percent of what is unexplained is divided, and the rest stays Not yet explained, shown as such and never spread across customers to look complete. The usage data section of Connections shows the coverage of each model, so a gap points at the calls your instrumentation misses.
Send each call by one route. A call reported both by your application and by your gateway is counted twice, which shows up as coverage above what was billed.
What you can do with it
With usage data arriving, Business shows what each customer, feature and user cost, beside the calls made for them, and Explore groups OpenAI spend by customer, then by model, to see whose usage runs on the most expensive models. Budgets can watch a customer or a feature the same way they watch a project.
Connect Stripe, and each customer's revenue sits beside their cost, for gross margin by customer. AI cost per customer, and the margin it leaves covers that step.
Frequently asked questions
Do I need to change how my application calls OpenAI? No. CostReveal reads OpenAI's costs report with an admin key, and the calls from telemetry, gateway logs or events you send. Nothing sits in the path of your calls.
What if every customer shares one API key? That is the case usage data is for. Project owners explain what projects can; usage data divides the rest by each customer's tokens.
Does it read prompts or responses? No. Only the model, the tokens and who the call was for.
What happens to calls my data does not cover? Their share of the bill stays Not yet explained, in the open, until the data covers it.
Is OpenAI spend on Azure divided the same way? No. Azure OpenAI is billed on your Azure bill, and AI spend on a cloud bill is not divided by usage data.
Keep reading
- Connecting OpenAI to CostReveal: the admin key, and naming project owners.
- AI cost per customer, and the margin it leaves: from cost per customer to gross margin with Stripe.
- Why CostReveal shows the spend it cannot explain: how uncovered spend stays in the open.