I've seen too many people start an agent or a long-running script, walk away, and come back to a few thousand dollars of spend. The public cases run bigger. In February 2026 a stolen Gemini API key ran up $82,314.44 in about 48 hours on an account whose normal bill was about $180 a month, and Google pointed to shared responsibility. An AI agent with full access to an AWS account ran up $6,531.30 overnight while scanning a hobbyist network, and AWS cut the bill to $1,894.

The controls most companies start with weren't built for that speed. Standard Google Cloud budgets only send alerts, and they run on billing data that arrives late. Google's newer spend caps can pause a service like the Gemini API, but they've been in preview since April 2026, with access granted case by case. AWS budgets react to billing data that can lag up to 24 hours, and OpenAI's hard spend limits do block requests, though OpenAI says enforcement lags and spend can run slightly past the cap.

On my own projects, a few habits cover most of this: a key per service, a cap on anything that runs unattended, and an estimate plus my go before any big run. A company needs more, because no one person sees every key. It needs a spend dashboard it builds for itself, alerts on how fast money is moving as well as how much has gone, a gateway that every agent goes through, and a way to connect the spend to the work it paid for.

A key per service, and no big run without an estimate

Every service in my builds gets its own API key, named for that service. With one shared key, nobody can say which product spent the money, and a leak exposes everything at once. Split keys also keep a leak small: you rotate one service's key while everything else keeps running. Keys only help if every call is counted, though. In one project, some AI calls skipped the cost tracker because writing them that way was quicker, and their spend showed up nowhere, so now every AI call goes through the one tracked path.

Anything that costs real money waits for me. My agents don't start a paid AI job until they've posted four lines: the target, the expected time, the expected cost and what the run will test. That rule came from small runs that kept costing money with nothing to show for them, and from long jobs that timed out halfway and still billed for the half they finished. A big batch starts as a dry run on a few items, because one clean run doesn't mean the next thousand will go the same way. And I don't leave an agent running around the clock without a cap and a way to stop it.

A company needs a spend dashboard it builds for itself

The stock Claude dashboard isn't enough for a company, and neither is any other single provider's, because each one sees only its own slice. The Anthropic Console sets a monthly spend limit and rate limits per workspace and emails an alert at a dollar amount you choose. OpenAI sets limits per organization and per project. In July 2026, Claude Enterprise added per-member spend limits through an API, alerts to admins at 75% and 90% of a limit and to users at 75% and 95%, and control over which roles can use which models. Those are worth turning on, but each stops at its own vendor. A company with Claude seats, an OpenAI project, a Gemini key in Google Cloud and AI features inside its help desk has its spend in four places, and none of them shows the whole of it.

I'd build one page that shows every API key and every block of seats, broken out by service, team and owner, and make it visible to the whole company. When the owner, their manager and finance all see the same number, a spike gets noticed the day it happens instead of when the invoice lands. Every tool, block of seats and usage account on it gets a named owner and a budget line, and before renewal the owner pulls two lists: seats nobody opened last month, and AI features in tools you already pay for that nobody switched on. API usage is easiest to collect at a gateway, since every request already passes through it.

Alert on how fast spend moves, and send a person

An agent's behavior is probabilistic. The same task can finish in five calls or loop for hours, and the same prompt can take a different path on its second run. You can't make that predictable, but you can make the limits around it deterministic: a cutoff that stops a key at the same number every time, and a gate that holds a run until a named person approves it. That's the split I use for cost. Model choice and agent behavior get tested and tuned, while caps and gates are written as rules the agent has no say in.

Most tools cap the total over a window, like a month or a day, and that misses the fast cases. Google reversed two other bills reported in May 2026: $10,000 run up in 30 minutes, and $17,000 within minutes of an automatic tier upgrade. A monthly cap sized for a busy company would let either one through. What catches them is velocity, how fast spend is climbing against its normal rate, and very few tools alert on it. The only explicit velocity signal I found across the providers' and gateways' docs is in Anthropic's admin scripts for Claude Enterprise, which flag "rapid usage changes."

When a key trips a spend-cap alert and a velocity alert together, the next step should be a person checking in with whoever owns it, more or less "u good bro?" In the cases I've seen, it was a process someone started and let run, and the owner could have said so in a minute. An alert that lands on a dashboard can sit there all night, which is why the velocity alert should page a person and the cutoff shouldn't wait for anyone.

Two hard lines sit under the alerts. An automatic cutoff stops a key or an agent at a set amount, at 3 a.m., with nobody awake. A cost gate pauses anything that would cross a set amount, like a large batch run or an agent asking for a bigger budget, until a named person approves it, which is the company version of my four-line rule. Set the cutoff below the real ceiling, since OpenAI's enforcement lags and Cloudflare's AI Gateway counts cost only after each request finishes, so a burst can run past the line. On AWS, the controls that act while spend is happening are account-level permission rules that block expensive services outright, and alerts on calls to AI models and new servers in the account's activity log.

Every agent goes through a gateway, with access by role

A gateway is a layer every AI request passes through on its way to a model, which makes it the one place to enforce budgets, log spend by key and decide who can use what. LiteLLM, which is open source, sets budgets per key, user or team and fails requests once a budget is spent, though budgets are off by default and it needs a database. Cloudflare's AI Gateway sets dollar budgets by provider, model, user, team or app, and at the cap it either blocks or falls back to a cheaper model. Portkey caps each key in dollars or tokens and expires the key at the limit. Any of them can feed the company dashboard, because the spend already passes through them with a key attached.

