Most agent cost dashboards I see have a dict like PRICES = {"model-x": 3.00} pasted in months ago. Prices have moved a lot this month (cache cuts, search fees dropped, a scheduled doubling), and third-party trackers even disagree with each other on same-day swings. A stale constant silently wrecks your budget math.
The fix in one idea
Keep prices in a JSON file, and have a nightly job compare it against the official pricing pages. The job never edits prices itself: it only flags drift so a human confirms against the vendor page.
| Piece | What it does |
|---|---|
| prices.json | Your single source of truth, with a verified date per model |
| check.py | Fetches your vendor pricing pages and looks for the listed numbers |
| cron | Runs nightly, writes an alert file or pings you |
Copy-paste checker
import json, sys, urllib.request, datetime PRICES = json.load(open("prices.json")) # each entry: {"url": "...pricing page...", "input": 3.00, "output": 15.00, "verified": "2026-11-28"} def page(url): req = urllib.request.Request(url, headers={"User-Agent": "price-check/1.0"}) return urllib.request.urlopen(req, timeout=20).read().decode("utf-8", "ignore") drift = [] for model, p in PRICES.items(): try: text = page(p["url"]) except Exception as e: drift.append(f"{model}: fetch failed ({e})"); continue for key in ("input", "output"): if f"{p[key]:.2f}" not in text and str(p[key]) not in text: drift.append(f"{model}: {key} price {p[key]} not found on page") if drift: open("DRIFT.txt", "w").write(datetime.date.today().isoformat() + "\n" + "\n".join(drift)) sys.exit(1) Cron line: 15 6 * * * cd /opt/pricecheck && python3 check.py || mail -s "LLM price drift" you@example.com < DRIFT.txt
Why a small VPS
This is a tiny always-on job, and your laptop sleeps. A cheap VPS runs it, keeps the history, and can also host the model router that reads the same prices.json. Get a Hostinger VPS here if you want somewhere to put it.
Rules that keep it honest
| Rule | Reason |
|---|---|
| Only trust official pricing pages | Aggregators hold back or conflict on single-day moves |
| Alert, never auto-update | A page layout change can look like a price change |
| Store a verified date | You can see how stale a number is |
| Budget with the higher of old and new | Scheduled increases hit mid-month |
Next step
Seed prices.json with the three models you actually call, run the script by hand once, then schedule it. Read the full write-up on the TokenLean hub.
Disclosure: some links in this article are affiliate links. If you buy through them, TokenLean may earn a commission at no extra cost to you.
