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-openai-api-models-sync

v0.3.1

Published

Pi extension that syncs models from an OpenAI-compatible API and enriches them with pricing and capability metadata.

Readme

pi-openai-api-models-sync

English | 简体中文

A Pi extension package that syncs models from an OpenAI-compatible /models endpoint and enriches them with pricing and capability metadata.

How it works

At Pi startup, the extension:

  1. Finds all openai-responses and openai-completions providers in ~/.pi/agent/models.json.
  2. Requests <baseUrl>/models with each provider's configured authentication.
  3. Fetches model pricing and capability metadata.
  4. Intersects the available model IDs with the metadata.
  5. Registers the resulting models through pi.registerProvider().

The OpenAI-compatible API is the source of truth for model availability. The metadata source supplies context windows, output limits, input modalities, token pricing, long-context pricing tiers, and supported reasoning levels.

If model discovery fails, the extension leaves the static provider configuration untouched. If only metadata discovery fails, models are registered with configured defaults.

Acknowledgements

Special thanks to Wei-Shaw/sub2api for providing and maintaining the model metadata used by this extension. By default, the extension reads Wei-Shaw/model-price-repo, the metadata source configured by Sub2API.

This project is independent and is not affiliated with or endorsed by Sub2API.

Install

pi install npm:pi-openai-api-models-sync

No extension configuration is required. The extension automatically discovers every OpenAI-compatible provider in ~/.pi/agent/models.json. A provider must already exist there:

{
  "providers": {
    "openai-api": {
      "baseUrl": "https://api.example.com/v1",
      "api": "openai-responses",
      "apiKey": "$OPENAI_API_KEY",
      "authHeader": true,
      "models": [
        { "id": "placeholder" }
      ]
    }
  }
}

The static models entry is only a bootstrap and fallback. After a successful sync, the extension replaces it for the active Pi process.

Run /reload in Pi or restart it, then inspect the result:

pi --list-models

Configuration

Configuration is optional. The built-in defaults are exactly those shown in config.example.json. Create ~/.pi/agent/pi-openai-api-models-sync.json only when you need to override them.

Set providerId to sync only one provider; omit it to auto-discover and sync all OpenAI-compatible providers.

| Field | Default | Description | | --- | --- | --- | | providerId | all compatible providers | Optional provider key in models.json | | pricingUrl | Sub2API metadata repository | Pricing and capability JSON URL | | include | [".*"] | Regex patterns; a model must match at least one | | exclude | audio/realtime/image/embedding/auto-review | Regex patterns removed from the result | | requestTimeoutMs | 15000 | Timeout for each HTTP request | | defaults | zero-cost, text, 128K/16K | Metadata used when no matching entry exists | | overrides | {} | Per-model Pi metadata overrides |

Provider apiKey and headers support the same value forms as Pi's models.json: literals, $ENV_VAR, ${ENV_VAR}, and leading !command values.

Reasoning levels

Reasoning levels are derived from these metadata fields:

  • supports_reasoning
  • supports_none_reasoning_effort
  • supports_minimal_reasoning_effort
  • supports_xhigh_reasoning_effort
  • supports_max_reasoning_effort

For a reasoning model, low, medium, and high are enabled. off, minimal, xhigh, and max are enabled only when the corresponding capability flag is present. Use overrides when an API gateway or aliased model behaves differently from the metadata repository.

Security

The extension reads provider credentials locally only to call the configured /models endpoint. It does not write credentials, include them in logs, or send them to the metadata endpoint. The metadata request is unauthenticated.

Prefer environment references such as $OPENAI_API_KEY instead of storing a literal secret in models.json.

Development

npm install
npm test
npm run typecheck
npm run lint
pi --no-extensions -e ./extensions/openai-api-models-sync.ts --list-models

License

MIT