Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pi-tokenrouter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
pi-tokenrouter
A pi provider extension for TokenRouter.
Dynamically discovers available models from the TokenRouter API and enriches them with pricing, context window, and max output token data from OpenRouter (TokenRouter shares the same pricing).
Install
pi install npm:pi-tokenrouterOr run directly:
pi -e /path/to/pi-tokenrouterAuthentication
Resolve via /login, environment variable, or auth.json:
# Option 1: Interactive login
/login tokenrouter
# Option 2: Environment variable
export TOKENROUTER_API_KEY=sk-...
# Option 3: auth.json (~/.pi/agent/auth.json)
# "tokenrouter": { "type": "api_key", "key": "sk-..." }How it works
- On startup, fetches the model list from TokenRouter's
/v1/modelsendpoint. - In parallel, fetches pricing data from OpenRouter's public model catalog.
- Matches models by ID and fills in cost, context window, and max output tokens.
- Caches everything locally for 1 week (
~/.pi/agent/cache/tokenrouter-models.json).
Models that don't match an OpenRouter entry fall back to zero cost and default context limits.
License
MIT