Skip to main content
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
The script saves your API key to your shell profile as 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 (~/.bashrc, ~/.zshrc, etc.):
Then reload your shell:
2

Add Concentrate to ~/.pi/agent/models.json

Create or edit ~/.pi/agent/models.json. The apiKey value is the name of the environment variable, not the key itself:
Add any model from the supported models page using its 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:
For anthropic-messages, leave /v1 off the baseUrl. pi adds /v1/messages itself.

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 at low.
  • xhigh. pi sends xhigh as high by default. The setup script sends xhigh for 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
This removes the API key from your shell profile and the concentrate provider from models.json. Other providers are kept.

Troubleshooting

  1. Check the variable is set: echo $CONCENTRATE_PI_API_KEY
  2. Check apiKey in models.json is the variable’s name ("CONCENTRATE_PI_API_KEY"), not $CONCENTRATE_PI_API_KEY.
The model ID isn’t one Concentrate knows. Use the exact provider/model ID from the supported models page.
Your balance is empty. Add funds on the billing page.
pi re-reads models.json each time you open /model. Check the file is valid JSON and the model is under the concentrate provider.
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.
Last modified on October 9, 2026