mirror of
https://github.com/bitbaum/ai-kit.git
synced 2026-12-04 05:07:59 +01:00
One mistake, three codebases, one day. Each was a FALLBACK that began spending
the moment the free tier ran dry — the path nobody watches, because it only runs
when something else has already broken:
botsmann OPENROUTER_DEFAULT_MODEL = anthropic/claude-sonnet-5 (premium)
kivvi chain ended at Anthropic; OpenRouter default was
google/gemini-2.0-flash-001, the paid twin of a :free id
evig meta-llama/llama-3.3-70b-instruct — reads free, bills at 1e-7/token,
and its :free sibling has been retired from the catalogue
A fallback is a reliability mechanism; paying is a business decision. Wiring the
second to the first lets an outage make the decision, at the worst moment,
without anyone choosing it.
The rule is deliberately narrow and says so. A ROUTED id (vendor/model) is free
only with the :free suffix and paid without it — that suffix is the entire
difference between free routing and a per-call charge for identical weights. A
bare id (llama-3.1-8b-instant) returns "unknown": whether it costs depends on
the account tier at that vendor, which no string can answer. Guessing "free"
there is the direction that let all three through review, so it is not the
default.
paidModelsIn() applies it to a whole chain, returning offenders rather than
throwing — the caller knows whether a paid link is a bug or a deliberate,
opted-in upgrade, and a library that throws on the second case gets routed
around.
35 tests green, including the case that keeps this package honest: its own
shipped free chain must contain no paid model.