pi-tokenrouter-provider

Pi extension + token-router fork that adds tokenrouter.com as a model provider for pi

Packages

Package details

extensionskill

Install pi-tokenrouter-provider from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-tokenrouter-provider
Package
pi-tokenrouter-provider
Version
0.1.0
Published
Jul 19, 2026
Downloads
646/mo · 519/wk
Author
rharagon
License
MIT
Types
extension, skill
Size
48 KB
Dependencies
0 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./src/index.ts"
  ],
  "skills": [
    "./skills"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

Pi TokenRouter Provider

A fork of token-router adapted to add tokenrouter.com as a model provider for pi.

It keeps the original lossless local line-routing Python router (scripts/router.py) and adds a TypeScript extension that lets you use tokenrouter.com models directly from pi.

Installation

From npm (appears in the Pi package gallery):

pi install npm:pi-tokenrouter-provider

From GitHub:

pi install git:github.com/rharagon/pi-tokenrouter-provider

Or with a local path for development:

pi -e ./pi-tokenrouter-provider

Authentication

Get an API key from your tokenrouter.com dashboard.

Then set it as an environment variable:

export TOKENROUTER_API_KEY=sk-...

On Windows PowerShell:

$env:TOKENROUTER_API_KEY="sk-..."

Or authenticate interactively in pi:

/login tokenrouter

and paste the API key when prompted.

Usage

Select a model:

/model tokenrouter

or start pi directly with:

pi --provider tokenrouter --model gpt-4o

Model discovery runs at startup and is cached. If the catalog is unreachable, the cached list is used as a fallback.

Refresh the model list:

/tokenrouter-refresh

Original token-router

The router still works as a standalone Python tool. See scripts/router.py and the original docs in docs/token-router/. A Pi skill is also included under skills/token-router/.

License

MIT