Models on Vertex AI (@gadhs/pi-vertex)
Exposes the models a project can call on Google Cloud Vertex AI to pi, with
two properties the stock providers lack: per-model region routing and a
static, editable JSON catalog. Auth is Application Default Credentials
throughout — no API keys, no gcloud subprocess at request time, and no
/login: every kind appears in /model on install.
The credential lookup is handed the project the config names, so
google-auth-library does not search for one (#831, #832): without it the library
ran gcloud config config-helper and then probed the cloud metadata server,
two to three seconds before a request went out. The Anthropic client and the
MaaS and image bearer are given the project directly. pi’s own Gemini adapter
builds its client per request and takes none, so at load pi-vertex sets
google_cloud_project in its process environment, unless GCLOUD_PROJECT or
GOOGLE_CLOUD_PROJECT (either case) is already set. Programs the agent starts
inherit it. On Windows a native program finds it under either case,
GOOGLE_CLOUD_PROJECT included, while a Git Bash script sees only the
lower-case name (seen on the Windows box).
(Published as @gadhs/pi-vertex-anthropic through 0.6.0; the provider ids
and the config file did not change with the rename.)
Vertex is optional (#714). On a box with no GCP project set (no project
in the config, and none of ANTHROPIC_VERTEX_PROJECT_ID,
GOOGLE_CLOUD_PROJECT or GCLOUD_PROJECT), pi-vertex registers no
providers and says so once a session, at info level. The rest of the
distribution loads and runs on pi’s own logins, such as an Anthropic API
key, a Claude subscription or Google AI Studio. A malformed
vertex-models.json still fails the load, because that is a config written
wrong, not the absence of Vertex.
One file, three publisher kinds
A catalog entry names its publisher kind, and the kind decides which
provider id the model is registered under and which wire the extension
delegates to. Nothing is reimplemented at the wire: each kind hands the
request to code that already speaks that protocol, and owns only the
routing — the region pin, the credential, the retry. Every other option a
caller sets (toolChoice, a stream observer, telemetry, sampling, provider
env) reaches that code as pi-ai’s own adapter would pass it: the
anthropic kind dropped them until #406, and the google kind replaced a
caller’s env with the pin rather than merging the pin into it.
publisher |
Provider id | Wire | Models |
|---|---|---|---|
|
|
The official |
Claude — |
|
|
pi’s own Vertex Gemini adapter, handed the project and the entry’s region per call |
Gemini — |
|
|
pi’s OpenAI-completions adapter against Vertex’s OpenAI-compatible endpoint, with a bearer minted from ADC |
The Model-as-a-Service models Vertex serves on that endpoint:
|
Not every Model-as-a-Service model is on the OpenAI-compatible endpoint.
Vertex serves Mistral’s models (Mistral Medium 3, Mistral Small 3.1,
Codestral 2) and AI21’s Jamba as publisher models through rawPredict, in
us-central1 and europe-west4, and no kind speaks that wire yet (#387).
They are not MaaS candidates: there they would answer 404 whether or not a
project had them enabled (#386).
A fourth publisher kind is a fourth row here, not a new way to configure.
Why per-model regions
On Vertex, “a region hosts a model” is not “your project can call it
there”: availability and quota are granted per (project, model, region),
whoever publishes the model. A real project measured on 2026-09-07 (the
two 5.5-era Claude rows on 2026-09-22, the day Model Garden enablement
landed for them; Haiku 5.5 on 2026-10-08). Read
the SHAPE, not the cells: no single region serves everything, and grants
change per project and over time. node probe.mjs prints this for yours,
which is the only authoritative version; it takes its token from the
gcloud on PATH (on Windows the SDK’s gcloud.cmd, through the shell,
#985). Some rows are models the catalog
has dropped since (#381, #942); they stay for the shape.
| Model | global |
us |
us-east5 |
us-central1 |
|---|---|---|---|---|
|
200 |
200 |
quota-0 |
— |
|
200 |
200 |
quota-0 |
— |
|
200 |
200 |
quota-0 |
— |
|
200 |
200 |
quota-0 |
— |
|
200 |
200 |
quota-0 |
not-servable |
|
200 |
quota-0 |
200 |
— |
|
200 |
200 |
not-found |
not-found |
|
200 |
not-found |
not-found |
not-found |
|
200 |
not-found |
200 |
200 |
|
200 |
not-found |
— |
200 |
|
200 |
200 |
— |
not-servable |
|
200 |
not-found |
— |
not-servable |
Each entry pins its own region. For the anthropic kind the SDK owns the
region→host mapping, including the us/eu multi-region
.rep.googleapis.com hosts; the maas kind uses the same table
(vertex-host.mjs, shared with the probe, because us-aiplatform… answers
400 for a multi-region); the google kind’s SDK derives its own host from
the location, and agreed with the table on every cell above.
Status meanings: 200 usable (the only status to wire in) · quota-0 HTTP
429 whose message is Vertex’s “Quota exceeded” (quota grant is zero; it
never clears) · throttled any other 429, still refused after two retries
over twenty seconds (shared capacity: the model is served and callable;
probe again later) · data-sharing 403 until the project enables data
sharing for that publisher · not-servable 400 · not-found 404. Before
#385 every 429 read as quota-0, and a callable preview model (Gemma 4 26B
MaaS, throttled at global) was reported unusable.
Configuration
Config resolution order:
-
$VERTEX_CONFIG(explicit path) -
<agentDir>/vertex-models.json(per-user override) -
models.jsonbundled with the package (the org default)
Pre-publisher installs used vertex-anthropic-models.json and
$VERTEX_ANTHROPIC_CONFIG; those names are gone, not aliased — rename the
file.
Top-level fields
| Field | Default | Meaning |
|---|---|---|
|
|
GCP project. |
|
required |
The catalog — see below. |
|
|
Auth-expiry behaviour for every
kind: how often to retry a turn that failed on expired Google auth. By
default it retries for as long as the turn is alive — your escape is what
ends it; |
|
sensible |
Catalog-wide defaults for |
Unknown keys at the top level, in any model entry, or in adcRetry,
defaults, cost, cost.tiers[], imageCost, or promptCache are
refused at load by name (#1042). Keys beginning with // are accepted as
comments at the top level and in model entries (not inside nested blocks).
Per-model fields
| Field | Default | Meaning |
|---|---|---|
|
required |
The pi-facing model id ( |
|
the id |
Display name. |
|
required |
The region your project can call this model in. |
|
|
|
|
unset |
openai-compatible only: the publisher-prefixed string
Vertex’s endpoint wants ( |
|
google: the catalogue’s, else |
google and
openai-compatible only. |
|
|
google and
openai-compatible only. Tokens the model spends thinking before it answers,
added to whatever output budget a caller asks for and capped at |
|
unset |
ISO date, the last day |
|
unset |
google only: |
|
|
anthropic only: |
|
unset / |
anthropic only; |
|
|
anthropic only. |
|
see below |
Standard pi model
metadata; |
|
unset |
Pricing by prompt length (#355): a list of
|
|
anthropic: |
The publisher’s prompt-cache
lifetimes in seconds per retention tier (#726), which pi’s cache warming
reads (Prompt-cache warming). An anthropic entry carries Anthropic’s two
published lifetimes unless it sets its own; |
|
unset (false) |
Whether the model accepts a |
|
unset (false) |
Whether the model takes pi-ai’s
managed-effort wire (#746): the thinking level sent as an empty |
Where the numbers come from: an anthropic entry uses the file, then
defaults. A google entry whose id the installed pi-ai’s Vertex catalogue
lists inherits its contextWindow, maxTokens, cost and thinking-level
map from there (the operator’s pi is the source, so a new Gemini appears
when pi updates); the file overrides any of it; an unlisted id gets the
file’s values or defaults, never a neighbour’s numbers. A maas entry uses
the file, then defaults.
Every packaged entry carries a real rate. test/unit.test.ts refuses a
zero-cost entry on any kind (pi would report its cost as zero forever) and
checks Anthropic’s multipliers on the anthropic kind, in every tier; Google’s and the MaaS
publishers' rates are cited in the file’s //cost-* notes. An entry on an
introductory rate carries costUntil, and the same tests fail the day
after it.
Prompt-cache warming
Anthropic keeps a prompt-cache entry for five minutes by default and an
hour on the extended tier, and charges a cache write at 25 times a cache
read (Opus 5.5: $5 against $0.20 per MTok). A session that pauses longer
than the lifetime - a battery, a helper, a monitor, the human away - pays
the write again for its whole context on the next turn. pi can keep the
entry alive instead: just before it would expire it re-sends the request
with a one-token output cap, a cache read’s worth, during a long tool run
and between runs too when cacheWarming is "idle" (pi’s default from
1.5.1, and what pi-modes seeds on 1.5.0; tuning). It refreshes only
while the expected saving clears pi’s threshold, and stops after an hour
in a run or half an hour idle.
pi warms nothing for a model that declares no lifetime, and before #726
no Vertex model did: in one week-long session on this catalogue, 383 of
4,910 turns re-wrote the whole cache after a pause, $1,180 of $1,746. So
every anthropic entry declares Anthropic’s two lifetimes by default - the
lifetime is the API’s, not a model’s, which is why it is a kind default
rather than a line per entry, and why a catalogue a team generates with
the probe gets it too. A google entry
inherits whatever the installed pi-ai’s Vertex catalogue lists for the id
(nothing today: Gemini publishes no implicit-cache lifetime); a MaaS entry
declares none. /session shows the warmer’s next decision and its
economics; each refresh is a cache_warm usage row in the session.
The shipped catalog
(The Kind column is the entry’s publisher; the probe’s --publisher
maas selects the openai-compatible kind.)
| Model | Kind | Region | Notes |
|---|---|---|---|
|
anthropic |
|
Daily driver in auto, manual and yolo, Opus 5’s successor; also the judge’s policy-refusal fallback (#987); thinking cannot be off; effort |
|
anthropic |
|
Fable 5.1’s successor (Anthropic, 2026-11-09): 1M context, 128K out, $8.80/$44, cache read $0.22 ( |
|
anthropic |
|
Fast general model, $2/$10, cache read $0.10 (#984); the judge (auto and plan, at |
|
anthropic |
|
Small/fast, for high-volume work; the cheapest Claude, priced by prompt length at the |
|
|
Google’s frontier Gemini 4 (GA 2026-11-10); also |
|
|
|
Google’s Gemini 4 between Hydrogen and Carbon (GA 2026-11-18); also |
|
|
|
Google’s fast Gemini 4, the successor it names for 3.8 Flash (GA 2026-11-12); also |
|
|
|
Google’s frontier Gemini (GA 2026-10-13); also |
|
|
openai-compatible |
|
Reasoning block observed; 131k window. Vertex drops the tail of roughly one streamed answer in six (measured; see the file’s |
|
openai-compatible |
|
Also |
|
openai-compatible |
|
xAI’s newest (#427); also |
contextWindow and maxTokens are what Vertex accepts, measured, not
the vendor’s sheet. A window claimed larger than the real one deadlocks a
session: pi cannot compact on a model the context does not fit
(session.adoc#_switching_to_a_model_the_context_does_not_fit), and
over-window errors from the OpenAI-compatible endpoint are not reliably
recognised as overflows, so the catalog being right is the real defence.
The numbers were taken with tools/window-probe.mjs (repository tooling,
not shipped; Local Development), which is also how to retake them.
Not shipped, as of the 2026-10-22 refresh (#381):
-
Answer, but short-lived: Gemini 3.6 Flash (Google retires it 2026-11-19), and the preview MaaS models DeepSeek V4.1 Flash and GLM 5.2 (Google guarantees them only to 2026-11-28 and 2026-10-31).
-
Answer, but preview: Gemma 4 26B A4B IT on the MaaS endpoint (
google/gemma-4-26b-a4b-it-maas; Google promises a preview 45 days), fromglobal, sometimes throttled (#386). -
Current per Google, not callable by the agency’s project yet: Grok 4.3 and 4.6 (enabled per project in Model Garden), Llama 4 Maverick and Scout, Muse Spark 1.3 and OpenAI’s GPT-6 models (gated previews); tracked in #382.
-
Current per Google, no kind for them: Mistral and AI21 (above; #387).
-
Removed: Gemini 2.5 Pro (retired by Google 2026-10-20), Kimi K2 Thinking, Qwen3 Coder 480B, Qwen3-Next-80B Thinking, Qwen3 235B and MiniMax M2 (retired 2026-10-21, Google’s open-model deprecations page), and Grok 4.1 Fast (shut down 2026-08-20).
The probe looks for the first two groups and finds them the moment a project can call them; the removed models are no longer probe candidates.
Removed 2026-11-27, superseded (#942): Claude Opus 4.8, Fable 5.1, Sonnet
4.6 and Haiku 4.5; Gemini 3.8, 3.7 and 3.5 Flash, 3.5 and 3.1 Flash-Lite and
3.1 Pro Preview. Google and Anthropic still serve them, and the probe still
looks for them: to keep one, list it in your own catalog
(start from a copy of the shipped one). The
commit reviewer still ranks them, so a session on one through pi’s own
anthropic or google provider is reviewed as before.
The provider reads the catalog once, when pi starts: restart pi after editing it.
Image models (Nano Banana)
Google’s chat models produce only text on the API. Image generation is a
separate family, "Nano Banana" (#481). pi’s chat messages carry only text,
thinking and tool calls, so pi treats image generation as its own model
operation: image models are not in /model. They are reached through
codemode’s models.generateImages(), an extension’s
ctx.modelRegistry.generateImages(), and pi-modes' generate_image tool
(tools.adoc#generate-image).
The catalog ships five, each tested with a real generation on 2026-10-26,
all from global:
| Model | Per 1K image | Time | Notes |
|---|---|---|---|
|
~$0.034 |
11 s |
Nano Banana 2.1; generate_image’s default; thinks first |
|
~$0.067 |
8 s |
Nano Banana 2 |
|
~$0.034 |
3 s |
fastest; answers in JPEG |
|
~$0.134 |
17 s |
Nano Banana Pro, highest quality; thinks first |
|
~$0.039 |
5 s |
the original Nano Banana; also from |
An image entry carries "type": "image", its output modalities, and
two output rates. cost.output is the image output rate, and
imageCost.textOutput is the rate for text and thinking, which Google
prices apart. Each reply is priced from Google’s per-modality token
counts, so the session total is exact. The implementation calls
generateContent with image output requested, on the same ADC login as
chat, with one re-fetch on a stale token’s 401. It skips the thinking
parts of the reply, and keeps each image once and in its own format.
Google’s safety refusals come back as errors that say so. The
-preview ids in Google’s docs return not-found; the catalog uses the GA
ids.
Credential expiry (ADC rotation and retry)
Two behaviours cover an expired ADC session (agency reauth policy), together, for every kind:
-
Rotation pickup. Every attempt re-resolves its credential: the anthropic kind’s cached clients are fingerprinted against the ADC file, the google kind’s adapter reads ADC per request, and the maas kind mints its bearer inside the attempt. Re-running
gcloud auth application-default loginrewrites the file, and the next request uses it — no pi restart. The file watched is the one google-auth-library reads, in its order:GOOGLE_APPLICATION_CREDENTIALS, else underCLOUDSDK_CONFIG, else%APPDATA%\gcloudon Windows or~/.config/gcloudelsewhere (#408;CLOUDSDK_CONFIGwas ignored before, so a second gcloud profile’s re-login was missed). -
Turn retry. A request that fails on expired auth is re-issued on a timer instead of killing the turn: re-login in another terminal and the turn resumes by itself - for as long as the turn is alive, unless
adcRetry.maxWaitMscaps it. Configure withadcRetry. Auth failures happen at connection, before any content streams, so a retry never duplicates output; non-auth errors propagate immediately. A turn that ends in an error is never announced as a resume: with a cap that closed, the notice says how long it waited and that it gave up; another error stops the retry and says so; after your escape nothing is said. A session with nobody to re-login does not retry at all (#724): where pi has no UI and the session is not a helper’s (pi -p,--mode json), the notice has nowhere to show and no escape can end the wait, so the turn ends at once on the auth error, withgcloud auth application-default loginnamed in it. A helper keeps the retry: the person at its caller can log in again. A call begun before the session has said who the host is (the judge’s warm-up at start) can still take the retry path; its wait never holds pi open by itself, so api -pthat has printed its error exits then, not a minute later. The re-login itself is exercised live (test/adc-relogin.live.test.ts): a copy of the credential with a dead refresh token fails the attempt, is rewritten good while the pump waits, and the same turn completes on the next poll. -
One immediate refetch (maas). The bearer is cached per process until two minutes before expiry and single-flight; a 401 on a cached token is refetched once and the request replayed before any event reaches pi, so the consumer sees one stream. A 401 on a fresh token is the timer’s business.
Discovering availability (probe.mjs)
Each team probes their own project and generates their catalog:
It ships beside the catalog (~/.pi/agent/npm/node_modules/@gadhs/pi/dist/assets/@gadhs/pi-vertex/probe.mjs
on a default install; packages/pi-vertex/probe.mjs in this repository):
node probe.mjs # every kind, env project, default lists
node probe.mjs --publisher google # one kind: anthropic | google | maas | all
node probe.mjs --discover # add what Model Garden lists to the packaged candidates
node probe.mjs --json # the suggested entries as JSON
With --discover the probe reads each publisher’s Model Garden catalog
from the global and the us-central1 endpoint (most publishers list only
on the regional one for the agency’s project) and probes what it lists on
top of the packaged candidates: a MaaS listing counts when its id ends in
-maas (Google’s Gemma included) or a partner’s catalog calls it
proprietary, never a self-deploy listing, Google’s own proprietary
listings (embeddings, vision), or a Mistral or AI21 listing (#386).
The catalog does not name every callable model - Llama 4 Scout is listed
only as its family - so discovery adds and never replaces; a kind whose
catalogs list nothing says so on stderr (#381).
It prints one status matrix per kind and suggested models entries
pinning each model to the first region that returned a real HTTP 200, with
publisher and vertexModel filled in. For the maas kind it also asks for
reasoning and reads the reply, marking reasoning: true only where a block
came back. Every cost in the suggestion is a placeholder zero — the probe
cannot infer pricing — so fill in the publisher’s rates before an entry
goes into your catalog (start from a copy of
the shipped one), or it misreports session cost.
Thinking mapping
-
anthropic
adaptive(every Claude in the catalog):thinking.type: "adaptive"+output_config.effort; pi levels map minimal/low→low, medium→medium, high→high, xhigh/max→xhigh iff"xhigh": true(else clamped to high). The extension injectscompat.forceAdaptiveThinking— without it pi-ai silently falls back to a 1024-token budget and drops the effort. -
"offSupported": falsefor anthropic models that reject disabled thinking (Fable 5.2, Opus 5.5, Sonnet 5.5). Haiku 5.5 accepts it at efforthighor below, and pi sends no effort with thinking off, so it keeps the default. -
google: pi’s level goes through pi-ai’s Gemini adapter (
LOW/MEDIUM/HIGH, plusXHIGHonlevel-xhighentries). Thinking off is raised tolowbefore the adapter sees it: pi-ai’s disabled config sendsTHINKING_LEVEL_MINIMALorthinkingBudget: 0, and Vertex refuses both on Gemini 4 (and older Gemini 2.5 Pro), so every Gemini turn with thinking off was a 400 — including compaction, which runs thinking off. Off is not a thing these models offer;lowis the floor here for the whole kind. -
openai-compatible: pi’s level goes through as
reasoning_effort; whether the vendor honours it is what the probe’sreasoningcolumn measured. -
openai-compatible, the system prompt: always sent as role
system. pi-ai would senddeveloperfor a reasoning model on a host its compat probe does not recognise, and some vendors behind the endpoint (MiniMax M2, Qwen3-Next) drop adevelopermessage unread;systemis the role every vendor honoured when probed. -
openai-compatible,
<think>in the content: a vendor that opens its answer with a literal<think>tag instead of areasoning_contentfield (MiniMax M2) has it lifted into a thinking block as the stream passes — up to</think>, or to the end if unclosed — and its own earlier turns get the tag put back on the way in, because pi-ai replays an unsigned thinking block as nothing and the model needs its reasoning in the history. Text that does not open with the tag passes untouched.think-tags.test.tsandcontract.test.tspin both directions.
What every message is stamped with
pi keys three things on the model stamped on an assistant message
equalling the session model’s id: overflow recovery (skipped as "a
different model’s error" otherwise), session restore (which looks the stamp
up and falls back to the default model when it is not a registered id), and
the cost lookup. pi-ai’s adapters stamp what they were handed or what the
API answered with - the Vertex string for a MaaS model
(openai/gpt-oss-120b-maas), the API’s dated name for Claude
(claude-haiku-4-5-20251001, written over at message_start) - neither of
which is the id here. So every kind’s stream is restamped with the
pi-facing id before pi sees an event; the wire’s name is kept in
responseModel, the field pi’s usage totals already prefer.
The way back is the inverse (#239). pi-ai reads a replayed assistant turn as the model’s own only when provider, api and model match what it was handed. A MaaS model’s earlier turns, stamped with the pi-facing id, reached the adapter beside the Vertex string, and their reasoning was flattened into the answer text on every turn after the first. The MaaS kind now replays this model’s own turns under the id it hands pi-ai.
Auth and login
ADC sources: gcloud auth application-default login, a service-account JSON
via GOOGLE_APPLICATION_CREDENTIALS, or GCE/GKE workload identity. Each kind
is registered with a literal adc placeholder key — pi’s documented way to
mark a keyless provider configured — so every kind is in /model on install
with no /login. The oauth sentinel from before publishers is kept beside
it: a developer who logged in then has a stored record, and pi lets a stored
record win, so without the sentinel that provider would vanish from
/model. No kind forwards the placeholder: anthropic ignores it (own
client), google strips it, maas replaces it with the bearer. If ADC is
missing, requests fail with a clear google-auth-library error.
pi’s own built-in google-vertex provider is left alone. A developer who
also configures it (env or /login) sees Gemini twice, under two ids;
harmless.
Troubleshooting
| Symptom | Fix |
|---|---|
A provider missing from |
Another extension owns that provider id (only one may). Check
|
|
Set |
Your override seems ignored — the models and regions are the packaged catalog’s |
The pre-publisher names are not read at all: |
403 “data sharing … publisher 'anthropic'” |
Enable |
429 that never clears |
Quota for that |
400 “not servable in region X” / 404 on a Gemini or MaaS model |
Model not offered there; the newer Gemini and every MaaS model answer
from |
|
You put an Anthropic thinking switch on a google or maas entry; use
|
Thinking seems ignored (anthropic) |
|
A 400 on every turn right after |
The context no longer fits the new model and pi’s recovery runs on that
same model. |
400 on a Gemini entry only with thinking off |
Vertex refuses thinking off for Gemini; the extension raises it to |
Thinking seems ignored (maas) |
That vendor does not expose a reasoning block; the probe’s column said so
and the entry carries |
A reasoning model defers every judge call, or a small-budget caller only
ever gets |
The model spends the caller’s output budget thinking. Set |