Skip to content
Back to Blog
FinOpsfinopscost-trackingllm-costs

Per-Agent LLM Cost Attribution: Who Spent What

Aggregate model spend tells you the bill, not the cause. How per-agent, per-team attribution works, and what a reviewer asks about it in a vendor review.

Gil KalApril 3, 20264 min read

An invoice arrives for $2,400 of LLM API calls, spread across three providers and eight agents. The invoice is correct and it is useless. It says what was spent. It does not say which agent spent it, on whose behalf, or whether the spend was the intended shape of the work or a retry loop nobody noticed until Monday.

Most teams treat this as a finance annoyance. It becomes something else the first time an AI vendor sells into a bank, because operational-resilience review asks about cost as a control, not as a number.

What procurement asks about cost

The cost question in a vendor-risk pack almost never arrives as "what do you spend?" It arrives as some version of: what stops one of your systems from consuming resources without bound, who is notified when it approaches that limit, and can you show me the last time it happened.

That is a resource-management question, and it sits inside the ICT risk obligations DORA pushes down from the financial entity to its providers. It separates two situations that look identical on a dashboard: a cap that is enforced, and a cap that is configured and has never been tested against real traffic.

A budget nobody has ever hit is a number in a settings page. The record of it firing is the control.

Attribution starts with identity on the call

You cannot attribute spend you cannot identify. Aggregate provider billing has no notion of which of your agents made a call, so attribution has to be established at the point the call is made — either by routing calls through a path that carries the agent identity, or by instrumenting the agent so its telemetry says who it was.

The routed path is OpenAI-SDK compatible, so frameworks that use that client underneath can point at it by changing the base URL and using a gateway key in place of a provider key:

from openai import OpenAI

# Before — calls the provider directly
client = OpenAI(api_key="sk-...")

# After — routes through the Dobby gateway
client = OpenAI(
    api_key="gk_user_...",  # a Dobby gateway key
    base_url="https://dobby-ai.com/api/v1/gateway",
)

Be honest with yourself about the scope of that change. The edit is small, but reaching it is a real integration: agents that build their own HTTP requests, hold provider keys in their own secret store, or run inside a framework that wraps the client differently all need individual attention. How long that takes depends on how your agents were built, and it is the part teams consistently underestimate.

Twelve providers are recognised today — Claude, OpenAI, Gemini, Grok, Bedrock, Llama, Perplexity, DeepSeek, Mistral, Azure OpenAI, GitHub Copilot and Microsoft 365 Copilot. Pricing, though, is keyed on the model rather than the provider: cost is computed against an effective-dated price list joined on the exact model string, so a model with no row covering the date of the call is still recorded, just not priced. Worth checking rather than assuming, because a newly released model is exactly the case that arrives unpriced.

What the record supports once it exists

With identity attached, three questions become answerable that the invoice could not answer: which agent accounts for what share of spend, whether an expensive model is earning its multiple over a cheaper one for a given task, and whether spend has a shape over time that matches the work or diverges from it.

The third one is where runaway loops actually get caught. A retry storm is not visible as a large total until the period closes. It is visible almost immediately as a shape that does not match the workload.

Attribution is what makes a cap possible, but the caps themselves — how a budget is scoped, why none of them can stop the run that first exceeds it, and the two bounds that decide what a cap means in a questionnaire — are the subject of a separate piece, and are covered properly there rather than in outline here.

The evidence this leaves

For a reviewer, the artefact is not the dashboard. It is the per-call record: the agent identity, the model, the tokens, the computed cost, and the run the call belongs to — enough that any line on the invoice can be traced back to the system that caused it.

The link between the call and the run is the part that is hard to add later. A per-call cost with no run to attach it to answers what was spent and not what it was spent doing, and a reviewer asking which system incurred a charge is asking exactly that second question.

Ready to take control of your AI agents?

Start free with Dobby AI — connect, monitor, and govern agents from any framework.

Get Started Free
Per-Agent LLM Cost Attribution: Who Spent What | Dobby