@suaiva/pi-model-router

Declarative modular model router, multi-account rotation, dynamic compute escalation & WAF bypass for Pi & OMP

Packages

Package details

skill

Install @suaiva/pi-model-router from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@suaiva/pi-model-router
Package
@suaiva/pi-model-router
Version
1.0.0
Published
Aug 25, 2026
Downloads
115/mo · 115/wk
Author
suaiva
License
MIT
Types
skill
Size
38 KB
Dependencies
0 dependencies · 1 peer
Pi manifest JSON
{
  "skills": [
    "./skills/model-router"
  ]
}

Security note

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

README

Pi Model Router (@suaiva/pi-model-router)

Declarative modular model router, multi-account rotation pools, dynamic compute escalation & WAF fingerprint spoofing for Pi and Oh My Pi.

Architecture

Instead of maintaining a fragile 300+ line monolithic configuration, Model Router decouples routing into 3 distinct declarative modules:

catalog/
  ├── settings.yml    # Compaction (70% shake), advisor cadences, UI themes
  ├── routing.yml     # modelRoles, tiers, pools, auto-upgrade & fallback chains
  └── providers.yml   # Endpoints, keys, multi-account rotation & WAF headers
┌─────────────────────────────────────────────────────────────────────────────┐
│                       Pi Dynamic Escalation & Routing                       │
├─────────────────────────────────────────────────────────────────────────────┤
│ 1. Default Primary: Gemini 3.7 Flash / Claude Sonnet 4.6                    │
│    │ (on refusal, complex failure or rate-limit)                            │
│    ▼                                                                        │
│ 2. Dynamic Auto-Upgrade: OpenAI Codex GPT-5.6 Luna:high (Deep Reasoning)    │
│    │ (on subscription / token exhaustion)                                  │
│    ▼                                                                        │
│ 3. Fresh Free Pool: Stealth Ox-Alpha (1M Free) / OpenCode Zen X-Preview     │
│    │ (on daily free-tier rate limits)                                       │
│    ▼                                                                        │
│ 4. Multi-Account Failover: Gateway Pool (Keys 1/2 with WAF Bypass)         │
└─────────────────────────────────────────────────────────────────────────────┘

Features

  • Modular 3-File Catalog: Separate concerns between system settings, routing topologies, and provider credentials.
  • Dynamic Compute Escalation: Automatically promotes tough coding turns to gpt-5.6-luna:high before dropping to free models.
  • Multi-Account Rotation: Rotates across multiple API keys per provider (@account.openrouter.1/2, @account.custom-gateway.1/2) on 429 quota exhaustion.
  • WAF Client Spoofing: Injects custom client headers (User-Agent, x-client-name) to satisfy upstream gateway requirements.
  • Free Model Prioritization: Automatically prioritizes high-context, high-TTFT free models (stealth/ox-alpha 1M and opencode-zen/x-preview-f-free 1M).

Installation

# Install package into Pi
pi install git:github.com/suainam/pi-model-router
# Or from local clone:
pi install ./pi-model-router

Python Dependency

pip install -r requirements.txt   # PyYAML

Quick Start

1. Compile Catalog Projections

python3 scripts/render_config.py \
  --source templates/catalog \
  --config ~/.pi/agent/config.yml \
  --models ~/.pi/agent/models.yml

2. Probe and Benchmark Free Models

# Discover free models and run 3-run serial latency benchmark
python3 scripts/probe_free_models.py --runs 3

License

MIT © suainam