Running AI at home burns real money — the API meter never stops, and half my tasks don't need the smartest model. So I had Claude build a two-layer router: one flag picks the cheapest model that's still good enough, then the cheapest host to serve it. Same scripts, same prompts, a fraction of the bill.
Every script I run, every nightly job, every little classify-this or summarise-that call hits an API that charges by the token. It adds up fast — and the dumb part is that most of those calls don't need the smartest model. I was paying premium prices to rename files and tidy captions. The fix isn't writing worse prompts; it's making something else decide, per call, how much brain the job actually deserves.
Claude built or_client.py — a thin wrapper around OpenRouter with two cost levers. Lever one: low_cost=True routes the call to a quality-vetted pool of capable-but-cheap models (Gemma-4-31b, DeepSeek-v4-flash and Nemotron-3-Super all clear the bar), with live prices refreshed every ten minutes. Lever two: inside that pool, provider.sort=price tells OpenRouter to pick the cheapest host serving that model. You win twice — on the model and on the infrastructure under it.
Routing every call to the literal cheapest model on the market would be a disaster — you'd save money and get garbage. The router only works because the cheap pool is curated: a model earns its place by passing a quality bar first, and only the vetted ones are eligible for the price sort. And the hard jobs — the ones that actually need it — still go to the premium model. So the honest claim isn't "AI for free." It's: spend premium money only where premium matters, and let everything else fall to the cheapest option that still passes.
A cheaper model won't return the exact same words as the top-tier one. The promise is that for the tasks I route low-cost — classify, summarise, tidy, extract — the output clears the same bar I'd accept from the expensive model. Anything where the wording really matters, I leave low_cost off and pay full price on purpose. The savings are real; the honest framing is "good enough, far cheaper," not "free and identical."
Four moments from the build: the two-layer selection logic, the live price-vs-latency compare tool, the route diagram, and a before/after cost estimate. Tap any image to enlarge it and read the exact prompt that drew it.




That's the payoff. I don't touch a single prompt or script — I set AIOS_LOWCOST=1 in the environment, and every eligible call quietly reroutes to the cheapest model that still passes, on the cheapest host that serves it. The kicker writes itself: Claude Opus built this router in one session — the AI optimised its own cost footprint, then handed me the bill it had just shrunk.
Sixty seconds: the problem (a bill that never stops), the two levers in or_client.py, the compare tool printing price vs latency live, and the one-flag flip that shrinks the cost without touching a prompt.
The or_client.py OpenRouter wrapper with both cost levers, the llm_route_compare.py price-vs-latency tool, and the vetted-pool config. Everything in this episode is free and open — clone it, set your own key, flip the flag.
gh repo clone jacobskogstrom/or-cost-router ~/or-cost-router && cd ~/or-cost-router && cat README.md
No GitHub? Comment ROUTER on the post and the bot DMs you the link.
A voice conversation tier for my home AI — spec'd and planned end to end with Claude before any code. The episode is the planning, not the typing: how to design a complex AI feature so the build is the easy part.