cpa-provider

CLIProxyAPI provider extension for pi with automatic model discovery

Packages

Package details

extension

Install cpa-provider from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:cpa-provider
Package
cpa-provider
Version
0.2.4
Published
Oct 9, 2026
Downloads
238/mo · 196/wk
Author
gcoder1991
License
MIT
Types
extension
Size
12 KB
Dependencies
0 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./index.ts"
  ]
}

Security note

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

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-provider

Git installs are also supported:

pi install https://github.com/gcoder1991/cpa-provider

Restart pi, then configure the provider:

/login cpa

Enter the API key configured in CLIProxyAPI. Use /model to select a discovered model.

Configuration

The default CLIProxyAPI endpoint is:

http://127.0.0.1:8317

Override it before starting pi:

CPA_BASE_URL=http://127.0.0.1:8317 pi

For non-interactive authentication:

CPA_API_KEY=your-api-key pi

Both variables can be used together:

CPA_BASE_URL=https://cpa.example.com CPA_API_KEY=your-api-key pi

Fast mode

Toggle OpenAI Fast mode for CPA requests:

/cpa-fast on
/cpa-fast off
/cpa-fast status
/cpa-info

To enable it at startup:

CPA_FAST_MODE=1 pi

Fast 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:

  1. Exact, case-sensitive model ID.
  2. Longest catalog ID that prefixes the requested ID, followed by -, _, :, or /. For example, glm-5.3-ali matches glm-5.3, but glm-5.30 does not.
  3. 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 --extensions

Remove

pi remove npm:cpa-provider