pi-diy-provider
Create custom API providers for Pi without editing JSON
Package details
Install pi-diy-provider from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-diy-provider- Package
pi-diy-provider- Version
0.1.1- Published
- Sep 4, 2026
- Downloads
- 326/mo · 18/wk
- Author
- nature_tide
- License
- MIT
- Types
- extension
- Size
- 42.5 KB
- Dependencies
- 0 dependencies · 1 peer
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 DIY Provider
English | 简体中文 | 繁體中文 | 日本語 | 한국어
A focused Pi package for setting up API-key-based relay and custom providers without editing JSON. It writes provider and model definitions to ~/.pi/agent/models.json, refreshes Pi's model registry, and safely reloads the extension runtime.
Install
Install the latest release from npm:
pi install npm:pi-diy-provider
Try it for one session without adding it to your settings:
pi -e npm:pi-diy-provider
Update or remove the installed package:
pi update npm:pi-diy-provider
pi remove npm:pi-diy-provider
Use
Run /provider-add and enter:
- a stable lowercase provider id;
- a display name;
- an HTTP(S) Base URL;
- an API type (OpenAI Chat Completions is the default; OpenAI Responses, Anthropic Messages, and Google Generative AI are also supported);
- whether to discover models after login or enter model ids manually.
The recommended discovery flow is:
/provider-add
/login <provider-id>
/provider-model-sync <provider-id>
/provider-model-sync resolves the API key from Pi's credential store, requests the provider's model-catalog endpoint, and opens the discovered comma-separated model ids in an editor for review. Confirming the list updates models.json, refreshes Pi, and makes the authenticated models available in /model.
Discovery recognizes OpenAI- and Anthropic-style { "data": [...] } catalogs and Google-style { "models": [...] } catalogs. It sends the stored key using the authentication convention for the selected API and times out after 20 seconds. A relay must expose a compatible model-list endpoint; if it does not, rerun /provider-add and choose manual model entry.
The extension preserves unrelated models.json configuration. Before changing an existing file, it creates a timestamped sibling backup such as models.json.backup-20260905T010203004Z, then replaces the original atomically. Existing JSON comments are accepted, although a rewritten file is formatted as standard JSON; the backup retains the exact original text.
No API key is written to models.json. When using manual model entry, run:
/login <provider-id>
The provider appears in Pi's built-in API-key provider list. After the key is saved in Pi's credential store, manually configured models become available in /model; discovery-mode providers appear there after /provider-model-sync saves a non-empty model list. This package intentionally adds separate /provider-add and /provider-model-sync commands; Pi's extension API does not expose a supported way to inject an arbitrary setup action into the native /login menu.
Development
Requires Node.js 22.19 or newer.
git clone https://github.com/chen-985211/pi-diy-provider.git
cd pi-diy-provider
npm install --ignore-scripts
npm run check
Load the local checkout for one session while developing:
pi -e /absolute/path/to/pi-diy-provider
Or install the local checkout in Pi:
pi install /absolute/path/to/pi-diy-provider