npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pi-provider-fallback

v1.0.4

Published

Cross-provider model fallback for pi, with an interactive TUI config

Readme

pi-provider-fallback

A simple cross-provider model fallback extension for pi, with an interactive TUI config.

When the active model hits a terminal transient, quota, or model-unavailable error, the extension swaps to the next configured fallback model (trying the same provider first, then other providers) and re-issues the failed prompt. If fallback switches to a model with a smaller context window, the extension triggers pi compaction first when the current context would be too large. The swap is sticky for the session; the original model is restored on shutdown or at /reload.

At a glance:

  • This is a pi extension. It adds the /fallback-config and /fallback-status commands.
  • Options draw from your available providers (those in pi --list-models).
  • Providers are enabled for fallback per your preference: opt each one in or out.
  • Up to two models per provider can be set as your 1st and 2nd fallback preference.

Install

# via npm
pi install npm:pi-provider-fallback

# via git
pi install git:github.com/37/pi-provider-fallback

This adds the extension to ~/.pi/agent/settings.json (use -l to write project-local .pi/settings.json instead).

Alternatively you can install from local, or remote using specific versions pinned to a tag or commit:

# specific git version
pi install git:github.com/37/[email protected]

# Local / dev
pi -e ./provider-fallback.ts   # run once from a clone, no settings change

Usage

Configure interactively in pi:

/fallback-config      # interactive TUI to set fallback models per provider
/fallback-status      # view current config

Configuration / setup with TUI

No JSON editing required. The TUI only shows providers and models present in your registry (pi --list-models).

fallback-config provider list

A marks a provider enabled for fallback, disabled. Press Enter on a provider to pick up to two fallback models and assign them priority 1 / 2.

Note: /fallback-config automatically saves changes on every action. No ctrl+s required.

How fallback works

On an eligible error for providerA/modelX:

  1. Try providerA's other configured fallbacks (priority 1, then 2).
  2. If exhausted, try other enabled providers' fallbacks.
  3. If nothing is available: [fallback] no fallback available.

The pointer is forward-only per session (never retries an already-failed fallback). If the target fallback has a smaller context window and the current context is too large, compaction runs before the retry.

fallback process in action

The screenshot shows a rate-limit error falling back first within Anthropic, then across providers after the second rate-limit. Request IDs are redacted.

Error classification

| Bucket | Triggers fallback | Examples | |--------|-------------------|----------| | transient | yes | overloaded, rate-limit, 429/5xx, network/timeout | | quota | yes | usage limit, billing, insufficient quota | | unavailable | yes | 404 not_found, "model is not available", invalid model | | ignore | no | context overflow, user abort |

Config

Stored at ~/.pi/agent/extensions/provider-fallback.json (override with PI_PROVIDER_FALLBACK_CONFIG). Managed by the TUI; see provider-fallback.example.json for the shape.

Testing fallback

Set your default model to anthropic/claude-fable-5 and send a prompt. As of 2026-06-21 this is a convenient deterministic test: Anthropic has disabled the model, so it always 404s and reliably triggers fallback. This may change in future; if the model is re-enabled or removed, pick any other unavailable model id.

You should see:

[fallback] anthropic/claude-fable-5 failed (unavailable) → anthropic/claude-opus-4-8

Note: the → anthropic/claude-opus-4-8 target appears only if claude-opus-4-8 is configured as an anthropic fallback model. With a different anthropic fallback (or none, falling through to another provider) the target reflects whatever you configured.

Self-check the classifier: npx tsx provider-fallback.ts --selfcheck

License

MIT