Files
ai-kit/package.json
T
G 14a41b0c34 feat: modelCost — because the same paid fallback was found in three apps (#3)
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.
2026-08-16 14:57:42 +02:00

62 lines
1.5 KiB
JSON

{
"name": "ai-ration",
"version": "0.2.0",
"description": "Stay on free LLM tiers: a multi-vendor fallback chain, rate-limit classification that tells the three kinds of 429 apart, and fair-share rationing of a shared daily pool across users.",
"license": "MIT",
"author": "Mao Nakamoto",
"homepage": "https://github.com/maonakamoto/ai-ration#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/maonakamoto/ai-ration.git"
},
"bugs": {
"url": "https://github.com/maonakamoto/ai-ration/issues"
},
"keywords": [
"ai",
"llm",
"free-tier",
"rate-limit",
"fallback",
"quota",
"rationing",
"fair-share",
"groq",
"openrouter"
],
"type": "module",
"sideEffects": false,
"engines": {
"node": ">=18"
},
"publishConfig": {
"access": "public",
"provenance": true
},
"files": [
"dist"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"scripts": {
"build": "tsc -p tsconfig.json",
"lint": "eslint .",
"typecheck": "tsc -p tsconfig.json --noEmit",
"test": "node --test test/*.test.js",
"verify": "npm run lint && npm run typecheck && npm run build && npm test",
"prepare": "npm run build"
},
"devDependencies": {
"@eslint/js": "^9.39.5",
"@types/node": "^22.10.2",
"eslint": "^9.39.5",
"globals": "^15.15.0",
"typescript": "^5.8.2",
"typescript-eslint": "^8.67.0"
}
}