@lilco/pi-cheaperinference
v0.1.0
Published
CheaperInference provider for pi: live model catalog with native pricing and graceful fallbacks
Readme
pi-cheaperinference
A pi package that registers CheaperInference as a first-class provider: model selection from the live catalog with native pricing, so pi's usage/cost reporting is correct out of the box — no manual provider or cost configuration.
Install
pi install npm:@lilco/pi-cheaperinferenceSetup
export CHEAPERINFERENCE_API_KEY=ci-...Get a key at cheaperinference.com (referral link — it supports this plugin at no cost to you).
Then pick a cheaperinference/* model in pi (/model or pi --model cheaperinference/gpt-5.6-luna).
What it does
- Fetches the authenticated catalog (
GET /v1/models) at startup and registers every priced model with its current input/output/cache rates (USD per million tokens, tiered rates where applicable). - Pricing is never hardcoded — rates come from the catalog and are cached with a 15-minute TTL.
- Cost reporting uses catalog rates, which are the same rates the provider bills at.
Graceful fallbacks
The plugin never breaks a run or pi startup:
| Situation | Behavior |
|---|---|
| CHEAPERINFERENCE_API_KEY unset | Provider not registered; warning printed with signup link |
| Catalog fetch fails / invalid | Provider not registered (or stale cache reused mid-session); warning printed |
| Unknown model requested | No pricing invented; run proceeds |
Optional overrides: CHEAPERINFERENCE_BASE_URL (default https://api.cheaperinference.com).
Not yet
- Settled-cost precedence: CheaperInference returns the exact billed amount in response usage metadata; overriding pi's local estimate with it needs a custom streaming shim and is deferred (catalog rates are the same numbers the provider bills at).
- Reasoning/thinking metadata: models register with
reasoning: false; override per-model inmodels.jsonif a catalog model supports thinking.
Tests
node --test test/Covers catalog parsing (all documented envelope shapes), alias/normalized model matching, pricing fallback, TTL caching, and registration behavior on missing credentials and fetch failure.
