Guides

How to track what each AI agent costs

A provider's bill tells you what you spent. It doesn't tell you which agent spent it or whether the work was worth it. For that, you have to record who made each call.

Checked against the sources on October 31, 2026.

Why the invoice isn't enough

Provider reporting is organized around the provider's own units, such as projects, workspaces and models. That gets you "we spent $4,000 on this model". It doesn't get you "the research agent cost $900 this month, and most of that was one customer's account".

Without that second sentence you can't set sensible limits, charge a client, or tell which agent to fix first.

Decide what you need to split costs by

Ways to split LLM cost and the question each answers
Split byAnswers
AgentWhich agent is expensive?
WorkflowWhat does this job cost end to end?
KeyWhat did this app or integration spend?
Person or teamWho is using it, and how much?
CustomerIs this account profitable? What do we bill them?
ModelWould a cheaper model do this work?

Three ways to attach an identity to a call

One key per agent or client. The simplest approach, and it needs no code change. Any system that reports by key then reports by agent, and revoking one key stops one agent. The cost is managing more keys.

Metadata on each call. Send the agent, workflow or customer with the request through a gateway. Helicone, for instance, uses headers such as Helicone-User-Id and custom properties. This is finer-grained, but it relies on every call site setting the field, and a call that forgets goes unattributed.

Separate provider projects or workspaces. Good for a few broad divisions, like production and staging. It gets heavy as the count grows.

Whichever you choose, identity should be set by something the agent can't change. If an agent labels its own calls, a bug can mislabel them.

What to record for each call

  • Who made it: agent, workflow, key, person.
  • What it used: model, input tokens, output tokens, cached tokens.
  • What it cost, and who paid: your own provider key or platform credits.
  • What happened: success, failure, or refusal, with the reason.
  • When, in UTC, so daily totals line up with daily budgets.

You don't need the prompts or replies to do any of this. Leaving them out keeps sensitive text out of your cost system, and it keeps the system simpler to secure.

Connect cost to outcomes

Cost per call is a starting point. Cost per finished task is what you can act on. An agent that costs $3 and finishes the job may be better value than one that costs $0.50 and fails four times out of five, because failures are paid for too.

Record the result of each run and divide total cost by successful runs. That one number shows you which agent to improve and when moving to a cheaper model truly helps.

Then use it

Good attribution pays off three ways: you can set a budget for each agent from real figures, you can give clients a statement they can check, and you can find routes that do the same work for less.

Spend is in early access: you can set budgets and see what each call cost today, and budgets that stop calls are being switched on across the platform. See what Spend records for each call.

Questions

How do I track LLM costs per agent?
Give each agent its own API key, or send an agent identifier with each call through a gateway, then report cost by that key or identifier. One key per agent is the simplest way to start.
Can I see per-agent costs in my OpenAI or Anthropic bill?
Provider reporting is organized around units such as projects, workspaces and models. If each agent has its own project or workspace you get a rough split, and for anything finer you need your own record of who made each call.
Do I need to store prompts to track AI costs?
No. Cost attribution needs the model, token counts, cost, outcome and who made the call. Leaving out prompts and replies keeps sensitive text out of the cost system.

Sources