Skip to content

Instantly share code, notes, and snippets.

@ERICJ3ffrey
Last active September 28, 2026 00:20
Show Gist options
  • Select an option

  • Save ERICJ3ffrey/1067c38028fa1c9e2914b30c63a2448a to your computer and use it in GitHub Desktop.

Select an option

Save ERICJ3ffrey/1067c38028fa1c9e2914b30c63a2448a to your computer and use it in GitHub Desktop.
Setting Up PI Agent with OpenRouter

This the clean setup of Pi on OpenRouter by default

0) Install Pi

npm install -g @mariozechner/pi-coding-agent

Check that it installed:

pi --version

Windows note

Pi needs a bash shell on Windows. For most people, installing Git for Windows is enough: https://git-scm.com/download/win


1) Create Pi’s config folder

Mac / Linux

mkdir -p ~/.pi/agent

Windows PowerShell

New-Item -ItemType Directory -Force "$HOME/.pi/agent"

On Windows, that usually lives here:

C:\Users\YOUR_NAME\.pi\agent\

2) Add your OpenRouter API key

Pi supports credentials in auth.json, and that takes priority over environment variables. That’s the cleanest move here.

Mac / Linux

nano ~/.pi/agent/auth.json

Windows PowerShell

notepad $HOME\.pi\agent\auth.json

Paste this in:

{
  "openrouter": {
    "type": "api_key",
    "key": "sk-or-your-key-here"
  }
}

Get your key here:

https://openrouter.ai/keys

A couple things matter:

  • keep "type": "api_key"
  • keep "key"
  • do not rename it to apiKey

3) Set OpenRouter as the default provider

Now tell Pi to boot into OpenRouter automatically.

Mac / Linux

nano ~/.pi/agent/settings.json

Windows PowerShell

notepad $HOME\.pi\agent\settings.json

Paste 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:

https://openrouter.ai/models


4) Run Pi

Mac / Linux

pi

Windows

Start with:

pi

If PowerShell complains, use:

pi.cmd

If everything worked, Pi should open using OpenRouter by default.


5) Windows fallback if Pi can’t find bash

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.


Useful shortcuts after setup

  • switch models: Ctrl+L or /model
  • cycle scoped models: Ctrl+P
  • change thinking level: Shift+Tab
  • continue last session: pi -c
  • browse older sessions: pi -r
@c4kar

c4kar commented Apr 22, 2026

Copy link
Copy Markdown

Thanks 💚

@bad-ash

bad-ash commented Jun 27, 2026

Copy link
Copy Markdown

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment