cpa-provider
v0.2.4
Published
CLIProxyAPI provider extension for pi with automatic model discovery
Maintainers
Readme
cpa-provider
CLIProxyAPI provider extension for pi.
The extension reads the OpenAI-compatible /v1/models endpoint, registers the returned models in pi, and enriches known model IDs with context limits, reasoning support, image input, and output limits from pi's bundled model catalog.
Install
pi install npm:cpa-providerGit installs are also supported:
pi install https://github.com/gcoder1991/cpa-providerRestart pi, then configure the provider:
/login cpaEnter the API key configured in CLIProxyAPI. Use /model to select a discovered model.
Configuration
The default CLIProxyAPI endpoint is:
http://127.0.0.1:8317Override it before starting pi:
CPA_BASE_URL=http://127.0.0.1:8317 piFor non-interactive authentication:
CPA_API_KEY=your-api-key piBoth variables can be used together:
CPA_BASE_URL=https://cpa.example.com CPA_API_KEY=your-api-key piFast mode
Toggle OpenAI Fast mode for CPA requests:
/cpa-fast on
/cpa-fast off
/cpa-fast status
/cpa-infoTo enable it at startup:
CPA_FAST_MODE=1 piFast mode sends service_tier: "priority", the backward-compatible name for OpenAI Fast mode. OpenAI/Codex text models use /v1/responses; other discovered models keep /v1/chat/completions.
Model metadata
/v1/models normally returns model IDs but not capability metadata. Known IDs are matched against the model catalog bundled with pi, without additional network requests, for:
- context window
- maximum output tokens
- reasoning support
- image input support
- pricing metadata
Matching searches all bundled chat-model catalogs, using this order:
- Exact, case-sensitive model ID.
- Longest catalog ID that prefixes the requested ID, followed by
-,_,:, or/. For example,glm-5.3-alimatchesglm-5.3, butglm-5.30does not. - For the same matching ID in multiple providers, existing family-based provider preferences win (including Qwen token-plan providers). Otherwise, the first provider in alphabetical order wins. Provider metadata can differ; this fallback is deterministic, not a guarantee of upstream capabilities.
For example, qwen3.8-max matches exactly; aliases can inherit metadata via prefix matching. A longer or exact ID always beats a shorter prefix, even in a preferred provider. Matching does not strip provider prefixes or correct spelling. It only supplies metadata: the original CPA model ID, endpoint, and API selection are retained. Prefix matching may overestimate capabilities for a distinct model variant; use Pi's modelOverrides when needed.
IDs with no match remain available with conservative defaults: 128K context, 16K maximum output, text-only input, and reasoning disabled.
Tests
Run npm test with Node.js 22.18+ (native TypeScript stripping).
Update
pi update --extensionsRemove
pi remove npm:cpa-provider