Skip to content
Docs

Pi with AI Gateway

Pi is an open-source terminal coding agent. It ships a first-class vercel-ai-gateway provider, so it already knows the gateway's base URL and model catalog and only needs your API key.

Run the Vercel CLI setup command for Pi:

terminal
npx vercel ai-gateway setup --agent pi

This command:

  • Provisions an AI Gateway API key, or reuses one you pass with --key.
  • Writes the key to Pi's auth file (~/.pi/agent/auth.json, or $PI_CODING_AGENT_DIR/auth.json when that variable is set) under the vercel-ai-gateway provider key, with owner-only (0600) permissions.
  • Backs up any file it changes alongside the original as .bak. Add --dry-run to preview changes without writing them.

The Vercel CLI configures Pi but doesn't install it. Install Pi before starting it:

terminal
npm install -g @earendil-works/pi-coding-agent

Pi always keeps the key in auth.json, so the command writes it there even in macOS Keychain mode. Pi reads its agent directory from $PI_CODING_AGENT_DIR when that variable is set, and falls back to ~/.pi/agent otherwise.

Run the command without --agent to detect and configure every installed supported agent at once:

terminal
vercel ai-gateway setup

For the full command reference, see vercel ai-gateway.

To verify the setup, start Pi and choose a gateway model with /model (or --model), then confirm your requests appear in the AI Gateway Overview in the Vercel dashboard.

Only needed on machines where you can't use the Vercel CLI.

  1. Install the Pi coding agent from npm:

    Terminal
    npm install -g @earendil-works/pi-coding-agent
  2. Go to the AI Gateway section in the Vercel dashboard sidebar and click API keys to create a new API key.

  3. Pi keeps credentials in ~/.pi/agent/auth.json. Add an entry for the gateway provider:

    ~/.pi/agent/auth.json
    {
      "vercel-ai-gateway": {
        "type": "api_key",
        "key": "your-ai-gateway-api-key"
      }
    }

    The file holds a secret, so create it with owner-only permissions:

    Terminal
    chmod 600 ~/.pi/agent/auth.json

    Pi reads its agent directory from $PI_CODING_AGENT_DIR when that variable is set, and falls back to ~/.pi/agent otherwise.

  4. Start Pi and choose a gateway model with /model, or name one when you launch:

    Terminal
    pi --model anthropic/claude-opus-5

    Model IDs use the gateway's creator/model-name format. Browse the models catalog for what's available.

Last updated September 13, 2026

Was this helpful?

supported.