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

anthropic (default)

vertex-anthropic

The official @anthropic-ai/vertex-sdk, a client per (project, region)

Claude — vertex-anthropic/claude-opus-5-5

google

vertex-gemini

pi’s own Vertex Gemini adapter, handed the project and the entry’s region per call

Gemini — vertex-gemini/gemini-4-hydrogen

openai-compatible

vertex-maas

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: vertex-maas/gpt-oss-120b, grok-4.20-reasoning, grok-4.20-non-reasoning, grok-4.7 …

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

claude-opus-5-5

200

200

quota-0

—

claude-sonnet-5-5

200

200

quota-0

—

claude-sonnet-5

200

200

quota-0

—

claude-opus-5

200

200

quota-0

—

claude-haiku-5-5

200

200

quota-0

not-servable

claude-haiku-4-5

200

quota-0

200

—

gemini-3.8-flash

200

200

not-found

not-found

gemini-3.1-pro-preview

200

not-found

not-found

not-found

gemini-2.5-pro

200

not-found

200

200

gpt-oss-120b

200

not-found

—

200

grok-4.20-reasoning

200

200

—

not-servable

kimi-k2-thinking

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:

  1. $VERTEX_CONFIG (explicit path)

  2. <agentDir>/vertex-models.json (per-user override)

  3. models.json bundled 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

project

"$ANTHROPIC_VERTEX_PROJECT_ID"

GCP project. "$ENV_VAR" form reads the environment (falls back to GOOGLE_CLOUD_PROJECT / GCLOUD_PROJECT); a literal id also works for single-project setups.

models

required

The catalog — see below.

adcRetry

