Back to guides

AI API Cost Management

AI API Cost Allocation: How to Split One LLM Bill Across Projects

A worked method for splitting one month's AI API invoice across projects or teams: what to tag, which costs are shared, how to divide them, what to do with untagged traffic, and how to make the split add up to the invoice.

Quick answer

Price every tagged request from its token counts and give that amount to its project. Put the rest in named pools: shared indexes, evals, untagged traffic and the gap between your logs and the invoice. Split each pool by a rule you write down, usually each project's share of direct cost. In our $10,000 example, $8,000 is direct and $2,000 has to be split.

ModelInput $/1MCached input $/1MOutput $/1MSourceLast verified How we verify
Claude Sonnet 5.5$2.00$0.10$10.00Official sourceOct 9, 2026
Claude Haiku 5.5$0.10$0.01$0.50Official sourceOct 30, 2026

Prices from official provider pages, verified on the date shown.

8 min read - Published Nov 3, 2026 - Updated Nov 3, 2026

Tracking tells you who used what. Allocation decides who pays.

Tagging requests by project is the first half of the job, and our AI API cost tracking guide covers it. This article is the second half. At the end of the month there is one invoice. Part of it maps neatly to tagged requests. The rest does not: a search index three products share, test runs, scripts nobody tagged, and a gap between what your logs add up to and what the provider billed.

Allocation is the set of rules that turns that invoice into one number per project, and those numbers must add up to the invoice. If they don't, someone will ask where the rest went, and the report loses trust.

invoice = direct costs (tagged requests)
        + shared pools (indexes, evals, platform features)
        + untagged requests
        + gap (invoice minus what your logs add up to)

project share = its direct cost + its part of each pool

What to log on every request

Use separate OpenAI projects, Anthropic workspaces or Google Cloud projects per product where the provider allows it. That gives you a coarse split from the provider's own usage reports. It cannot see features or customers inside a product, so log these fields in your own code as well:

  • project or cost center, set where the API client is created, not where the prompt is written
  • feature or workflow, such as support-reply or weekly-summary
  • environment: production, staging or development
  • a pseudonymous customer or tenant ID if you want per-customer cost
  • model, plus input, cached input and output token counts from the API response
  • request ID and whether the call was a retry

Read token counts from the usage field the API returns, not from an estimate of the prompt. Reasoning tokens, tool definitions and retries are in the real numbers and not in your guess. Then price each record from one current price table, so every project is priced the same way.

A worked split: one $10,000 month, three projects

Here is a made-up month for a company with three AI features on one provider account. The numbers are round so the arithmetic is easy to follow; your pools will have different sizes.

LineAmountWho it belongs to
Support bot (tagged)$4,000Support
Sales email drafts (tagged)$2,400Sales
Internal search assistant (tagged)$1,600Internal tools
Shared knowledge index: embeddings and re-indexing$300Support and Internal tools
Evaluation and test runs$600All three
Untagged requests$900Unknown
Gap between priced logs ($9,800) and invoice$200All three
Invoice total$10,000

Direct costs are $8,000, so the three projects' direct shares are 50%, 30% and 20%. The other $2,000 needs rules. These are the ones we would write down for this month:

  • Shared index ($300): split by retrieval queries. Support ran two thirds of them and the internal assistant one third, so $200 and $100. Sales does not use the index and pays nothing.
  • Evals ($600): split by direct share, so $300, $180 and $120. If each test suite carries a project tag, charge it directly instead.
  • Gap ($200): split by direct share, so $100, $60 and $40.
  • Untagged ($900): keep it as its own line, or split it by direct share if every dollar must be charged back.
ProjectDirectIndexEvalsGapShowback totalUntagged shareChargeback total
Support$4,000$200$300$100$4,600$450$5,050
Sales$2,400$0$180$60$2,640$270$2,910
Internal tools$1,600$100$120$40$1,860$180$2,040
Unallocated$900$0
Total$8,000$300$600$200$10,000$900$10,000

Both versions add up to $10,000. The showback version leaves $900 visible as unallocated. The chargeback version makes Support pay $450 for requests nobody can prove were Support's. That is fair only if untagged traffic really follows the same pattern as tagged traffic, and you rarely know that.

Split shared costs by dollars, not tokens

