omp packages

pi-cpa0.2.3

pi provider for CLIProxyAPI (CPA) endpoints: one /cpa panel to enter the key, pick the models that key can use, and keep the lineup in sync

GitHub Actions Published 1 day ago MIT ~1K 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-cpa

One /cpa panel for a CLIProxyAPI (CPA) endpoint: log in with the key, tick the models that key can actually call, and pi gets a working provider without editing models.json.

What's included

Extension Surface What it does
index.ts /cpa Opens the panel: status, auth (login/logout), model picker.
index.ts cpa provider Registers the selected models at session start, over Chat Completions, Responses or Anthropic Messages per model.
index.ts session_start Re-reads the catalog, notifies about new models, and warns about selected models this key lost access to.

There is exactly one command. Login, logout and model choice are actions inside the /cpa panel, not subcommands. esc closes the panel.

Install

pi install npm:pi-cpa

To try it for one run without installing: pi -e npm:pi-cpa.

Usage

  1. Run /cpa.
  2. On a fresh install the panel opens the Login form first: paste the key and press enter. It is checked against GET /v1/models before anything is saved. The endpoint is not edited here — it defaults to https://cpa.c2ph.com, and endpoint in cpa.json is the only way to point the provider at another server. Once a key is saved, Auth shows a single Logout row instead of Login, which forgets the key and the catalog snapshot.
  3. The Models picker opens next. ←/→ switch vendor tabs, ↑/↓ move, space toggles a model, a toggles the whole tab, and enter saves the lineup. A ◉ marks models that accept images.
  4. Opening Models re-reads what the key can use, so there is no separate refresh action. New ids are badged new in the picker; if the read fails, the last snapshot is shown with the error.

Where available, model limits and list prices come from vendor entries in pi's generated catalog, so cost estimates approximate normal API rates rather than CPA charges. Other entries retain tuned values or estimates; they are not necessarily official prices. Thinking levels and compatibility flags are tuned for this proxy.

Only models present in the key's catalog are ever registered: a model the key cannot use is never offered to pi, so a 403 at request time is not the first sign of a bad selection.

Configuration

One file, written by the panel:

Path Contents
<agent-dir>/cpa.json (mode 0600) endpoint, apiKey, the selected models, and the last catalog snapshot (id + owned_by only).

<agent-dir> is ~/.pi/agent unless PI_CODING_AGENT_DIR says otherwise. CPA_CONFIG points the file somewhere else; it exists for tests.

The panel never edits endpoint; change that value in cpa.json to use another server. The key, the model selection and the snapshot are all managed by /cpa.

Nothing else is needed: no environment variable for the key, no models.json edit. If models.json still contains a hand-written providers.cpa block, the panel warns — that block would layer above this provider and shadow its key, so delete it.

Security note

  • The API key is stored in plain text in cpa.json, mode 0600, inside pi's agent directory. It is written atomically, so a crash cannot leave a permissive half-file.
  • Network access is one request: GET <endpoint>/v1/models with Authorization: Bearer <key>, on the endpoint from cpa.json. Model traffic goes wherever that endpoint proxies it.
  • No shell commands, no tools, and no file access outside the agent directory.
  • Extensions run in-process with your OS permissions.

Update and remove

pi update --extensions     # update installed packages
pi remove npm:pi-cpa      # uninstall
pi config                  # enable or disable the extension

Logging out: /cpa → Auth → Logout, which forgets the saved key. Logging in again is the same panel's Login row. Deleting cpa.json also resets everything, including the model selection.

Compatibility

  • Pi 1.6.1 (development pin; peer dependencies are *).
  • Node.js 22 or newer.
  • Linux and macOS. Windows is untested.

Development

npm install
npm test          # config persistence, catalog parsing, protocol heuristics, selection, status
npm run typecheck
pi -e ./index.ts

Live check: run /cpa and open Models; the status line shows the model count and the age of the snapshot.

License

MIT © 2026 kslamph