Connect Pi Coding Agent
Configure CanalAPI models.json, environment credentials and model selection in Pi, starting with tools disabled.
Pi here means the terminal Pi Coding Agent. Its official repository moved from badlogic/pi-mono to earendil-works/pi; this is not another chat product named Pi.
Checked 2026-11-03 against v1.5.0. Current package, configuration and CLI flags were checked; real CanalAPI requests remain untested.
1. Install and prepare
Use an OS installer from the official guide, or install this reference version with Node.js 22.19+:
npm install -g --ignore-scripts @earendil-works/pi-coding-agent@1.5.0
pi --versionPrepare a dedicated key and a full model ID supporting Chat Completions. Coding tools also require tool-call support.
2. Add models.json
Back up ~/.pi/agent/models.json, normally %USERPROFILE%\.pi\agent\models.json on Windows. Honor a custom PI_CODING_AGENT_DIR. Merge providers.canalapi while preserving existing providers:
{
"providers": {
"canalapi": {
"baseUrl": "https://api.canalapi.com/v1",
"api": "openai-completions",
"apiKey": "${CANALAPI_API_KEY}",
"authHeader": true,
"models": [
{
"id": "YOUR_MODEL_ID",
"name": "CanalAPI model",
"input": [
"text"
],
"contextWindow": 128000,
"maxTokens": 8192
}
]
}
}
}Replace YOUR_MODEL_ID. 128000 context / 8192 output are illustrative, not promised capacities; set the model's actual limits before running. Client cost estimates are separate from actual billing.
Pi v1.5.0 resolves ${CANALAPI_API_KEY} or $CANALAPI_API_KEY as an environment reference. The old bare string "CANALAPI_API_KEY" is a literal in this version. authHeader: true explicitly sends Bearer authentication. openai-completions means Chat Completions.
Set the key in the PowerShell window that will start Pi:
$env:CANALAPI_API_KEY = "YOUR_CANALAPI_KEY"macOS / Linux:
export CANALAPI_API_KEY='YOUR_CANALAPI_KEY'Replace the placeholder; keep the real key out of JSON and screenshots. Credential precedence is CLI --api-key, saved auth.json, models.json, then provider environment variables. If canalapi already has saved credentials, inspect and remove only that provider's old login using upstream guidance, not the whole auth file.
3. Verify with tools disabled
pi --provider canalapi --model YOUR_MODEL_ID --no-tools--provider requires --model. Ask “Reply only OK” and confirm usage logs. Interactive /model reloads the file and switches models; usable credentials are required for a model to appear. Ctrl+S saves a selection as the default for new sessions.
After chat succeeds, restart normally in a dedicated test directory and verify tools. Default tools include reading, commands, editing and writing; Pi does not ask for approval before every call. A working directory or read-only prompt is not an access-control boundary. Limit tools and the execution environment to the task.
Troubleshooting and recovery
- Missing model: check JSON, the active config directory, process environment and saved credentials.
- Old model: resumed sessions restore their selection. Pass both model flags or verify in a new session.
- 400: check protocol and model before copying compatibility flags, reasoning parameters or capability claims.
- Undo: select the original model, remove only
providers.canalapior restore the backup, preserving other sessions and credentials. Revoke an unused dedicated key.
Sources: models, field reference, CLI, permissions. See troubleshooting.