intervalMs 60000, no cap

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; maxWaitMs is the opt-in cap, after which the turn ends on the original error and says it gave up. intervalMs: 0 disables. A session with nobody to re-login (pi -p, --mode json) never retries, whatever this says (#724).

defaults

sensible

Catalog-wide defaults for contextWindow (200 000), maxTokens (64 000), input, and cost, overridable per model.

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

id

required

The pi-facing model id (claude-opus-5-5, gemini-4-hydrogen, gpt-oss-120b). Never contains a slash — pi refs are provider/id.

name

the id

Display name.

region

required

The region your project can call this model in.

publisher

anthropic

anthropic, google, or openai-compatible.

vertexModel

unset

openai-compatible only: the publisher-prefixed string Vertex’s endpoint wants (openai/gpt-oss-120b-maas).

reasoning

google: the catalogue’s, else true; maas: false

google and openai-compatible only. true when the model spends output tokens thinking: the probe sets it for a MaaS model where, having asked with reasoning_effort, it saw a reasoning block, and the battery set it where a model thinks inside its output budget without exposing one (MiniMax M2). Grok reports reasoning apart from output and ships false.

thinkingAllowance

4096 when the entry reasons, else none

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 maxTokens - so the judge’s 300-token verdict from a model that thinks 3 000 first gets both. Measured per model by the battery. Every shipped entry runs on the 4096 default (the heavier thinkers that carried their own number were retired with #381); an entry that thinks longer sets its own.

costUntil

unset

ISO date, the last day cost is right, for an entry on an introductory rate. The unit tests fail from the next day until the rate is flipped, so a lapsed promotion becomes a deliberate edit rather than a silent under-count of session cost; the model-battery page marks such rows (†). Today no entry is on an introductory rate: Gemini 4 Argon and Carbon carried 2026-11-30 and are at their standard rate (#872). Gemini 4 Neon and Hydrogen carry 2027-01-11 for another reason: their rates are standard, and Google bills cache writes on them from the day after (#858).

thinkingWire

unset

google only: "level" sends thinking as a Gemini thinkingLevel (LOW, MEDIUM or HIGH) where pi-ai would send a token thinkingBudget. pi-ai picks the format from the model id and sends a budget for any id it does not recognise as Gemini 3; the four Gemini 4 models refuse every budget ("Thinking budget is not supported for this model") and MINIMAL, so their entries carry this (#381, #811, #858). "level-xhigh" does the same and also offers pi’s xhigh, sent as XHIGH (max with it): Neon and Hydrogen carry it. Argon and Carbon answer 400 to XHIGH and stay on "level", where xhigh and max are sent as HIGH (#859; measured 2026-11-19 through the installed pi, twelve calls, each answered). An entry with either value offers no off and no minimal: the models have neither, and both were LOW under another name (#862; pi 1.6.0 withdraws them itself, so this matters on pi 1.5.x). Asked for anyway (a flag, a mode’s effort), each is clamped to low. A request without a budget passes through untouched, so the field becomes a no-op once pi-ai sends the level itself.

thinking

none

anthropic only: adaptive (every shipped Claude) or none. Refused on other kinds rather than ignored, and any other value (including the retired budget, #952) is refused by name (#407; a typo used to register the model as thinking while every request sent none).

xhigh, offSupported

unset / true

anthropic only; true or false, anything else refused.

temperatureSupported

true

anthropic only. false for a model that answers a non-default temperature with a 400 (every 4.7+ and 5.x Claude, per Anthropic’s thinking page): pi-ai then never sends one, whoever the caller (#357). The judge’s warm-up, which sends temperature: 0 with thinking off, failed on Sonnet 5.5 until this was set.

contextWindow, maxTokens, input, cost

see below

Standard pi model metadata; cost is per-million-token pricing for the cost display and the spend cap.

cost.tiers

unset

Pricing by prompt length (#355): a list of { inputTokensAbove, input, output, cacheRead, cacheWrite }, thresholds ascending. pi-ai prices the whole request at the highest tier whose threshold the request’s input (input, cache read and cache write) exceeds. Claude Haiku 5.5 carries one tier above 100,000 tokens. The loader refuses a threshold that is not a positive integer above the one before, or a rate that is not a non-negative number.

promptCache

anthropic: { "short": 300, "long": 3600 }; google: the installed catalogue’s, if any; maas: unset

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; null turns warming off for the entry; a tier left out is not warmed. Chat entries only. The loader refuses a tier it does not know or a lifetime that is not a positive whole number.

midConvoSystem

unset (false)

Whether the model accepts a system message later in the conversation (#729, #744), which lets pi patch one prompt section - a mode change - and keep the cached prefix. True only where a probe saw it accepted: the shipped catalogue sets it on Opus 5.5, Fable 5.2, Sonnet 5.5 and Haiku 5.5. A model that refuses the message answers 400 role 'system' is not supported on this model (Sonnet 4.6 and Haiku 4.5 did), which would end the turn. Off is safe on every model: the prompt is replayed whole on a change, a cache miss per change and nothing worse. anthropic entries only; the loader refuses it elsewhere.

midConvoEffort

unset (false)

Whether the model takes pi-ai’s managed-effort wire (#746): the thinking level sent as an empty system message before each reply with the top-level effort fixed, and the thinking-binding-controls beta with prefix_mismatch_behavior: "drop_block". Claude Fable 5.2 needs it. It binds each thinking block to the conversation before it, and pi moves that prefix at every mode change, compaction and reload; without drop_block the next request and every one after is 400 …​ The block is bound to a different conversation until the model is switched, and with it the stale block is dropped and the turn answers. Set on Fable 5.2, the one entry probed (as shipped: the same prefix answered, a changed system prompt and a changed earlier message were each refused; with the flag all three answered, and effort low, high and max each answered). Needs midConvoSystem and adaptive thinking; the loader refuses it otherwise. pi-ai puts the effort row before an earlier reply only when the reply carries its own api id, anthropic-messages, and this provider stores replies under vertex-anthropic. Unchecked, every earlier thinking block was dropped on its next use. So such an entry’s call goes to pi-ai under anthropic-messages, for the model and for this provider’s earlier replies, and the reply is tagged vertex-anthropic again on its way back (#908). This stays until pi-ai compares a reply’s api id with the model’s; a contract test fails the day it does.

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

claude-opus-5-5

anthropic

global

Daily driver in auto, manual and yolo, Opus 5’s successor; also the judge’s policy-refusal fallback (#987); thinking cannot be off; effort xhigh and max answer

claude-fable-5-2

anthropic

us

Fable 5.1’s successor (Anthropic, 2026-11-09): 1M context, 128K out, $8.80/$44, cache read $0.22 (us multi-region +10% premium over global’s $8/$40/$0.20, #984); adaptive thinking always on, effort low through max answer; temperature is refused ("deprecated for this model"); takes a mid-conversation system message; binds a thinking block to the conversation before it, so it runs on the managed-effort wire (midConvoEffort, #746). Answers from us the day the project got it; global had no Fable quota (#743, re-verified 2026-11-29). Plan mode’s model and the mode:plan role, in 5.1’s place by the operator’s choice, with 5.1’s reviewer tier; unmeasured until the battery runs it

claude-sonnet-5-5

anthropic

global

Fast general model, $2/$10, cache read $0.10 (#984); the judge (auto and plan, at low), the reviewer floor and the Research helper, Sonnet 5’s successor (#252); also answers from us and eu; thinking cannot be off; effort xhigh and max answer

claude-haiku-5-5

anthropic

us

Small/fast, for high-volume work; the cheapest Claude, priced by prompt length at the us multi-region rate (+10% over global: $0.11/$0.55 up to 100,000 input tokens, $0.55/$2.75 above, carried as cost.tiers, #984); also answers from eu; moved off global, where every call answered 429 on the project’s quota on 2026-11-27 (#949, quota-0 on global 2026-11-29); thinking can be off at effort high or below; effort xhigh and max answer

gemini-4-carbon

google

global

Google’s frontier Gemini 4 (GA 2026-11-10); also us and eu; 1,048,576 tokens for input and output together, 65,536 out per request (Google’s developer guide; pi-ai lists it from pi 1.6.0, with the same figures); thinking sent as a level, since a budget or MINIMAL is a 400; former default commit reviewer and second plan reviewer (#811, superseded by Neon in #1010 and #1035), measured by the battery on 2026-11-19 (#858); $4 in, $20 out, cache read $0.20 (standard rate from 2026-12-01, #872)

gemini-4-neon

google

global

Google’s Gemini 4 between Hydrogen and Carbon (GA 2026-11-18); also us and eu (probed 2026-11-19); 1,048,576 tokens for input and output together, 65,536 out per request (Google’s developer guide; pi-ai lists it from pi 1.6.0, with the same figures); thinking sent as a level, since a budget or MINIMAL is a 400; HIGH is Google’s default and the most pi sends (#859); $3 in, $15 out, cache read $0.15; the default commit reviewer at medium (#1035), default second plan reviewer at high (#1010), and judge stand-in where no Claude is reachable (#942); measured by the battery on 2026-11-19 (#858)

gemini-4-hydrogen

google

global

Google’s fast Gemini 4, the successor it names for 3.8 Flash (GA 2026-11-12); also us and eu (probed 2026-11-19); the same limits, thinking wire and levels as Neon; $1.50 in, $7.50 out, cache read $0.075; the Explore helper (#858) and the compaction fallback (#942); measured by the battery on 2026-11-19 (#858)

gemini-4-argon

google

global

Google’s frontier Gemini (GA 2026-10-13); also us and eu; 1,048,576 tokens for input and output together, 65,536 out per request (Google’s model card; pi-ai lists it too, and pi 1.6.0’s figures are the same); thinking levels LOW, MEDIUM and HIGH only, sent as a level (thinkingWire, #381); $4 in, $20 out, cache read $0.20 (standard rate from 2026-12-01, #872)

gpt-oss-120b

openai-compatible

global

Reasoning block observed; 131k window. Vertex drops the tail of roughly one streamed answer in six (measured; see the file’s //gpt-oss note) - a truncated tool call is a failed tool call

grok-4.20-reasoning, grok-4.20-non-reasoning

openai-compatible

global

Also us; no reasoning block exposed even when asked; 262k window on Vertex, whatever xAI’s sheet says (260k answers, 300k is refused)

grok-4.7

openai-compatible

global

xAI’s newest (#427); also us; reasons, but exposes no reasoning block; $2/$6 up to 200K input, double above; 360k window on Vertex (371k answers, 425k is refused; Google’s card says 524k). A Google Preview on a fixed quota shared by the whole project: 20 requests and 21,000 output tokens a minute, so one busy session can meet it and pi retries the refusals

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), from global, 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

gemini-nano-banana-2.1

~$0.034

11 s

Nano Banana 2.1; generate_image’s default; thinks first

gemini-3.1-flash-image

~$0.067

8 s

Nano Banana 2

gemini-3.1-flash-lite-image

~$0.034

3 s

fastest; answers in JPEG

gemini-3-pro-image

~$0.134

17 s

Nano Banana Pro, highest quality; thinks first

gemini-2.5-flash-image

~$0.039

5 s

the original Nano Banana; also from us-central1; may say a line of text beside the image

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 login rewrites 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 under CLOUDSDK_CONFIG, else %APPDATA%\gcloud on Windows or ~/.config/gcloud elsewhere (#408; CLOUDSDK_CONFIG was 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.maxWaitMs caps it. Configure with adcRetry. 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, with gcloud auth application-default login named 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 a pi -p that 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 injects compat.forceAdaptiveThinking — without it pi-ai silently falls back to a 1024-token budget and drops the effort.

  • "offSupported": false for anthropic models that reject disabled thinking (Fable 5.2, Opus 5.5, Sonnet 5.5). Haiku 5.5 accepts it at effort high or 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, plus XHIGH on level-xhigh entries). Thinking off is raised to low before the adapter sees it: pi-ai’s disabled config sends THINKING_LEVEL_MINIMAL or thinkingBudget: 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; low is 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’s reasoning column measured.

  • openai-compatible, the system prompt: always sent as role system. pi-ai would send developer for a reasoning model on a host its compat probe does not recognise, and some vendors behind the endpoint (MiniMax M2, Qwen3-Next) drop a developer message unread; system is 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 a reasoning_content field (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.ts and contract.test.ts pin 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 /model

Another extension owns that provider id (only one may). Check pi --list-models. For vertex-anthropic on an install that logged in before publishers existed, see "Auth and login".

no GCP project resolvable

Set "project" in the config or export ANTHROPIC_VERTEX_PROJECT_ID.

Your override seems ignored — the models and regions are the packaged catalog’s

The pre-publisher names are not read at all: $VERTEX_ANTHROPIC_CONFIG and ~/.pi/agent/vertex-anthropic-models.json are silently passed over (no alias, no error). Rename to $VERTEX_CONFIG / vertex-models.json.

403 “data sharing … publisher 'anthropic'”

Enable data_sharing_enabled_provider=anthropic (setPublisherModelConfig), or pin the model to a region where it is already satisfied.

429 that never clears

Quota for that (model, region) is 0 — request quota or re-pin (see probe).

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 global (and some from us) — pin there.

"thinking" … apply to anthropic entries only

You put an Anthropic thinking switch on a google or maas entry; use reasoning for those kinds.

Thinking seems ignored (anthropic)

"thinking" is unset (defaults to none) — set "thinking": "adaptive" on the entry.

A 400 on every turn right after /model, and /compact is a 400 too

The context no longer fits the new model and pi’s recovery runs on that same model. /new starts fresh; or switch back and /compact there. The modes extension warns at the switch and offers to do the second for you (session.adoc#_switching_to_a_model_the_context_does_not_fit).

400 on a Gemini entry only with thinking off

Vertex refuses thinking off for Gemini; the extension raises it to low (see Thinking mapping). An override catalog cannot change that — an old extension can: update @gadhs/pi.

Thinking seems ignored (maas)

That vendor does not expose a reasoning block; the probe’s column said so and the entry carries reasoning: false.

A reasoning model defers every judge call, or a small-budget caller only ever gets length

The model spends the caller’s output budget thinking. Set reasoning: true on the entry and, if the default 4096 is not enough, a thinkingAllowance sized to what it thinks (the battery’s records show it).

Edit this page · latest