omp packages

pi-model-setup0.0.3

Add API endpoints and import models into Pi.

GitHub Actions Published 3 days ago MIT ~0 downloads/mo

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.

Did it work for you?

Result

One report per person. A new report replaces your old one.

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.

  1. Run /model-setup and press N to add an endpoint. Choose a unique ID such as my-gateway, select the protocol, and enter the Base URL and API key. For local services without authentication, select No authentication (Pi may send the placeholder local).
  2. Open the endpoint and press F to fetch its models. Type to filter, press Space to toggle a model, Ctrl+A to select ready matches, and Ctrl+X to clear the selection. Press Enter to import. You can fill in or skip models that need review.
  3. Return to Pi and run /model to choose a model. Imports do not overwrite existing models or switch the active model. If your endpoint cannot list models, press N inside 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 O inside an endpoint for JSON options. headers adds 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. modelsPath overrides 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 is x-api-key.
  • For Chat Completions, compat can explicitly set supportsStore, supportsDeveloperRole, and maxTokensField (max_tokens or max_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 C when editing a model to set pricing in USD per million tokens, e.g. {"input":1.5,"output":4}. Optional keys: cacheRead and cacheWrite. Use null to 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:

  1. Your presets. A preset for my-gateway/fast takes precedence over a global fast preset. 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 ID fast.
  2. 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, or max_completion_tokens.
  3. 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