@seqyuan/pimodel

Import OpenAI-compatible model providers into PI models.json

Packages

Package details

package

Install @seqyuan/pimodel from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@seqyuan/pimodel
Package
@seqyuan/pimodel
Version
0.2.4
Published
May 28, 2026
Downloads
784/mo · 784/wk
Author
seqyuan
License
MIT
Types
package
Size
25.7 KB
Dependencies
1 dependency · 0 peers

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pimodel

pimodel imports models from an OpenAI-compatible provider into PI's models.json.

It is a lightweight Node.js CLI with a small interactive prompt dependency and no release build step.

Install

npm install -g @seqyuan/pimodel

Usage

pimodel            # interactive import
pimodel --version  # print version
pimodel --help     # show help

The tool will interactively prompt for:

Prompt Description
Base URL Provider base URL (e.g. https://api.openai.com)
API Key API key; leave empty for local providers
Provider name PI provider name to create or update
Models Choose models interactively from the fetched provider catalog

Endpoint discovery

The CLI automatically tries multiple endpoint paths to fetch the model list:

  • /v1/models — OpenAI / most compatible providers
  • /models
  • /api/models
  • /api/tags — Ollama

Model display format

When models are discovered, the CLI renders them in this format:

Available models (14):
  1. custom - unknown | out=64000
  2. auto - unknown | out=64000
  3. ring-2.6-1t - unknown | ctx=262144 | out=32800
  4. mimo-v2.5-pro - unknown | ctx=1000000 | out=131000
  5. gpt-5.3-codex - unknown | ctx=400000 | out=128000

Interactive model selection

The flow first lets you choose between importing all models or interactively selecting a subset.

  • Up / Down: move
  • Space: select or unselect the current model
  • Enter: confirm selection
  • Ctrl+C: cancel

For large catalogs, the interactive picker uses a scrollable list instead of printing every model at once. If you enter the multi-select picker and confirm with nothing checked, it imports all models.

Non-interactive mode

When stdin or stdout is not a TTY (e.g. piped input), the tool falls back to a prompt-based mode: it prints the model table and asks you to type all, model numbers, or model IDs.

Provider matching and re-import

When importing, the CLI matches existing providers by baseUrl + apiKey. If a match is found, models are merged into the existing provider entry rather than creating a duplicate.

Re-importing an existing provider overwrites baseUrl and apiKey with the latest values, so you can fix wrong URLs or rotate credentials.

New models are added; existing models are skipped by default (use replaceExisting in programmatic mode to overwrite).

Metadata enrichment

If the provider's model list does not include context window or max output tokens, the CLI automatically tries model detail endpoints (/v1/models/{id}, /models/{id}, /api/models/{id}, Ollama /api/show) to fill in the gaps.

For models where detail endpoints also don't return limits, pimodel estimates defaults based on the model ID (e.g. Claude models default to 200k context, DeepSeek to 128k). Claude models with "thinking" or "reasoning" in the ID are automatically flagged with reasoning: true.

Output

By default it writes:

~/.pi/agent/models.json

If PI_CODING_AGENT_DIR is set, it writes ${PI_CODING_AGENT_DIR}/models.json.