I Built a Cost Meter for AI Agents Because Nobody's Watching the Bill
AI agents use five different API providers in a single session. Each one bills differently. Nobody gives you the full picture. So I built CostMeter.
Last Saturday at 2am, I told my AI agent to integrate Google Maps into a project. It said “sure” and started coding. Twenty minutes later, the feature worked beautifully. Geocoding, route calculations, distance matrices, the whole thing.
The next morning I checked the Google Cloud console. $87 in Maps API calls. In twenty minutes.
The agent didn’t ask if I wanted to spend $87. It didn’t warn me. It just made hundreds of API calls because that’s what the implementation needed, and I’d said “yes” to the approach without thinking about what “yes” actually meant in dollar terms.
This wasn’t even the worst part.
The real problem is five dashboards
I run an AI setup with five different providers. Anthropic for reasoning (Claude does the heavy thinking). OpenAI for Whisper (audio transcription). Gemini for image generation. Perplexity for web search. Google Maps for anything location-related.
Each one is billed differently. Anthropic charges per token. OpenAI charges per token but with different pricing per model. Google charges per API call. Perplexity has its own system. Five providers, five billing dashboards, five different ways to tell you how much you owe.
And here’s the thing: agents don’t care about any of this.
When my agent orchestrates a complex task, it might call Claude for reasoning, Whisper to transcribe an audio file, Perplexity to research something, and Google Maps to geocode an address. All in one flow. The agent is great at orchestrating. It’s terrible at accounting.
Nobody gives you a unified view of what that session actually cost. You find out at the end of the month when the bills arrive.
What an agent doesn’t know can cost you
Coding sessions are where this gets expensive fast. Your agent suggests an approach that involves calling an external API. You’re focused on the feature, not the pricing page. You say “sounds good, go ahead.”
That’s consent without information. You agreed to the implementation, not to the bill.
Google Maps is a classic example. A geocoding call costs $5 per 1,000 requests. Seems cheap until your agent decides to geocode every address in a dataset during development. Or calls the Distance Matrix API with a 20x20 origin-destination grid, which is 400 API calls per request.
The agent doesn’t know this costs money. It doesn’t even know that “costs money” is a concept it should consider. It’s optimizing for correctness, not for your wallet.
So I built CostMeter
CostMeter is a proxy. It sits between your AI agent and every API provider. Every request passes through it. It logs the tokens, calculates the cost, enforces budgets, and captures rate limits. All providers, all in one place.
The install is one command:
curl -fsSL https://costmeter.io/install.sh | sh
It auto-detects what you’re running. If you use OpenClaw, it imports your API keys and patches the config. If you use Claude Code, it detects your credentials and patches settings.json. Either way, it installs as a system service and starts proxying immediately.
No manual config. No YAML files to edit. No environment variables to set.
What you actually see
After a coding session, you can check what you spent:
$ costmeter spend --by provider
PROVIDER COST REQUESTS
anthropic (sub) 47
openai $2.34 142
google $0.85 170
TOTAL $3.19 + subscription
That (sub) next to Anthropic means I’m on a Claude subscription, so CostMeter tracks my token usage and rate limits instead of dollars. For API-billed providers, it shows exact costs.
You can also check your rate limits in real time:
$ costmeter limits
anthropic (claude-sonnet-4)
Requests: 950 / 1000 remaining (95%)
Tokens: 480K / 500K remaining (96%)
And set budgets that actually block requests when exceeded. Your agent gets stopped before you get a $200 surprise. Not after.
The boring parts that matter
CostMeter runs on your machine. API keys and prompts never leave your system. It stores metadata only: provider, model, token counts, cost, latency. The database is a SQLite file in your home directory.
It handles SSE streaming properly (Anthropic and OpenAI both use server-sent events for responses). Requests pass through chunk-by-chunk with zero buffering. The proxy adds maybe 1ms of latency.
It works with subscription plans. If you’re on Claude Pro or Max, your OAuth token passes through untouched. CostMeter tracks tokens and rate limits instead of dollars, because you’ve already paid.
It auto-updates weekly. It runs as a systemd or launchd service. It survives reboots and crashes. The kind of boring infrastructure stuff that means you install it once and forget about it.
Why this needs to exist
AI agents are getting better at doing things. They’re not getting better at knowing what things cost. As agents get more autonomous (running on schedules, chaining tools, calling external APIs), the cost visibility problem gets worse, not better.
Right now, most people find out what their agent spent after the fact. They check five different dashboards, piece together the timeline, and realize that coding session last Tuesday burned through their monthly Anthropic budget.
CostMeter is the thing that should be running in the background every time an agent makes an API call. One proxy. One view. One budget. All providers.
It’s free. No account needed. I’d love feedback from anyone running AI agents.