← Catalog

pi-custom-model-provider

Discover models from the OpenAI-compatible providers in your models.json and keep them refreshed.

Provider

Install

Install with PiG

pig install npm:pi-custom-model-provider

Install with Pi

pi install npm:pi-custom-model-provider
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

README

Written by the package's publisher, shown as published in version 0.1.1 (README.md). PiG does not review it.

pi-custom-model-provider

Discover the model catalog of the OpenAI-compatible providers you already configured in ~/.pi/agent/models.json, instead of maintaining the list twice.

For every provider there whose api is openai-completions and that has a baseUrl, the extension:

  1. reads the model list from GET {baseUrl}/models at startup,
  2. registers the result through pi.registerProvider(), so the models appear in /model and in pi --list-models,
  3. implements refreshModels, so Pi's own model refresh re-reads the endpoint with the effective credential.

Install

pi install npm:pi-custom-model-provider
# or from git
pi install git:github.com/zaypen/pi-custom-model-provider

Run /reload if Pi is already running.

Configuration

No config file of its own. This models.json entry is the whole setup:

{
  "providers": {
    "bifrost": {
      "baseUrl": "https://gateway.example.com/v1",
      "apiKey": "$BIFROST_API_KEY",
      "models": [
        { "id": "deepseek-r1", "reasoning": true, "contextWindow": 163840 }
      ]
    }
  }
}

With 30 models on the endpoint you write one of them.

Key resolution

~/.pi/agent/auth.json first (the entry Pi writes for that provider id when you run /login, type: "api_key"), then the apiKey value in models.json, which is expanded for $ENV_VAR and ${ENV_VAR}. Providers that resolve no key are registered from their models entries only, and the fetch is reported as no API key.

Live refreshes pass the credential Pi resolved to refreshModels, so a stored or refreshed credential is used in preference to the startup key.

Merge policy

The endpoint decides which models exist; models.json decides their metadata. If deepseek-r1 is in your models array and the endpoint returns it too, your contextWindow, cost, reasoning, input, name, api, and baseUrl win. A model you never wrote gets the defaults: 128000 context window, 8192 max tokens, zero cost, text-only input.

Models that are in models.json but not returned by the endpoint stay registered. A refresh failure keeps the previously known list.

Commands

  • /custom-models — re-fetch every matching provider and report.
  • /custom-models status — show model counts, how many came from the endpoint, and where the key came from.

Behaviour

  • PI_OFFLINE set: no startup fetch. models.json entries are still registered, and Pi's refresh callback is told to stay off the network.
  • Each fetch is capped at 3 seconds; the caller's signal is honoured on top.

Limitations

  • Only openai-completions providers are fetched. Providers on other APIs are left alone, including openai-responses ones.
  • The 3 second cap is per endpoint and fixed.

Compared to its siblings

Three other Pi extensions discover models from OpenAI-compatible endpoints, so pick the one that matches your setup:

(blank)config sourcerefreshmetadata authority
this onemodels.jsonstartup seed + native refreshModelsmodels.json wins
pi-model-discoverymodels.jsonits own commandsendpoint wins
pi-dynamic-modelsseparate dynamic-models.jsonstartup + session_startits defaults

Differences that actually matter: this one finds keys that /login stored in auth.json, and hands discovery to Pi's refresh machinery rather than running on its own clock.

Development

Try it without installing:

pi -e ./extensions/index.ts

License

MIT