$ cat ~/map/pi-custom-model.md
pi-custom-model
A keyless fallback chain for pi: configured tiers answer in order, and the first to stream a token wins.
extensions✓ Nov 2
Facts
- repository
- github.com/ederevx/pi-custom-model ↗
- GitHub Stars
- ★ 0
- Forks
- 0
- license
- MIT
- npm / mo
- —
- last push
- Nov 1, 2026
install
pi install git:github.com/ederevx/pi-custom-model@v0.2.0, then pick custom-model/fallback via /model or set defaultProvider custom-model and defaultModel fallback in settings.json.## TL;DR
A pi extension that registers a custom-model/fallback model routing every request through a chain of up to three tiers — primary, secondary, tertiary — where the first tier to produce a first token within the timeout answers the whole request and a tier that errors or stalls is skipped.
## Key points
- $Registers one wrapper model, custom-model/fallback: each request walks a prefix-ordered chain of up to three tiers, and the first tier that produces a first token within the timeout answers the whole request.
- $Keyless by construction: the wrapper never calls an API itself — every tier streams through its own provider's credentials, so the chain adds no keys of its own.
- $Edited in pi's two-column settings dock via /custom-model-settings: model pickers for primary, secondary, and tertiary plus a first-token timeout in whole seconds (default 10); restore defaults deletes stored settings after a confirmation.
- $Settings live in the piCustomModel section of the agent-directory settings.json — the same convention as piConsult, piTeams, and piDaemon — and are shared by every session; edits write only the key they change through a sibling temp file renamed over the document, and an invalid JSON settings file is reported and never overwritten.
- $The dock picker only offers models whose provider has configured credentials and never offers the wrapper itself; a stored tier whose provider was removed stays configured but is skipped and marked unavailable or no-auth.
- $The catalog entry advertises the smallest context window and max-token limit of the currently resolved tiers, so pi's compaction never plans past what the chain can serve; limits are recomputed at session start and after every dock edit.
- $Failure behaviour is spelled out: no tiers ends the request with a pointer back to /custom-model-settings; every tier stalling ends with a timeout error naming how many tiers were tried; an error before the first token advances the chain, an error after it is forwarded because the answer is already committed.
- $Recorded usage and cost always reflect the tier that actually answered, while the message is attributed to custom-model/fallback; routing re-reads settings per request, so hand-edited chains take effect on the next request.
## FAQ
Q Does the fallback chain need its own API key?
No — the wrapper is a keyless delegating provider that never calls an API itself; each tier streams through its own provider's existing credentials.
Q What happens when every tier fails or stalls?
The request ends with a timeout error naming how many tiers were tried. A tier that errors before its first token advances the chain; an error after the first token is forwarded, because the answer is already committed.
Q Can I edit the chain outside the settings dock?
Yes — the piCustomModel section of settings.json holds the tiers and timeout, and routing re-reads settings on every request, so hand edits take effect on the next request; dock edits write only the key they change.
Q What context window does pi see for the wrapper model?
The smallest context window and max-token limit among the currently resolved tiers (0 for both when nothing is configured), so pi's compaction never plans past what the chain can serve.
Q Which tier shows up in usage and cost records?
The tier that actually answers — usage and cost always reflect it, while the message itself is attributed to custom-model/fallback.
## References
## Related entries
$ big-pi
Model-driven compression that summarizes completed phases into tiered blocks while Pi's JSONL transcript stays authoritative and untouched.
$ inception
A curator LLM replaces pi's compaction, rewriting old history every few turns to keep the context dense.
$ motus
Redacts exact secret values from pi tool output, blocks the commands and files that print them, and fails closed.
## Guides
Last updated: Nov 1, 2026