@xamfoo/pi-openrouter-pin

Pi extension to pin an OpenRouter model to a provider.

Packages

Package details

extension

Install @xamfoo/pi-openrouter-pin from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@xamfoo/pi-openrouter-pin
Package
@xamfoo/pi-openrouter-pin
Version
0.1.5
Published
Aug 16, 2026
Downloads
4,266/mo · 98/wk
Author
xamfoo
License
MIT
Types
extension
Size
108.5 KB
Dependencies
0 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./src/index.ts"
  ]
}

Security note

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

README

pi-openrouter-pin

Pin an OpenRouter model to a specific host provider as a dedicated, persistent pi provider. No in-memory state, no proxy daemons, no backend quantization roulette.

This extension is written with the help of AI coding assistants and reviewed by humans.

Install

pi install npm:@xamfoo/pi-openrouter-pin

Usage

Every command accepts --help (or -h) to print its usage. Use Esc to stop tab completion:

/openrouter-pin --help
/openrouter-unpin --help
/openrouter-pins --help

/openrouter-pin

Run without arguments to launch the interactive wizard:

/openrouter-pin

Expect a tabbed flow with instant fuzzy-matching against OpenRouter's full local catalog (Model › Provider › Quant › Name › Routing › Default). Tab/Enter advances, Shift+Tab steps back, Esc cancels.

Alternatively, pin directly from the command line:

# Lock to a specific provider and quantization (e.g. avoid 4-bit degradation)
/openrouter-pin deepseek/deepseek-v4-flash-0731 baseten --quant fp8

# Exclude specific unreliable providers
/openrouter-pin z-ai/glm-5.2 z-ai --ignore deepinfra,venice

# Set provider preference order
/openrouter-pin openai/gpt-oss-120b groq --order baseten,together

# Enforce zero data retention / strict privacy policy
/openrouter-pin minimax/minimax-m3 minimax --data-collection deny

# Pin and make it the default model in pi
/openrouter-pin qwen/qwen3.8-max alibaba --default

Routing Policy

By default, pins are strict: requests go only to the specified provider under openrouter-<provider>.

When you relax constraints with --fallback, --order, or --ignore, the provider is registered with a -plus suffix (e.g., openrouter-groq-plus) so the name reflects that fallbacks are allowed. (Naming conventions for relaxed routing are experimental and subject to change.)

/openrouter-pins

List active pins, their endpoints, and configured routing policies.

/openrouter-pins

/openrouter-unpin

Remove a pinned model and its provider configuration.

/openrouter-unpin <model-id>

How It Works

  • Per-Endpoint Pricing Truth: OpenRouter's catalog pricing is an aggregate that often reflects the lowest-cost provider rather than the one you call. pi-openrouter-pin extracts and records the actual endpoint pricing for your pinned provider in ~/.pi/agent/models.json.
  • Startup Drift Sync: On pi launch, pinned models refresh their pricing and context limits against OpenRouter's catalog, updating fields atomically if upstream parameters change.
  • Pi-Native Persistence: Modifies standard models.json and settings.json with atomic writes, preserving formatting and comments.

Development

npm install
npm run typecheck
npm test        # runs pure builders, arg parser, and TUI wizard harness