@arhen/pi-add-commandcode
v0.0.3
Published
pi extension: Command Code Provider API (models, ZDR).
Maintainers
Readme
@arhen/pi-add-commandcode
Install
Requires the pi coding agent — install it first: npm install -g @earendil-works/pi-coding-agent.
pi install npm:@arhen/pi-add-commandcodeCommand Code Provider API for pi — 58 models on one key, live catalog, dual-endpoint routing, Zero Data Retention toggle.
- Login:
/login→ "Command Code" → API key (orCOMMANDCODE_API_KEY) /commandcode— status: key, model count, ZDR state/commandcode zdr [on|off]— Zero Data Retention (persisted across sessions)
Endpoint routing
The API is two endpoints on one base, and using the wrong one is a hard 400:
| Models | Endpoint | pi API |
| --- | --- | --- |
| claude-* (7) | /provider/v1/messages | anthropic-messages |
| everything else (51) | /provider/v1/chat/completions | openai-completions |
Routing is per model, so /model just works — pick any id and the right shape is sent.
Models are fetched in the extension factory, which pi awaits before startup finishes, so the catalog is ready for interactive startup and /model. Fetching in session_start instead leaves the provider empty on first paint.
Model metadata
GET /provider/v1/models returns only id, name, and context_length — no pricing, no capability flags. So metadata comes from two sources:
- Claude ids reuse pi's built-in
ANTHROPIC_MODELSentry. Rates are identical to the Command Code docs, and it carriesforceAdaptiveThinkingandsupportsTemperature, which Opus 4.7+/Sonnet 4.6 need to think correctly. - Everything else reads the
CATALOGtable insrc/index.ts, transcribed from pricing & limits.
npx tsx src/index.test.ts # runs the real factory against a stub APIThe test asserts every live model resolves to exactly one source, that Claude ids route to Messages with a /v1-less baseUrl, and that an offline refresh preserves the catalog rather than emptying it. Run it after Command Code adds models: a model in neither source still registers, but bills as free and claims reasoning: true, so the test fails rather than letting that ship.
Zero Data Retention
/commandcode zdr on sends x-cmd-zdr: 1 on every request, so it routes only through ZDR-capable upstreams. Per the docs there is no silent fallback: a model with no ZDR upstream fails with 422 cmd_zdr_no_providers instead of quietly using a non-ZDR route. ZDR may also change which upstream serves you, so cost can differ.
Notes
- Reasoning effort accepts
low|medium|high|xhigh|max. There is nonone, so thinking-off is marked unsupported and pi omits the field. - Token usage arrives at the end of every stream with no opt-in, so pi's built-in cost footer works as-is.
- Claude ids register on any plan but return
403 MODEL_NOT_IN_PLANunless your plan covers them. - Long-context pricing tiers (8 models bill ~2× past a threshold) are not modelled —
CATALOGholds the standard tier, so cost reads low on very large contexts.
License
MIT.
