How we govern pi, a minimal coding agent, without changing it.
· 5 min read
Install @vidaiuk/pi-provider, set two variables, and every model call pi makes goes through your Vidai gateway, where your cost, data and regulation rules apply. That includes local models on your own hardware, not just the hosted ones. pi itself doesn't change. The provider is open source under Apache 2.0, and it's the same setup we use for our own work.
Why do we use pi?
We use pi for our own development. It's a small, terminal-first coding agent: it reads and edits files in your project, runs commands, and asks a model what to do at each step. It's quick to start, easy to extend, and it doesn't try to decide which model you should use. That last part matters to us, because we don't either.
Once we were running it daily, we wanted it under the same rules as every other AI tool in the company. So we wrote a provider, and now we've published it.
What does pi leave to you?
pi is minimal on purpose. Its own README says it has no built-in permission system for the filesystem, processes, network or credentials, and points you to sandboxing if you need stronger boundaries. That's a sensible split: the harness stays small, and you choose the boundaries.
The model calls are the part that leaves your machine, with your code, your prompts and sometimes your data inside them. They're also where the money goes. That makes them the natural place for governance, and the natural place for that is the gateway, not the agent.

What does the provider package do?
@vidaiuk/pi-provider adds Vidai to pi as a provider. Once it's installed, the models your key is allowed to call appear under Vidai in pi's model picker. The package:
- fetches the model list from the gateway (
GET /v1/models, using your key), including your organisation's aliases. If the gateway can't be reached at start-up, it falls back to a short built-in list; - takes context window, output limit, image input and reasoning settings from pi's own model catalogue, with safe defaults for models it doesn't know;
- uses each provider's own API format, chosen from the model name.
| Models | Format | Address used |
|---|---|---|
| Claude | Anthropic Messages | https://<your-gateway> |
| Gemini | Gemini API | https://<your-gateway>/v1beta |
| OpenAI (GPT, o-series) | OpenAI Responses | https://<your-gateway>/v1 |
| Anything else | OpenAI Chat Completions | https://<your-gateway>/v1 |
Using the native format keeps each provider's own features, such as prompt caching, working through the gateway. For aliases whose names don't show the model, such as team-coder, you can set the format yourself:
export VIDAI_MODEL_FORMATS="team-coder=anthropic-messages,prod-gpt=openai-responses"
The package runs with your permissions, so read it before you install it: github.com/vidaiUK/pi-provider.
How do you set it up?
Install the package, or try it once without installing:
pi install npm:@vidaiuk/pi-provider
# or, for a single run
pi -e npm:@vidaiuk/pi-provider
Set two variables. The key is a Vidai key (it starts with vk_), not a provider key:
export VIDAI_BASE_URL="https://<your-gateway>" # with or without /v1
export VIDAI_API_KEY="vk_..."
Then make a test call:
pi -p --model vidai/gpt-4.1 "Reply with exactly: ok"
In the interface, use /model to pick a Vidai model, or list them with pi --list-models vidai. You need Vidai 1.0.0-rc.3 or later and pi 1.4 or later.
What does governance look like in practice?
Every step of a pi session, interactive or with -p, is a call through the gateway. Each one is checked against your policies, charged to your team and recorded. In day-to-day use that looks like this:
- One key per developer. Reports then show whose pi made each call. Add a key limit or a team budget to stop a runaway task; when it's reached, pi gets a
429. - Models you haven't approved come back as
403 model_not_allowed. - Content your guardrails block, such as personal data your policy doesn't allow to leave, comes back as
403 content_guardrail_blocked. Where your policy masks or pseudonymises instead, the task carries on without the raw values reaching the model. - Every call is in Request logs, filterable by key, model or path, with the cost of each call there and on the Cost page.
Thinking levels, images and tool calls work on the models that support them.
Do local models get governed too?
Yes, and this is the part people often miss. "It runs on our own GPUs" makes a local model feel safe by default, but a local model still sees whatever code and data a developer sends it, still uses capacity someone pays for, and still needs a record if anyone asks what happened.
In Vidai a local model is just another provider behind the gateway. Add an open model running on your own hardware, give it an alias such as team-coder, and pi calls it exactly like a hosted one. The same budgets, guardrails, allow-lists and request logs apply, so a local model is governed like every other model rather than becoming a gap in your records.
Can you keep it in the UK or EU?
Yes. pi doesn't mind where a model runs, which makes it a good fit for sovereign setups. Point your aliases at models hosted in the UK or EU, or at local models on your own hardware, and refuse the regions you haven't approved. Developers keep the same picker and the same workflow; the gateway decides where their code and prompts are allowed to go, and the record of every call stays in your own database.
What are the limits?
- pi shows $0 for Vidai models, because prices are left to Vidai. The real cost is in Request logs.
- pi doesn't show response headers.
- Stopping pi mid-answer ends the call; Request logs record the tokens used so far.
- MCP servers and extensions are reached directly by pi. Only the model calls that use their tools go through the gateway.
- Autonomous tasks make one call per step, so long tasks make many calls. Tool use also needs a capable model, as small models tend to stall on long tasks.
Try it
The full guide, including setting pi up without the package, is in the docs: pi integration. If you don't have a gateway yet, the Community Edition install gets you one in a few minutes. For the other coding tools and models the gateway translates for, see Control Room rc.4: Codex on any model.
FAQ
Do I have to change how I use pi? No. You pick a Vidai model in the usual picker and work as before. The rules apply in the gateway.
Are local models governed the same way as hosted ones? Yes. A local model sits behind the gateway like any other provider, with the same budgets, guardrails, allow-lists and logs.
Can I use it without the package? Yes. Describe Vidai as a provider in ~/.pi/agent/models.json; the docs have a complete example.
Does the package send anything to Vidai? No. It talks only to your own gateway, using your key. The source is public, so you can check.
Which pi steps go through the gateway? Every model call. MCP servers and extensions that pi reaches directly do not, though the model calls that use their tools do.