I counted my agents. Not the names, the sessions: every Claude Code and Codex run still sitting on my two laptops. 3,119.
Together they read 38 billion tokens and wrote 120 million. My agents spend 99.7% of their lives reading and 0.3% saying anything new.
On a pay-per-token API, that habit is a five-figure invoice. On two flat subscriptions, it's the same bill as any other month. One afternoon I learned the difference the expensive way.
Why are AI agent loops so expensive on API billing?
Because an agent re-reads its entire conversation on every single turn, and you pay for every re-read.
An agent loop is a chat that never ends: read the files, run a command, read the output, run another. Every step ships the whole history back to the model and bills for it. My Claude turns re-read about 275,000 tokens apiece. Most of those turns boil down to "ok, now run the tests."
Prompt caching softens this. Anthropic bills a cache read at a twentieth of normal input on Opus 5.5, and OpenAI advertises cached input "discounted up to 95%". But a discount on a mountain is still a mountain: in my Claude logs, cache reads alone are 60% of the metered price.
Drag the sliders. The defaults are a single, modest lane.
Each turn: the context at the cache-hit rate ($0.20 per million tokens), 3k new tokens written to cache ($5/M) and 700 output tokens ($20/M), Claude Opus 5.5 list prices. A flat subscription has usage limits instead of an invoice.
What does a fleet of AI agents cost on a flat subscription?
The same fixed monthly fee, whether the agents work one hour or all night. You swap an invoice for usage limits, and a fleet is exactly the workload where that swap pays.
Here's my fleet, priced as if metered. The Claude half covers only the five weeks of logs still on disk: 21.6 billion cached tokens, 365 million cache writes, 53 million tokens of output. At Anthropic's published Opus 5.5 rates, that's about $7,200, and that's a floor, since some turns ran on pricier models.
The Codex half re-read 15.7 billion cached tokens. With no verified public price for those models, I used the rate OpenAI actually charged me on my one bad afternoon: 58 cents per million cached tokens. Another $9,000 or so, for cached input alone. Even at Claude's cheaper cache rate it would be about $3,100.
So: somewhere between $10,000 and $16,000 of agent work, on two flat subscriptions.
The catch: limits. A subscription is a weekly allowance, and a fleet can eat it. So a small guard watches the fuel gauge. It polls Claude's weekly usage, reads the percentage Codex logs about itself, and kills only the lanes (one agent each) of whichever engine crosses my cap. Worst case, the agents take a nap.
That's the whole rig behind my overnight agents: fifteen lanes for eleven hours, no meter running.
What happens when an AI agent runs on an API key by mistake?
It bills like a taxi stuck in traffic. Mine ran up $57.95 in about three hours, on a $62.72 day, for work the subscription already covered.
One laptop's Codex had quietly logged in with an API key instead of my subscription. Nothing looks different when that happens. The agents worked; the terminal stayed green.
The bill told the story: 513 calls, 53.7 million cached-input tokens. The biggest line items were two flavours of "cached input". The output line, the actual code, came to $5.95.
It got worse. That key drew on a prepaid balance that also fed a production app, behind an auto-recharge cap. My three hours were the last straw: the cap tripped, the balance hit zero, and the production app's AI calls failed with "credit balance exhausted" for most of a day.
A few days earlier, a different agent had logged Codex into a key on its own rather than ask me. Its report: "Got Codex working without you." Same message: key mode "bills metered tokens rather than using the x5 Max sub you already pay for". It knew. It did it anyway, to save me one question.
My rule since: coding agents run on a subscription, never a key. The guards:
- Strip keys at the launcher. My shell wraps
claudeandcodexso they start with the OpenAI and Anthropic keys removed. A key once exported in a dotfile leaked into every agent started from a terminal; now it can't. - Check the live process, not the config. A config file can say "subscription" while an environment variable says otherwise.
- Prove it afterwards. Codex logs a plan type on every subscription rollout. No plan type, investigate.
- Never pay for idle. Same disease, different meter: one of my agents deployed a voice model with a GPU kept always warm. It burned a $30 cap in about 17 hours, before anyone had tested it.
Is Devin or Replit worth it compared to your own agents?
For me, no, and I've used both properly. To me they feel like products for people who don't want a terminal. I want the terminal. My rig is faster and more honest, and it costs the same every month.
Devin. One client had Devin wired into its pull requests. It wrote "Comprehensive QA Review" comments, always felt laggy to me, and its confidence outran its results. My favourite afternoon, straight from the notification emails:
- 14:52Devin opens a PR for a small filter feature
- 14:56PR closed
- 15:00Opens it again. "Closing - incorrect target branch (staging instead of master)."
- 15:04Again. "Closing - still targeting staging instead of master."
- 15:08Fourth try, closed 13 seconds after opening: "still targeting staging despite explicit master base_branch parameter."
Four pull requests, sixteen minutes, one wrong branch. My agents blunder too, but they ship through one push script and answer to a separate tester, so the blunder dies in a terminal instead of in a stream of notification emails. More on that in why every agent needs a QA department.
Replit. I've used it a lot; it has sent me 116 publish notifications. It's genuinely good at the prototype you later port to a real codebase.
But I've also typed, typo fixed, "Replit cannot seem to set secrets himself". And the billing is the opposite of mine; paid agent work uses "effort-based pricing based on request complexity". One workspace mailed me "has used 100% of Credits" twice.
Metered agents put a meter on your curiosity. Every "try it again" costs money, so you stop asking. On a flat fee, I run three independent QA reviews on one fix, and nobody sends a receipt.
Replit sells an agent that can work for 200 minutes. Mine work twenty minutes or all night, and the fee doesn't move.
Want AI agents that actually ship?
I build AI agents and the systems around them for businesses: memory, voice, overnight rigs, and the boring guards that make them safe to leave alone.
Questions people ask
Does prompt caching make API billing cheap enough for agents?
It helps a lot, but it doesn't fix the shape of the problem. Cached input costs a fraction of normal input, yet an agent re-reads hundreds of thousands of tokens on every turn, dozens of times an hour. In my logs, cache reads alone were about 60% of the metered price. The cache also only works when the start of the prompt matches exactly, so a changed file early in the context breaks it.
How do I check whether Claude Code or Codex is using my subscription or an API key?
Check the running process, not the config file. Look for provider key variables such as OPENAI_API_KEY or ANTHROPIC_API_KEY in the agent's environment, and remove them at launch. For Codex, the session logs record a plan type on each rollout when it runs on a ChatGPT plan; a run on a key has none. Claude Code shows its login method in its status screen.
What are the limits of running AI agents on a subscription?
Usage caps. Subscriptions give you a rolling allowance instead of an invoice, so a busy fleet can run out before the week ends. Watch the weekly usage percentage, set your own stop line below the cap, and split the guard per engine so one running out doesn't stop the other. The worst case is idle agents, not a surprise bill.
Why is output such a small part of an AI agent's token bill?
Because most agent turns are short actions like running a command or reading a file, while the input on every turn is the whole conversation so far. Across my fleet, new output was 0.32% of all tokens. You pay mostly for the model re-reading its own history, which is why long agent sessions get expensive on metered billing.
Read next
AI agentsReplit Bragged About 200 Minutes. My AI Agents Worked All Night15 lanes, 11 hours, 10,785 tool calls and one shell loop that keeps telling them they're not done.Read it 2026
AI agentsMy AI Agents Need a QA Department (Bruno Checked Himself for 36 Hours)746 turns, 178 commits, nothing published. What goes wrong when agents grade their own homework, and the boring department that fixes it.Read it 2026
AI agentsWhat Is Your AI Agent Actually Doing? The Action Log Said Zero18 phone agents, 11 AI staff, 45 duties, one action log. Actions the AI actually executed: zero.Read it 2026