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:
npx vercel ai-gateway setup --agent piThis 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.jsonwhen that variable is set) under thevercel-ai-gatewayprovider key, with owner-only (0600) permissions. - Backs up any file it changes alongside the original as
.bak. Add--dry-runto preview changes without writing them.
The Vercel CLI configures Pi but doesn't install it. Install Pi before starting it:
npm install -g @earendil-works/pi-coding-agentRun the command without --agent to detect and configure every installed supported agent at once:
vercel ai-gateway setupFor 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.
Install the Pi coding agent from npm:
Terminalnpm install -g @earendil-works/pi-coding-agentGo to the AI Gateway section in the Vercel dashboard sidebar and click API keys to create a new API key.
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:
Terminalchmod 600 ~/.pi/agent/auth.jsonStart Pi and choose a gateway model with
/model, or name one when you launch:Terminalpi --model anthropic/claude-opus-5Model IDs use the gateway's
creator/model-nameformat. Browse the models catalog for what's available.
- Browse the models catalog for available models
- Read Pi's own provider documentation
- Configure spend limits on your API key
- Connect your other agents with the Vercel CLI
Was this helpful?