Skip to content

pi

Install the Vidai package for pi and every model your key may call appears under Vidai in pi's model picker. Every call it makes is governed: checked against your policies, charged to your team and recorded in Request logs. Claude, Gemini and GPT models each get their provider's own format, so prompt caching and reasoning work as the provider made them.

What it is

pi is an open-source coding agent for the terminal. It reads and edits the files in your project and runs commands, asking a model what to do next at each step. It calls the gateway from your machine.

The Vidai package, @vidaiuk/pi-provider, adds Vidai to pi as a provider. It's open source (Apache 2.0, github.com/vidaiUK/pi-provider) and short enough to read before you install it, as with any pi extension, since it runs with your permissions.

Install

pi install npm:@vidaiuk/pi-provider

To try it once without installing:

pi -e npm:@vidaiuk/pi-provider

The settings

Set two variables in your shell:

export VIDAI_BASE_URL="https://<your-gateway>"   # with or without /v1
export VIDAI_API_KEY="vk_…"
Variable Value
VIDAI_BASE_URL The gateway's address, with or without /v1: the package works out the address each format needs
VIDAI_API_KEY Your Vidai key (starts vk_), never a provider's key

The gateway's address is under Connect your app on the Keys page and in System › Settings › Gateway; the key comes from Keys › Issue a key (its secret is shown once).

A minimal call

pi -p --model vidai/gpt-4.1 "Reply with exactly: ok"

In the terminal interface, pick a model under Vidai in /model. pi --list-models vidai lists them.

Model names

The package asks the gateway for its list (GET /v1/models, with your key), so you see exactly the models your key may call, your organisation's aliases included. Approve a model under Models in the Control room and it appears in pi. If the gateway can't be reached when pi starts, a short built-in list stands in.

Context window, output limit, image input and reasoning come from pi's own model catalogue; a model it doesn't know gets safe defaults.

Which format each model gets

The package works out each model's provider from its name and speaks that provider's own format to the gateway:

Models Format Address the package uses
Claude Anthropic Messages https://<your-gateway> (pi adds /v1/messages)
Gemini Gemini API https://<your-gateway>/v1beta
OpenAI's models (GPT, o-series) OpenAI Responses https://<your-gateway>/v1
Anything else OpenAI Chat Completions https://<your-gateway>/v1

A name that doesn't say what the model is (an Azure deployment, an alias such as team-coder) gets Chat Completions, which the gateway translates to any provider. That works, but without the provider's own prompt caching. Name the format yourself:

export VIDAI_MODEL_FORMATS="team-coder=anthropic-messages,prod-gpt=openai-responses"

The formats are anthropic-messages, openai-responses, google-generative-ai and openai-completions.

Streaming

pi streams every step, in the format the model gets. Stopping pi mid-answer ends the call; Request logs record it with the tokens used so far.

Tool calls

pi's steps (read, write, edit, bash) are tool calls, and they work on every provider. A session can move from Claude to GPT and back and keep working. Use a model that is good at tool use; small models tend to stall on long tasks.

Reading what the gateway did

pi doesn't show response headers. Look the calls up in Request logs: filter on Key, Model or Path. One task usually shows as many calls, one per step.

Errors

What pi shows What to do
vidai: couldn't list models … 401 The key is wrong, unset or revoked: check VIDAI_API_KEY
… check VIDAI_BASE_URL pi can't reach the gateway: check the address and that you're on the right network
403 model_not_allowed Your key may not call that model: ask your Vidai admin
403 content_guardrail_blocked A guardrail stopped the content; the message says which
429 A limit on the key or team

The full list is in Headers and errors.

What goes through the gateway

pi feature Through the gateway
Every step of a session, interactive or with -p Yes
Thinking levels (--thinking) Yes, on models that reason; for the gpt-5 family, "off" is sent as "minimal"
Images Yes, on models that read them
MCP servers and extensions you add to pi The model calls that use their tools, yes; the servers themselves are reached directly by pi

Check it works in a minute

Run the minimal call above, then open Request logs a few seconds later and filter on your key: the call is there, with its model, its team and its cost.

Without the package

If you can't install from npm, describe Vidai in ~/.pi/agent/models.json yourself. You list the models by hand, and each provider entry speaks one format:

{
  "$schema": "https://pi.dev/schemas/models.schema.json",
  "providers": {
    "vidai": {
      "name": "Vidai",
      "baseUrl": "https://<your-gateway>/v1",
      "api": "openai-completions",
      "apiKey": "$VIDAI_API_KEY",
      "models": [
        { "id": "gpt-4.1", "contextWindow": 1047576, "maxTokens": 32768 },
        { "id": "claude-sonnet-4.5", "contextWindow": 200000, "maxTokens": 64000, "input": ["text", "image"] }
      ]
    }
  }
}

apiKey takes $NAME to read an environment variable, so the key stays out of the file; baseUrl takes the address as written. api decides the format:

api Format the gateway receives baseUrl
openai-completions (start here) OpenAI Chat Completions, /v1/chat/completions https://<your-gateway>/v1
openai-responses OpenAI Responses, /v1/responses https://<your-gateway>/v1
anthropic-messages Anthropic Messages, /v1/messages https://<your-gateway> (no /v1: pi adds it)

All three reach every provider the gateway serves. Give each model its contextWindow and maxTokens (pi assumes 128,000 and 16,384 otherwise), "input": ["text", "image"] for models that read images and "reasoning": true for models that think. Pick the model with /model, which also reloads the file.

Good to know

  • pi shows $0 for Vidai models: the package leaves prices to Vidai, so you don't see two different totals. Your organisation's cost for each call is in Request logs and on the Cost page.
  • Autonomous tasks are chatty: set a limit on the key (or the team's budget) so a runaway task stops at a known cost.
  • Issue one key per developer, so Request logs and cost reports show whose pi made each call.
  • The package works with Vidai 1.0.0-rc.3 and later and pi 1.4 and later.
  • Docs: the package's README, pi.dev (packages and models.json).