pi integration is currently in beta. Some features may not work, some may only work with certain models.
Why Use Concentrate with pi?
pi is an open-source coding agent for the terminal that accepts any OpenAI- or Anthropic-compatible API as a custom provider. By routing pi through Concentrate, you use models from every provider in our catalog with one API key, and get centralized visibility and control over your team’s usage: spend tracking, budget limits, and everything visible in your Concentrate dashboard in real time.What Works
Prerequisites
- A Concentrate AI account with an active API key (starts with
sk-cn) - pi installed (
npm install -g @mariozechner/pi-coding-agent)
Quick Setup
Bash
CONCENTRATE_PI_API_KEY, so pi can use a different key from your other tools. If you already have CONCENTRATE_API_KEY set, it asks whether to reuse it. It also adds every model on Concentrate to ~/.pi/agent/models.json, with its price, context window, image support and thinking levels. Other providers in that file are kept. Re-run it to pick up new models and prices.
Then restart your terminal (or source your shell profile) and start pi in a project directory:
Manual Setup
If you prefer to configure pi manually or the script doesn’t work for your environment:1
Set your API key
Add the following to your shell profile (Then reload your shell:
~/.bashrc, ~/.zshrc, etc.):2
Add Concentrate to ~/.pi/agent/models.json
Create or edit Add any model from the supported models page using its
~/.pi/agent/models.json. The apiKey value is the name of the environment variable, not the key itself:provider/model ID. Set "reasoning": true for models that think, "input": ["text", "image"] for models that accept images, and "cost" (per million tokens) to see prices in pi.3
Verify the connection
Check that pi sees the models, then start it in a project directory:Switch models at any time with
/model.Other API formats
We recommend the Responses API (openai-responses) shown above. pi can also use our Chat Completions and Messages APIs, which are in beta. Add them as extra providers in the same file:
Tips
- Thinking levels. pi’s thinking levels map to
reasoning.effort. The setup script hides levels a model doesn’t support. In a manual config, Concentrate uses the closest supported level instead. For example, Gemini 3.8 Flash can’t turn thinking off, so “off” runs atlow. xhigh. pi sendsxhighashighby default. The setup script sendsxhighfor models that support it. In a manual config, add"thinkingLevelMap": { "xhigh": "xhigh" }to the model entry.- Costs. pi’s cost uses the standard price. Peak-hour, long-context and priority pricing are billed at their own rates, so the Concentrate dashboard is the source of truth for spend.
- After pressing Esc. pi drops the interrupted turn from history. If the model keeps going back to the old task, say so explicitly or start a new session.
Remove Concentrate AI
Bash
concentrate provider from models.json. Other providers are kept.
Troubleshooting
401 Invalid API key
401 Invalid API key
- Check the variable is set:
echo $CONCENTRATE_PI_API_KEY - Check
apiKeyinmodels.jsonis the variable’s name ("CONCENTRATE_PI_API_KEY"), not$CONCENTRATE_PI_API_KEY.
400 Invalid request: model
400 Invalid request: model
The model ID isn’t one Concentrate knows. Use the exact
provider/model ID from the supported models page.402 Insufficient funds
402 Insufficient funds
Your balance is empty. Add funds on the billing page.
Model doesn't appear in /model
Model doesn't appear in /model
pi re-reads
models.json each time you open /model. Check the file is valid JSON and the model is under the concentrate provider.Setup says "pi could not load the Concentrate models"
Setup says "pi could not load the Concentrate models"
The script keeps your other providers in
models.json as they are. If one of them is invalid, pi skips the whole file, Concentrate included, and the script shows pi’s error. Fix or remove the provider it names, then re-run the script. The script saves a backup (models.json.backup.*) next to the file each time it runs. If you edit models.json by hand later, pi --list-models shows the same error.
