This the clean setup of Pi on OpenRouter by default
npm install -g @mariozechner/pi-coding-agentCheck that it installed:
pi --versionPi needs a bash shell on Windows. For most people, installing Git for Windows is enough: https://git-scm.com/download/win
mkdir -p ~/.pi/agentNew-Item -ItemType Directory -Force "$HOME/.pi/agent"On Windows, that usually lives here:
C:\Users\YOUR_NAME\.pi\agent\
Pi supports credentials in auth.json, and that takes priority over environment variables.
That’s the cleanest move here.
nano ~/.pi/agent/auth.jsonnotepad $HOME\.pi\agent\auth.jsonPaste this in:
{
"openrouter": {
"type": "api_key",
"key": "sk-or-your-key-here"
}
}Get your key here:
A couple things matter:
- keep
"type": "api_key" - keep
"key" - do not rename it to
apiKey
Now tell Pi to boot into OpenRouter automatically.
nano ~/.pi/agent/settings.jsonnotepad $HOME\.pi\agent\settings.jsonPaste this in:
{
"defaultProvider": "openrouter",
"defaultModel": "anthropic/claude-sonnet-4"
}That gives you:
- OpenRouter as the default provider
- Claude Sonnet 4 as the default model through OpenRouter
If you want a different model, swap this line:
"defaultModel": "anthropic/claude-sonnet-4"for any OpenRouter-supported model in this format:
author/model-name
Browse models here:
piStart with:
piIf PowerShell complains, use:
pi.cmdIf everything worked, Pi should open using OpenRouter by default.
Pi needs bash on Windows.
If Git for Windows is installed and Pi still doesn’t detect it, add shellPath to settings.json.
Use this:
{
"defaultProvider": "openrouter",
"defaultModel": "anthropic/claude-sonnet-4",
"shellPath": "C:\\Program Files\\Git\\bin\\bash.exe"
}Only do this if Pi isn’t picking up Git Bash automatically.
- switch models:
Ctrl+Lor/model - cycle scoped models:
Ctrl+P - change thinking level:
Shift+Tab - continue last session:
pi -c - browse older sessions:
pi -r
Thanks 💚