JSPM

pi-tokenrouter

1.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q73943F
  • License MIT

TokenRouter provider extension for pi — dynamic model discovery with OpenRouter-compatible pricing

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-tokenrouter

    Or run directly:

    pi -e /path/to/pi-tokenrouter

    Authentication

    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

    1. On startup, fetches the model list from TokenRouter's /v1/models endpoint.
    2. In parallel, fetches pricing data from OpenRouter's public model catalog.
    3. Matches models by ID and fills in cost, context window, and max output tokens.
    4. 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