Pi

Run Pi against AnyRouter as a custom OpenAI-compatible provider with one key.

Pi reads custom OpenAI-compatible providers from ~/.pi/agent/models.json. Register AnyRouter once to run Pi on any AnyRouter model with one sk-ar- key.

Fastest path

curl -fsSL https://anyrouter.dev/cli.sh | bash
anyr pi

The launcher writes a Pi agent dir (PI_CODING_AGENT_DIR) with AnyRouter in models.json, sets ANYROUTER_API_KEY, and starts pi --provider anyrouter. Use anyr pi --install --ok to install Pi too. Pi has no MCP support, so Auto-connect does not apply.

Manual setup

  1. Create a key in the dashboard and export it (add to ~/.zshrc or ~/.bashrc to persist):

    export ANYROUTER_API_KEY="sk-ar-your-anyrouter-key"
  2. Add AnyRouter to ~/.pi/agent/models.json:

    {
      "providers": {
        "anyrouter": {
          "baseUrl": "https://anyrouter.dev/api/v1",
          "api": "openai-completions",
          "apiKey": "ANYROUTER_API_KEY",
          "models": [
            { "id": "openai/gpt-5.4-mini" },
            { "id": "anthropic/claude-sonnet-4-6" }
          ]
        }
      }
    }

    apiKey is the environment variable name, not the secret. Do not paste your sk-ar- key here.

  3. Run Pi:

    pi --provider anyrouter --model "openai/gpt-5.4-mini"

Add more models from the catalog as entries in models, with the id exactly as listed (for example google/gemini-3.1-flash-lite). The call appears in your request logs.

Troubleshooting

SymptomFix
401 or 403echo $ANYROUTER_API_KEY must print your key, and the key must be active.
Model not foundThe id in Pi must match an AnyRouter model id exactly.
429Pi can send agent calls quickly. Wait for the window to reset or use a key with a higher limit.

AnyRouter routes requests to third-party models. Models and outputs are provided as is, with no warranty; you use them at your own risk. Disclaimer