The same question, and the same answers, apply to Anthropic. If multiple agents share one or two API keys, you have no way to know which agent is responsible when the bill jumps. The provider dashboard shows tokens by key, not by agent, customer, or feature. By the time the invoice arrives, the spike is three weeks old and nobody on the team remembers what shipped.
Across the teams we've talked to, the same three patterns account for most runaway-spend incidents. None of them produce an exception, none of them fail an existing alert, and none of them are visible in the provider's usage page.
claude-haiku to claude-opus for one agent because they were testing quality. The change ships. The cost-per-run for that agent jumps 12x and nobody notices for a week.The smallest instrumentation that catches all three patterns is the same: a cost number per run, attributed to the agent that produced the run, with a rolling baseline that knows what normal looks like for each agent.
| Agent | Customer | Runs | Cost | Cost / run |
|---|---|---|---|---|
| support-triage | acme-corp | 12,408 | $1,460 | $0.118 |
| research-agent | (unattributed) | 214 | $409 | $1.910 |
| content-writer | acme-corp | 3,114 | $967 | $0.310 |
| email-classifier | acme-corp | 18,672 | $163 | $0.009 |
The flagged row is a research-agent invocation running at 16x the cost-per-run of the other agents on the team, and missing its customer_id tag. That's a backfill job that started looping; the daily anomaly check finds it the morning it starts, not the first of next month.
Chat APIs are stateless. Every turn of an agent session sends the whole conversation so far as input: the system prompt, every earlier message, every tool result. Turn forty pays for the thirty-nine turns before it, again.
The fixes are unglamorous: summarise or truncate old turns, keep tool output out of the history once it has been used, and put the stable part of the prompt first so it caches. How to claim the prompt-caching discount covers the last one in detail. Per-run cost makes the problem visible: a resumed session shows up as one run costing ten times its neighbours.
The invoice has arrived and the number is wrong. Before you instrument anything, check what the provider already recorded. How far that gets you depends on how you split your keys.
If each team or agent has its own project, workspace or key, the provider report answers the question. If seven agents share one production key, it cannot: the provider never knew which agent made a request, so no export can recover it. The same goes for customers and features. That part needs attribution at the time of the run, tagging each run with its agent, customer and feature as it starts, so the next spike arrives already explained. Splitting keys per agent is a reasonable stopgap; it stops scaling once you want cost per customer.
Spend is the cost-attribution side of Agent Ping. The features page walks through the rate card model, anomaly detection, and per-customer cost rollups. The docs go one level deeper.
Spend features → Spend docs → Spend guard → Agent cost calculator → Track LLM cost per customer → What is AI agent observability? →