Connect the Pi coding agent to RedRouter through its OpenAI Chat Completions adapter. The setup CLI writes the provider configuration and installs a local Pi extension.
Set up Pi
The CLI requires Node.js 20.11+; the tested Pi 1.6.0 requires Node.js 22.19+. Install Pi separately. Create an API key and export it in the same terminal where you launch the agent. The CLI keeps the key out of configuration files.
Init reads the live catalog, merges your settings, and makes one test generation capped at 64 output tokens before saving. This uses one eligible trial generation or paid usage. A failed test leaves your configuration unchanged. --dry-run previews paths without writing or generating; --skip-test saves without checking the API.
npm install -g @earendil-works/pi-coding-agent@1.6.0
export REDROUTER_API_KEY="your-redrouter-api-key"
npx @redrouter/cli init --tools pi
pi --provider redrouter --model red-cyber-1
Install Pi separately following its official guide. Ask it to read a small README and summarize its purpose. Pi executes local tools under your control.
Tested on November 20, 2026: Pi 1.6.0 completed a read-tool round trip with red-cyber-1.
Configuration and extension
Init merges ~/.pi/agent/models.json and settings.json, or the directory selected by PI_CODING_AGENT_DIR. It sets the redrouter provider, the default model, and an extension under ~/.config/redrouter/integrations. The adapter uses https://redrouter.org/v1 and reads REDROUTER_API_KEY from the environment.
The initial output cap is 8,192 tokens. Static model overrides take precedence over extension-discovered catalog metadata. Run /model in Pi to choose a different model; check its capabilities before using images or structured output.
To install just the package extension through Pi instead of using init:
pi install npm:@redrouter/cli
pi --provider redrouter --model red-cyber-1
Use one installation method. If you switch to the package extension, remove the CLI-installed extension entry from Pi's settings to avoid loading both copies. If you want the extension to own the catalog, also remove the static redrouter provider from models.json after backing it up.
Fix Pi setup errors
Provider missing or model not found
Confirm Pi is reading the expected agent directory and that --provider redrouter matches the configured provider name. Use the exact API model red-cyber-1. If the extension was moved or deleted, rerun init to restore its local files. An API model_not_found response requires checking the current catalog.
401, credit hold or truncated tool arguments
Keep REDROUTER_API_KEY exported in the shell that launches Pi. If a request cannot reserve enough credit, lower its output cap or history size. Truncated tool arguments need a shorter turn or suitable output limit. See setup errors and tool calling.
Changed files have private .redrouter-<id>.bak backups beside them. Restore them to undo setup; delete files created by init only after reviewing their use.
See data handling for API content controls. Local Pi transcripts and tool output have separate retention settings.