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

@realvendex/pi-token-router

v0.2.0

Published

TokenRouter.com unified API gateway as a native Pi provider for accessing 300+ LLM models via a single API key

Downloads

3,420

Readme

pi-token-router

Native Pi provider for TokenRouter.com — a unified API gateway exposing 300+ LLM models through a single OpenAI-compatible endpoint.

Just switch your base URL.

  • Provider name: tokenrouter
  • Base URL: https://api.tokenrouter.com/v1
  • API: tokenrouter-api (custom streamSimple)
  • Auth: API key via TOKENROUTER_API_KEY env var or ~/.pi/agent/auth.json

Features

  • Custom streamSimple — full SSE streaming with reasoning_split support
  • Dynamic model list — fetched from GET /v1/models at startup
  • Curated fallback — fallback model map when live fetch is unavailable
  • Reasoning support — MiniMax thinking object and DeepSeek reasoning_content
  • Tool calling — full OpenAI-compatible tool call streaming
  • Context overflow recovery — auto-compaction on context-length errors
  • All 9 documented model fields — id, name, reasoning, input, cost, contextWindow, maxTokens
  • Logging — Structured logger with configurable verbosity

Install

pi install npm:@realvendex/pi-token-router

Or register as a local path in ~/.pi/agent/settings.json:

"packages": [
  "..\\..\\nexus\\pi-token-router"
]

Configure

Option 1: Environment variable (recommended)

# Linux/Mac
export TOKENROUTER_API_KEY="sk-..."

# Windows PowerShell
$env:TOKENROUTER_API_KEY="sk-..."

# Windows CMD
set TOKENROUTER_API_KEY=sk-...

Option 2: auth.json (or /login tokenrouter)

{
  "tokenrouter": {
    "type": "api_key",
    "key": "sk-..."
  }
}

Default model

Set your default provider and model in ~/.pi/agent/settings.json:

{
  "defaultProvider": "tokenrouter",
  "defaultModel": "openai/gpt-5.4-mini"
}

Popular model IDs:

  • MiniMax-M3 (free, 1M context, reasoning)
  • openai/gpt-5.5-pro
  • openai/gpt-5.4-mini
  • anthropic/claude-opus-4.8
  • google/gemini-3.5-flash
  • deepseek/deepseek-v4-pro
  • qwen/qwen3.7-plus
  • x-ai/grok-4.3

Commands

set-log-level

Configure the logger verbosity. Supports: debug, info, warn, error.

> set-log-level debug

Architecture

The extension strictly follows the pi custom provider docs:

  • Register New Provider pattern with an async factory for dynamic model discovery
  • api: "openai-completions" — uses pi's built-in OpenAI-compatible streaming (no custom streamSimple needed for an OpenAI-compatible provider)
  • apiKey: "$TOKENROUTER_API_KEY" — env var interpolation as documented
  • Context Overflow Errorspi.on("message_end", ...) normalizes TokenRouter overflow errors to context_length_exceeded for auto-compaction

Stability & Verification

This package has undergone a comprehensive quality audit:

  • Build Pipeline: TypeScript compilation with strict mode.
  • Logger Utility: Structured logging with debug/info/warn/error levels.
  • Error Handling: All catch blocks produce meaningful log output.
  • Type Safety: Explicit type annotations on event handlers and callbacks.

License

MIT © ZachDreamZ