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-weighted-model-router

v0.4.2

Published

Pi extension that balances model/provider usage across weighted model pools.

Downloads

646

Readme

pi-weighted-model-router

CI Publish npm version npm downloads License: MIT Pi Package Trusted Publishing

Pi extension that selects a model from weighted pools at session start, then keeps the session on that model unless a provider error or input capability requires fallback.

What this is

pi-weighted-model-router balances model and provider usage across weighted pools in Pi. It picks one entry when a session starts, restores that choice on resume when configured, and falls back to another pool candidate on provider errors or unsupported image input.

Features

  • Daily balanced weighted selection so weights such as 7 / 2 / 1 stay close to the configured ratio across sessions in the same day.
  • Session boundary policy: restore on startup and resume, reselect on new, reload, and fork by default.
  • Runtime fallback on provider failure statuses such as 400, 429, 500, 502, 503, and 504.
  • Image capability fallback before prompts when the selected model does not support image input.
  • Tool model_router_config for agent-guided config updates after confirmation.
  • Colon flat commands: /model-router:status, /model-router:next, and /model-router:configure.

Install

From npm:

pi install npm:pi-weighted-model-router

Project-local install:

pi install -l npm:pi-weighted-model-router

Pin a specific version:

pi install npm:[email protected]

From a local checkout:

pi install /absolute/path/to/pi-weighted-model-router

For temporary testing:

pi -e npm:pi-weighted-model-router
pi -e /absolute/path/to/pi-weighted-model-router

Quick start

  1. Install the package with one of the commands above.
  2. Start Pi and run /model-router:configure for guided weight setup, or edit config directly (see docs/usage.md).
  3. Check status with /model-router:status.

Config paths:

  • Project-local (.pi/settings.json): .pi/weighted-model-router/config.json
  • Global install: ~/.pi/agent/weighted-model-router/config.json

For local development in this repository, .pi/settings.json loads the package from ../. Start pi from the repo root and run /reload if a session is already open.

Usage summary

| Command | Purpose | | --- | --- | | /model-router:configure | Guided setup through the agent and model_router_config | | /model-router:status | Current pool, model, today's success counts, and config path | | /model-router:next | Reselect within the same session without reload |

Legacy /model-router with a selection menu and /model-router next remain available for one release; prefer the colon commands above.

Configuration, session boundary tables, manual model overrides, and privacy notes are in docs/usage.md. Concurrency assumptions and mitigations are in docs/RACE_CONDITIONS.md.

Package contents

| Path | Purpose | | --- | --- | | src/ | Extension entrypoint and routing logic | | docs/ | Usage, release, and concurrency decision docs | | README.md | Public entrypoint (this file) | | SECURITY.md | Vulnerability reporting | | LICENSE | MIT license | | CHANGELOG.md | Version history |

Development

npm install
npm run check

The core selection, ledger, and config logic is testable without starting Pi.

Release

This package uses npm Trusted Publishing with GitHub Actions OIDC — no NPM_TOKEN is required.

npm version patch
git push

On main, .github/workflows/auto-release.yml creates the v<version> tag and GitHub Release, then dispatches .github/workflows/publish.yml to publish to npm.

See docs/release.md for setup details.

Security

Pi packages can execute code with your local permissions. Review extensions before installing third-party packages.

For vulnerability reporting, see SECURITY.md.

Links

  • npm: https://www.npmjs.com/package/pi-weighted-model-router
  • GitHub: https://github.com/eiei114/pi-weighted-model-router
  • Issues: https://github.com/eiei114/pi-weighted-model-router/issues

License

MIT