Last month my OpenAI bill didn't match my own logs. Cached tokens were being
billed at the full uncached rate. 6.9% over a month. The observability tools I
pay for showed me what I spent, but not what I was overcharged.
So I built SpendGuard, a local-first CLI for LLM cost. It runs entirely on your
machine.
What it does:
- generates independent receipts (versioned pricing, cache hit/miss dual pricing) and checks them against your provider invoice
- runs as a local proxy with a hard budget cutoff (returns 429 instead of letting the bill climb)
- suggests cheaper models and more caching, which cut my test case about 79%
Why local-first: your API keys and call data never leave your machine. You can
read the code, and the code checks your bill. No accounts, no telemetry.
Try it:
pip install spendguard
spendguard audit your-bill.csv
Plain Python, no dependencies (tiktoken is optional). MIT, 13 unit tests, CI on
GitHub Actions.
Repo: https://github.com/caresotin/spendguard
I'm sure there are edge cases I've missed (retries, streaming, batch calls). If
you use the OpenAI or Anthropic API, I'd like to know what breaks.
opensource, ai, python, productivity
Top comments (0)