{"slug": "how-we-govern-pi-a-minimal-coding-agent-without-changing-it", "title": "How we govern pi, a minimal coding agent, without changing it", "summary": "Vidai co-founder and CTO Nagu Gopalakrishnan published @vidaiuk/pi-provider, an Apache 2.0 open-source package that routes every model call from the pi coding agent through a Vidai gateway, where cost, data and regulation rules apply, without modifying pi itself. The provider fetches the model list from the gateway via GET /v1/models, uses each provider's native API format (Anthropic Messages for Claude, Gemini API under /v1beta, OpenAI Responses under /v1, OpenAI Chat Completions for everything else), and requires Vidai 1.0.0-rc.3 or later and pi 1.4 or later. Gopalakrishnan said the gateway is the right place for governance because model calls are where code, prompts and data leave the machine and where the money goes, and pi's own README states it has no built-in permission system for the filesystem, processes, network or credentials.", "body_md": "# How we govern pi, a minimal coding agent, without changing it.\n\n[Nagu Gopalakrishnan](https://vidaicontrol.com/blog/author/nagu/)· Co-founder and CTO\n\n· 5 min read\n\nInstall `@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.\n\n## Why do we use pi?\n\nWe 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.\n\nOnce 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.\n\n## What does pi leave to you?\n\npi 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.\n\nThe 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.\n\n## What does the provider package do?\n\n`@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:\n\n- 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;\n- 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;\n- uses each provider's own API format, chosen from the model name.\n\n| Models | Format | Address used | \n|---|---|---|\n| Claude | Anthropic Messages | `https://<your-gateway>` | \n| Gemini | Gemini API | `https://<your-gateway>/v1beta` | \n| OpenAI (GPT, o-series) | OpenAI Responses | `https://<your-gateway>/v1` | \n| Anything else | OpenAI Chat Completions | `https://<your-gateway>/v1` | \n\nUsing 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:\n\n```\nexport VIDAI_MODEL_FORMATS=\"team-coder=anthropic-messages,prod-gpt=openai-responses\"\n```\n\nThe package runs with your permissions, so read it before you install it: [github.com/vidaiUK/pi-provider](https://github.com/vidaiUK/pi-provider).\n\n## How do you set it up?\n\nInstall the package, or try it once without installing:\n\n```\npi install npm:@vidaiuk/pi-provider\n# or, for a single run\npi -e npm:@vidaiuk/pi-provider\n```\n\nSet two variables. The key is a Vidai key (it starts with `vk_`), not a provider key:\n\n```\nexport VIDAI_BASE_URL=\"https://<your-gateway>\"   # with or without /v1\nexport VIDAI_API_KEY=\"vk_...\"\n```\n\nThen make a test call:\n\n```\npi -p --model vidai/gpt-4.1 \"Reply with exactly: ok\"\n```\n\nIn 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.\n\n## What does governance look like in practice?\n\nEvery 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:\n\n- **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` .\n- **Models you haven't approved** come back as`403 model_not_allowed` .\n- **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.\n- **Every call is in Request logs** , filterable by key, model or path, with the cost of each call there and on the Cost page.\n\nThinking levels, images and tool calls work on the models that support them.\n\n## Do local models get governed too?\n\nYes, 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.\n\nIn 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.\n\n## Can you keep it in the UK or EU?\n\nYes. 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.\n\n## What are the limits?\n\n- pi shows $0 for Vidai models, because prices are left to Vidai. The real cost is in Request logs.\n- pi doesn't show response headers.\n- Stopping pi mid-answer ends the call; Request logs record the tokens used so far.\n- MCP servers and extensions are reached directly by pi. Only the model calls that use their tools go through the gateway.\n- 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.\n\n## Try it\n\nThe full guide, including setting pi up without the package, is in the docs: [pi integration](https://docs.vidaicontrol.com/integrations/coding/pi/). If you don't have a gateway yet, the [Community Edition install](https://docs.vidai.uk/get-started/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](https://vidaicontrol.com/blog/control-room-rc4-codex-any-model/).\n\n## FAQ\n\n**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.\n\n**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.\n\n**Can I use it without the package?** Yes. Describe Vidai as a provider in `~/.pi/agent/models.json`; the docs have a complete example.\n\n**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.\n\n**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.", "url": "https://wpnews.pro/news/how-we-govern-pi-a-minimal-coding-agent-without-changing-it", "canonical_source": "https://vidaicontrol.com/blog/govern-pi-coding-agent/", "published_at": "2026-12-02 09:00:00+00:00", "updated_at": "2026-12-02 09:13:11.447575+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "ai-policy", "developer-tools", "ai-infrastructure"], "entities": ["Vidai", "Nagu Gopalakrishnan", "pi", "@vidaiuk/pi-provider", "Anthropic", "OpenAI", "Google Gemini"], "also_reported_by": [], "takeaway": "Installing @vidaiuk/pi-provider and setting VIDAI_BASE_URL and a vk_ key routes every pi model call through a Vidai gateway, with VIDAI_MODEL_FORMATS (e.g. \"team-coder=anthropic-messages\") needed to pin the API format for aliases whose names don't reveal the model.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/how-we-govern-pi-a-minimal-coding-agent-without-changing-it", "markdown": "https://wpnews.pro/news/how-we-govern-pi-a-minimal-coding-agent-without-changing-it.md", "text": "https://wpnews.pro/news/how-we-govern-pi-a-minimal-coding-agent-without-changing-it.txt", "jsonld": "https://wpnews.pro/news/how-we-govern-pi-a-minimal-coding-agent-without-changing-it.jsonld"}}