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

pi-models-provider

v0.1.0

Published

Pi extension for discovering models.dev-compatible provider models

Readme

pi-models-provider

Pi extension that discovers models from provider endpoints returning a models.dev-compatible { "models": {} } response.

Features

  • Registers multiple dynamic pi providers from one configuration file
  • Queries /v1/models with User-Agent: pi/models-fetch/<version>
  • Supports discovery request headers and same-origin Bearer authentication
  • Projects models.dev metadata into pi model configuration
  • Supports ordered include rules, per-rule API overrides, and exclusion rules
  • Uses pi's provider-scoped model store for offline and failed-refresh fallback

Installation

Requires pi 1.0 or newer.

Install the package as a global pi package:

pi install npm:pi-models-provider

For local development:

npm install
pi -e ./src/index.ts

Configuration

Create ~/.pi/agent/extensions/models-fetch.json for global configuration or .pi/models-fetch.json for project overrides:

{
  "providers": {
    "gateway": {
      "name": "AI Gateway",
      "baseUrl": "https://gateway.example.com/v1",
      "apiKey": "$GATEWAY_API_KEY",
      "api": "openai-completions",
      "discoveryHeaders": {
        "X-Tenant": "tenant-name"
      },
      "include": [
        {
          "match": "^claude",
          "api": "anthropic-messages"
        },
        {
          "match": "^(gpt|o[134])",
          "api": "openai-responses"
        }
      ],
      "exclude": ["embedding", "deprecated"]
    }
  }
}

Project providers override global providers with the same ID. Set PI_MODELS_FETCH_CONFIG to use one explicit configuration path instead. The global path follows pi's configured agent directory, including PI_CODING_AGENT_DIR; project paths follow pi's configured project directory name.

Provider options

| Option | Default | Description | | ------------------ | -------------------- | ----------------------------------------------------- | | name | provider ID | Display name | | baseUrl | required | Provider API base URL | | apiKey | none | Literal key or $ENV_VAR/${ENV_VAR} | | api | openai-completions | Default pi API | | headers | {} | Headers used for model inference requests | | authHeader | true | Add Bearer authentication to inference requests | | endpoint | /v1/models | Relative or absolute discovery endpoint | | discoveryHeaders | {} | Headers used only for discovery | | include | [] | Model-key allow-list; object rules may override api | | exclude | [] | Model-key regular expressions; exclusion wins | | timeoutMs | 10000 | Discovery timeout | | cache | true | Persist the last successful catalog through pi | | cacheTtlSeconds | 86400 | Fresh-cache lifetime before startup refresh |

An absolute cross-origin discovery endpoint never receives apiKey automatically. Set an explicit Authorization value in discoveryHeaders when required. Set discoveryHeaders.User-Agent to override the default pi/models-fetch/<version> user agent.

Refresh command

Force refresh every configured provider:

/models-fetch:refresh

Force refresh one provider:

/models-fetch:refresh hfai

The model cache is stored by pi in getAgentDir()/models-store.json (normally ~/.pi/agent/models-store.json). A fresh cache is reused during pi-managed refreshes; stale cache remains available when refresh fails.

Response format

{
  "models": {
    "claude-sonnet": {
      "id": "claude-sonnet",
      "name": "Claude Sonnet",
      "reasoning": true,
      "reasoning_options": [{ "type": "effort", "values": ["none", "low", "medium", "high"] }],
      "limit": {
        "context": 200000,
        "output": 64000
      },
      "modalities": {
        "input": ["text", "image"]
      },
      "cost": {
        "input": 3,
        "output": 15,
        "cache_read": 0.3,
        "cache_write": 3.75
      },
      "provider": {
        "api": "anthropic-messages"
      }
    }
  }
}

Models.dev reasoning_options entries with type: "effort" are projected to pi's model-level thinkingLevelMap. Unsupported or unlisted levels are hidden; none maps to pi's off level. Toggle-only and token-budget controls remain adapter-specific.

Each key in the discovered models object is used as both the pi model ID sent to the provider and its display name. Nested id and name fields do not override the key.

Missing metadata uses pi defaults: text input, a 128K context window, 16K maximum output, and zero cost.