Routing LLMs for £0
Give every service in the lab a language model to call, at no cost — and be honest about what that costs you instead.
- ai
- automation
- Cost
- £0/month
- Interface
- OpenAI-compatible
- Failure mode
- HTTP 429, by design
- Fallback
- Local model
A dozen services in the lab could each be improved by a language model call: summarising a log, triaging an alert, drafting a digest. None of them are important enough to justify a metered API bill that scales with how much I experiment.
So there is a gateway. Everything in the lab points at one internal endpoint that speaks a standard API, and the gateway decides which free provider actually serves the request.
How it works
The gateway holds a set of provider credentials and an ordered list of models to try. A request comes in, it attempts the first, and on failure falls through to the next. Callers do not know or care which model answered — they see one endpoint and one API shape.
This is genuinely useful. Adding a model to a script is now a URL, not an account signup, and swapping providers is a config change rather than a code change.
The honest part
It runs out. Free tiers have daily quotas. When they are exhausted the gateway has nothing left to try and returns HTTP 429. This is not a bug and it is not a misconfiguration — it is the arrangement working as designed, and any caller that cannot survive it is broken.
That constraint shaped everything downstream. Nothing on a critical path is allowed to depend on this gateway. It summarises the morning brief; it does not decide whether a backup ran. If the summary is missing, the brief still arrives with the raw data in it. The rule I settled on is simple: if a 429 would lose data or hide a failure, the gateway is the wrong tool.
Two traps worth knowing
The first is that a fallback chain is only as good as its assumptions. One model in my chain quietly disappeared from the provider’s catalogue. The gateway dutifully failed over — except that a 404 from that provider put the whole provider connection into a cooldown, which meant the next step in the chain, on the same provider, was skipped entirely. Two consecutive steps on one provider is not a fallback. It is one step with extra logging. The chain now interleaves providers so consecutive entries can never share a failure domain.
The second is that “multiple free providers” often means fewer than it looks. Two of my routers turned out to be authenticating to the same upstream account, so stacking them added no capacity whatsoever — just another hop and another thing to debug.
The local backstop
For anything that genuinely must answer, there is a named route that always goes to the local GPU box. It is slower and the model is smaller, but it has no quota, no upstream and no daily reset. Services that need a guaranteed response ask for that route explicitly.
Was this over-engineered
Slightly, and I have deleted parts of it since. The version that survives is one gateway, one fallback chain that interleaves providers, and one honest error. The elaborate routing rules I built first got removed after they turned out to be a more complicated way of producing the same 429.