Token counts look like the neutral way to split a shared cost. They are not, once projects use different models. Say Support runs on Claude Sonnet 5.5 and sends 300 million input and 30 million output tokens a month, while the internal assistant runs on Claude Haiku 5.5 and sends three times that: 900 million input and 90 million output.

ProjectModelTokens (input / output)Share of tokensMonthly cost
SupportClaude Sonnet 5.5300M / 30M25%$900.00
Internal assistantClaude Haiku 5.5900M / 90M75%$135.00

By tokens, the internal assistant would carry 75% of every shared pool. By dollars it carries only a small part, because its model is far cheaper. A team that moves to a cheaper model to save money should not end up paying more of the shared costs for it. Dollar share follows the bill, so use it unless a pool has a clearer driver, like retrieval queries for a search index.

Allocation keys that work, from most to least direct: the pool's own usage measure (queries against an index, test cases per suite), then each project's direct dollar cost, then active users or requests. An even split is the last resort; it is simple and almost always wrong for someone.

Untagged traffic: find it before you spread it

Untagged spend in our example is 9% of the bill. Spreading it hides the problem that created it. It usually comes from a few places: scripts and notebooks using a shared key, a background job written before tagging existed, a new service that forgot the tag, or a developer testing in production.

  • Group untagged requests by API key, model and hour of day; scripts and batch jobs show up as clear clusters.
  • Give each person and each job its own key, so an untagged request at least has an owner.
  • Pick a limit for untagged spend, such as 5% of the bill, and review it every month. We use 5% as a working target, not an industry figure.
  • Reject or flag requests without a project tag in your API wrapper once coverage is good.

Close the gap to the invoice every month

Your priced logs will not equal the invoice exactly. Common reasons: cache writes or long-context rates your price table does not apply, tool fees such as web search, batch or priority pricing, requests that failed after tokens were billed, a price change mid-month, and taxes or credits on the invoice. In the example the gap is $200, or 2%.

Spread a small gap by direct share, as above. When it is large, find the cause first; it often means one project uses a feature your price table does not model, and that project should get the cost. Keep the gap as its own line in the report, so a growing gap is visible instead of quietly raising everyone's numbers.

The invoice is the total; your logs are the split

Provider billing exports and invoices decide how much was spent. Your logs decide who spent it. Price logs to explain the bill, never to replace it.

From project cost to cost per customer

The same method works one level down. With a customer or tenant ID on each request, a project's direct cost splits by customer, and its share of the pools can follow the same rule. That is the number to compare with what each customer pays you. The AI SaaS margin calculator takes cost per customer and plan price and shows the gross margin. To limit what one customer or team can spend, see AI API budget limits.

If a project's direct cost is the problem rather than the split, price the same workload on other models with the AI API cost calculator before you change anything.

FAQ

What is AI API cost allocation?

It is splitting one provider invoice across the projects, teams or customers that caused it. Tagged requests go straight to their owner. Costs nobody owns alone, such as a shared search index, evaluation runs and untagged traffic, are split by a rule. The parts must add up to the invoice.

How do I allocate OpenAI or Claude API costs by project?

Give each project its own OpenAI project or Anthropic workspace where you can, so the provider reports it separately. Then log a project tag, model and token counts on every request in your own code. Price each request, add it up per project, and split the costs that remain by a written rule.

Should shared AI costs be split by tokens or by dollars?

By dollars in most cases. Tokens on different models cost very different amounts. In our example a project on Claude Haiku 5.5 uses three times the tokens of a project on Claude Sonnet 5.5 but costs $135.00 against $900.00. Splitting by tokens would charge the cheaper project most of the shared costs.

What should I do with untagged AI API requests?

Show them as their own line in the report, find where they come from, and add the missing tag. Spread them across projects only when you have to charge every dollar back, and say that you did. If untagged spend is a large share of the bill, fix tagging before you argue about the split.

What is the difference between showback and chargeback for AI costs?

Showback reports each team's share without moving money, so it can leave unallocated costs visible. Chargeback moves the cost into each team's budget, so every dollar must land on someone. Most companies start with showback until tag coverage is good.

Turn tagged usage into a report people can read.

The Team API Cost Report groups AI spend by project, team, workflow and model, so each owner sees their share of the bill and what drives it.

Build a Team Cost Report