bitbaum
Start a project
Package · MIT

ai-kit

Which model to call, whether the vendor still serves it, and what to do when every one of them fails.

Why it exists

Fourteen apps needed a model. The first copy picked one vendor and broke when that vendor had a bad day. The second copy would have done it again. ai-kit is the last copy: one chain, one way to tell a rate limit from an outage, one shared daily pool.

How it works

You name the job, not the vendor. The kit walks a fallback chain, classifies a 429 into the three kinds that are not the same failure, and rations a shared daily allowance so one app cannot empty the free tiers for the others. When every vendor fails, it says so instead of inventing an answer.

Where it fits

The Cat, the intake forms, the research tools and the agents in Loki all think through this. A product that calls a model and does not use it is writing the second copy.

LicenceMIT
Installpnpm add @bitbaum/ai-kit
Sourcebitbaum/ai-kit
Used by14 apps