Don't hardcode LLM prices: a nightly price-check job for your agent budget A developer published a small Python job that keeps LLM pricing in a local prices.json file and checks it nightly against official vendor pricing pages, flagging any drift to a human rather than auto-updating. The script fetches each model's pricing page, searches for the stored input and output numbers, and on a mismatch writes a DRIFT.txt file and exits non-zero so cron can email an alert. The write-up recommends trusting only official pages, storing a verified date per model, and budgeting with the higher of old and new prices. 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. 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 | python 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 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 https://go.nowto.link/hostinger?s=devto if you want somewhere to put it. | 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 | 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 https://tokenlean.wordpress.com/2026-11-28/llm-price-check-job/ . 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.