Agents also call tools, and that's where access by role matters most. Through MCP, an agent reads a list of tools (the help desk, the tracker, a database, a cloud account) and decides which to call and with what arguments. MCP is probabilistic and generally very helpful. When I need a tool to do one well-defined thing the same way every time, I build it on the API directly and give the agent that instead. Either way, something has to decide which agents and people can reach which tools. Kong's MCP proxy allows or denies each tool per user or group, checked both when the tools are listed and when they're called, and Azure's AI gateway sets token limits per subscription key and governs MCP servers.

The agent behind the $6,531 AWS bill had full access to the account. I'd start every agent read-only and widen its access by role as the work proves it needs more. At Tools for Humanity I wrote our support organization's policy for using Claude, Codex and Notion AI safely: model limits, read-only by default, dry runs before any write, and hooks that blocked writes outside a user's role. An agent gateway with role-based access (RBAC) was on the roadmap.

Because every request passes through it, and it usually holds the provider keys, the gateway needs the same suspicion as any package you install. LiteLLM itself was backdoored on PyPI for about 40 minutes on March 24, 2026, through a token stolen via the compromised Trivy security scanner. Pin the version, review updates before they roll out, and know who can push a change to the one layer that sees every AI request.

Pick the model by the job

Once spend shows up by service, the first thing to check is which model each service runs on. Models are billed by the token, the small chunks of text they read and write. On Anthropic's price list, Opus 5.5 costs 40 times as much per token as Haiku 5.5, and Fable 5.1 costs 100 times as much. If Haiku sorts your tickets just as well, putting Opus on that job means paying 40 times as much for the same answers.

Opus 5.5 costs 40 times as much per token as Haiku 5.5

Each card is Haiku 5.5's price per token.

SOURCE: ANTHROPIC'S PRICE LIST

Price per token on Anthropic's price list, counted in cards, each card Haiku 5.5's price. Haiku 5.5, Anthropic's cheapest model: 1 card, 1 times. Opus 5.5: 40 cards, 40 times, marked. Fable 5.1: 100 cards, 100 times.

When my code calls the API, it defaults to Haiku, Anthropic's cheapest model, and a run on anything bigger needs my go. Hands-on coding with ALAI, my team of AI agents, runs on Opus 5.5, because I haven't found the cheaper tiers good enough for it and it gives me the best performance for the price. Planning goes to the most advanced model I have. Testing whether my security engine catches what it claims to catch runs on Opus too, since a model that misses subtle bugs can't tell me whether the engine works. Which tier is good enough for a job is something you find out by testing it on real work, and the answer can change when a new model ships.

Every call resends the prompt, so cache it and keep it short

Agents that run on their own send the same long block of instructions, tool definitions and reference docs on every call. Prompt caching lets the provider keep that block and bill repeat reads at a discount. On Anthropic's API, caching is opt-in, and a cached read costs a tenth of the normal input price, or a twentieth on Opus 5.5 and Sonnet 5.5; OpenAI and Google cache repeated prompts automatically. The cache only matches when the start of the prompt is identical, so what never changes goes first, and anything that does change, even a timestamp, goes at the end.

The cache also expires, after five minutes by default, so an agent that wakes every half hour misses it on every run. Anthropic's one-hour cache costs twice the normal input price to write, and it comes out ahead once the agent has read it twice. Anthropic's API reports on every call how many input tokens were written to the cache and how many were read from it, and on an always-on agent that split is the first thing I check.

The conversation is the other part of the prompt, and it grows. A long session fills up with old tool output, dead ends and instructions that changed an hour ago, which people call context rot, and through an API every new turn pays to send that whole pile again. The answers get worse as well: in a 2025 study across 18 models, Chroma found that performance consistently drops as the input grows. I split long work by theme into new sessions. Each one opens with a briefing and closes with a write-up of what shipped, and anything the next session needs to remember goes in notes it can look up later.

Tie the spend to work that shipped

A spend dashboard shows what AI costs, and it can't say whether the money was well spent until the spend sits next to the work it produced: pull requests accepted, features released, revenue, users who come back to a feature. Lines of code don't belong on that list. They measure volume, and an agent can turn out volume all night without shipping anything anyone uses. For a support bot, the work is conversations finished without a person, and the cost includes the people behind it. At Tools for Humanity, every conversation the bot didn't finish became a ticket for a person, in-house or at a vendor, so when a vendor pitches a cheaper bot, the first number I'd ask for is how often it hands off.

I have yet to see an organization tie these together properly, and I think it's the key to seeing what the tokens are buying. The spend sits in provider consoles, merged pull requests in GitHub, releases in the tracker, revenue in the billing system and returning users in product analytics, and nobody joins them. Reporting has to change for how work happens now, too, because a report built around people's hours has no row for what an agent shipped overnight. The start is small: tag spend by service and team at the gateway, pick one outcome for each service before it's built, and put the two side by side every month. That monthly readout, along with tuning, QA and vendor reviews, is the job of a Fractional AI Lead for Operations.

Services

Is your company paying for AI that hasn't changed how the work gets done?

Tell me what's stuck. Thirty minutes, no pitch deck.