pi-model-setup0.0.3
Add API endpoints and import models into Pi.
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
Pi Model Setup
Add API endpoints and import models into Pi. Batch-import models and fill missing settings from upstream metadata or the Pi catalog when a reliable match is available.
Install and use
pi install npm:pi-model-setup
To try a local checkout, run pi --no-extensions -e ./src/index.ts from the project directory. Tested with Pi 1.7.0.
- Run
/model-setupand pressNto add an endpoint. Choose a unique ID such asmy-gateway, select the protocol, and enter the Base URL and API key. For local services without authentication, select No authentication (Pi may send the placeholderlocal). - Open the endpoint and press
Fto fetch its models. Type to filter, pressSpaceto toggle a model,Ctrl+Ato select ready matches, andCtrl+Xto clear the selection. PressEnterto import. You can fill in or skip models that need review. - Return to Pi and run
/modelto choose a model. Imports do not overwrite existing models or switch the active model. If your endpoint cannot list models, pressNinside it to add one manually.
Press / to search a dashboard, L on the endpoints screen to switch languages, or D to delete an endpoint after confirmation. Open a model to edit its display name or limits and save with Ctrl+S. On Context window, use ←/→ to try common sizes (32,768 / 65,536 / 128,000 / 200,000 / 262,144 / 1,000,000 tokens), or press Enter to type an exact value. Shortcuts are manual choices, not automatic defaults or server limits.
Gateways and model settings
- OpenAI Chat Completions / Responses: use the complete Base URL, often
https://gateway.example/v1. Discovery appends/models. Anthropic Messages: discovery uses/v1/models; the Base URL may include or omit the trailing/v1. - Press
Oinside an endpoint for JSON options.headersadds non-secret request headers (e.g.{"X-Title":"My Pi"}); values are stored in plain text. Put credentials in the hidden key prompt, not in this JSON.modelsPathoverrides the discovery path on the same host, e.g./api/tags. This only affects discovery, not the chat protocol. Anthropic supports"anthropicAuth":"bearer"if required; the default isx-api-key. - For Chat Completions,
compatcan explicitly setsupportsStore,supportsDeveloperRole, andmaxTokensField(max_tokensormax_completion_tokens). Only change options required by your gateway. - Discovery supports
data,models, and top-level model arrays. It does not follow redirects. A model list can be importable even if the server does not implement the selected chat protocol. - Press
Cwhen editing a model to set pricing in USD per million tokens, e.g.{"input":1.5,"output":4}. Optional keys:cacheReadandcacheWrite. Usenullto clear. Without pricing, Pi estimates zero cost; this is not a billing statement.
Where model limits come from
The context window is the model's total token budget; max output is the generation limit. For batch imports, the plugin uses these sources in order:
- Your presets. A preset for
my-gateway/fasttakes precedence over a globalfastpreset. A preset can set values directly or reference a Pi catalog model, for example{"fast":"openai/gpt-4.1"}. The request still uses the original model IDfast. - Your endpoint's model list. If there is no explicit preset, the plugin reads any limits the server reports, such as
context_window,context_length,max_output_tokens, ormax_completion_tokens. - Pi's model catalog. A reliable match supplies missing fields from Pi's live model registry. Pi starts with its bundled catalog and can overlay newer data from pi.dev/models. Pi's catalog generator combines models.dev, provider catalogs, and Pi's own corrections. The importer displays its sources; a catalog value is a reference, not a measurement of your endpoint.
If a limit is still missing or the values conflict, the model needs review: enter the limits yourself or skip it. The plugin does not guess a fixed limit or probe the API to measure one. Use exact token counts or units such as 200k and 1m. An imported model keeps its saved values until you edit it or apply a preset again.
Credentials and platforms
API keys are stored with AES‑256‑GCM. Data is stored in ~/.pi/agent/model-workbench/ by default and follows Pi's --agent-dir option. On Linux/macOS, vault.key must be a private file owned by the current user (normally mode 0600). On Windows, it is protected with DPAPI for the current Windows account, requires Windows PowerShell, and needs a filesystem that supports hard links, such as NTFS. A Windows key file cannot simply be copied to a different account or operating system.
Enter keys only in Pi's hidden terminal prompt. Use HTTPS for remote endpoints. Changing an endpoint's address or protocol requires re-entering its key and resets advanced options. Do not share vault.key or your configuration. See the credential recovery guide if you lose vault.key.
Development
Use Node.js 22.19 or newer. The extension runs directly from TypeScript under Pi.
npm ci
npm run typecheck
npm run test:coverage
npm run test:smoke # Linux terminal/Python 3
npm pack --dry-run
Publishing guide · MIT license