Use Claude in pi with a custom provider
Add AI in IDE to the pi coding agent as a custom Anthropic-compatible provider and run Claude Opus 5.5, Sonnet 5.5, or Haiku 4.5 with one API key.
Tested on 2026-11-06 with pi installed from @earendil-works/pi-coding-agent: pi -p returned a reply from claude-sonnet-5-5 and claude-haiku-4-5-20251001 through the file below.
Setup at a glance
- Create the API key. Open API Keys, create a key, and choose the AWSQ or CCMAX channel. A Codex or Gemini key is rejected on the Claude endpoint.
- Export the key. Add
export AIINIDE_API_KEY="YOUR_DASHBOARD_API_KEY"to~/.zshrcor~/.bashrc, then open a new terminal. - Add the provider. Create or merge
~/.pi/agent/models.json:
1 {2 "providers": {3 "aiinide": {4 "baseUrl": "https://api.aiinide.com",5 "api": "anthropic-messages",6 "apiKey": "$AIINIDE_API_KEY",7 "models": [8 { "id": "claude-sonnet-5-5", "name": "Claude Sonnet 5.5", "reasoning": true, "input": ["text", "image"], "contextWindow": 200000, "maxTokens": 64000 },9 { "id": "claude-opus-5-5", "name": "Claude Opus 5.5", "reasoning": true, "input": ["text", "image"], "contextWindow": 200000, "maxTokens": 64000 },10 { "id": "claude-haiku-4-5-20251001", "name": "Claude Haiku 4.5", "input": ["text", "image"], "contextWindow": 200000, "maxTokens": 64000 }11 ]12 }13 }14 }
- Verify. Run
pi --model aiinide/claude-sonnet-5-5 -p "Reply with exactly: OK". The reply isOK, and the request appears in Usage.
The base URL must be the bare host
With "api": "anthropic-messages", pi appends /v1/messages itself. https://api.aiinide.com/v1 produces /v1/v1/messages and a 404 Not Found page. This is the same rule as Claude Code and the opposite of OpenCode.
"apiKey": "$AIINIDE_API_KEY" is read from the environment when pi starts, so the key never sits in the file. Opening /model in a session reloads models.json after you edit it.
Models
| Model in pi | Channel | Use it for |
|---|---|---|
aiinide/claude-opus-5-5 | AWSQ, CCMAX | hard refactors, long agent runs |
aiinide/claude-sonnet-5-5 | AWSQ, CCMAX | everyday coding |
aiinide/claude-haiku-4-5-20251001 | AWSQ, CCMAX | quick edits, cheap checks |
GET /v1/models with your key returns every model ID the channel accepts; add any of them to the models array. pi's own cost display stays at $0 because the file has no cost field. Real charges are on Usage, and rates are on Models.
FAQ
Which base URL does pi need for AI in IDE?
https://api.aiinide.com with "api": "anthropic-messages". pi appends /v1/messages; adding /v1 yourself returns 404.
Where is models.json?
~/.pi/agent/models.json. The PI_CODING_AGENT_DIR environment variable moves the whole agent directory.
Why does pi still use Gemini by default?
pi's default provider is Google. Pass --model aiinide/claude-sonnet-5-5, or pick the model with /model in a session.
Can I use the OpenAI-compatible endpoint instead?
Yes, with "api": "openai-completions" and "baseUrl": "https://api.aiinide.com/v1" (note the /v1 here). Both were tested. Prefer the Anthropic endpoint: it supports Claude extensions such as Fast mode and hosted tools, which the OpenAI-compatible endpoint does not.