@ssweens/pi-vertex 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [1.4.0] - 2026-11-20
6
+
7
+ ### Added
8
+ - Gemini 4 Neon (`gemini-4-neon`): 1M combined context, 65,536 foreground output cap, text/image input, tools, and LOW through XHIGH thinking. Global prices are $3/$15 per 1M input/output tokens, with $0.15 cached input. Non-global prices are 10% higher.
9
+ - DeepSeek V4.1 Flash 1017 (`deepseek-v4.1-flash-1017`): 1M context, text/image input, tools, and the original Flash's reasoning levels. $0.30/$1.20 per 1M input/output tokens; cached input is $0.006.
10
+ - Grok 4.20 Non-Reasoning (`grok-4.20-non-reasoning`): text/image input and tools without thinking, using the existing Grok Chat Completions route.
11
+ - Six OpenAI Private Preview models: `gpt-6.2-astra`, `gpt-6.2-sol`, `gpt-6-astra`, `gpt-6.1-sol`, `gpt-6.1-terra`, and `gpt-6-luna`. All use Vertex's OpenAI publisher Responses endpoint, with 1,050,000 combined context and 128,000 max output tokens. Costs are estimates from OpenAI's public Standard API rates; Vertex billing uses the customer's Marketplace private offer.
12
+ - Catalog and GPT Responses regression coverage for routing, reasoning effort, payload hooks, stateless encrypted tool replay, and Muse compatibility.
13
+
14
+ ### Changed
15
+ - GPT Responses requests omit unsupported reasoning summaries and request encrypted reasoning at every thinking level. Terra and Luna can disable reasoning with `none`; Astra and Sol use the provider default at `off`.
16
+ - Gemini streaming honors `costRegional` when supplied, including Neon's non-global rates.
17
+ - The registry now contains 58 models.
18
+
5
19
  ## [1.3.0] - 2026-11-15
6
20
 
7
21
  ### Added
package/README.md CHANGED
@@ -11,22 +11,22 @@ export GOOGLE_CLOUD_PROJECT=your-project-id
11
11
  export GOOGLE_APPLICATION_CREDENTIALS=/path/to/key.json
12
12
  ```
13
13
 
14
- Set your GCP project and credentials. Vertex AI models (Gemini, Claude, Grok, Meta Muse and Llama, DeepSeek, Mistral, and others) appear in pi's model selector, billed through your GCP project.
14
+ Set your GCP project and credentials. Vertex AI models (Gemini, Claude, OpenAI GPT, Grok, Meta Muse and Llama, DeepSeek, Mistral, and others) appear in pi's model selector, billed through your GCP project.
15
15
 
16
16
  ## Features
17
17
 
18
- - **49 models** across 4 categories:
19
- - **Gemini** (14): 4 Hydrogen, 4 Carbon, 4 Argon, 3.8 Flash, 3.7 Flash, 3.6 Flash, 3.5 Flash, 3.5 Flash-Lite, 3.1 Pro, 3.1 Flash-Lite, 3 Flash, 2.5 Pro, 2.5 Flash, 2.5 Flash-Lite
18
+ - **58 models** across 4 categories:
19
+ - **Gemini** (15): 4 Neon, 4 Hydrogen, 4 Carbon, 4 Argon, 3.8 Flash, 3.7 Flash, 3.6 Flash, 3.5 Flash, 3.5 Flash-Lite, 3.1 Pro, 3.1 Flash-Lite, 3 Flash, 2.5 Pro, 2.5 Flash, 2.5 Flash-Lite
20
20
  - **Claude** (18): Fable 5.2, Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.1, Opus 5, Sonnet 5, Fable 5, Opus 4.8, Opus 4.7, Opus 4.6, Sonnet 4.6, Opus/Sonnet/Haiku 4.5, Opus 4.1, Opus 4, Sonnet 4
21
21
  - **Meta** (5): Muse Wonder 1.0, Muse Spark 1.3, Muse Ember 1.0, Llama 4 Maverick, Llama 4 Scout
22
- - **Other MaaS** (10): Grok 4.7, Grok 4.6, Grok 4.3, Grok 4.20, DeepSeek V4.1 Flash, Mistral (4), OpenAI GPT-OSS 120B, Gemma 4, GLM 5.2
22
+ - **Other MaaS** (20): OpenAI GPT-6 (6), Grok (5, including 4.20 Non-Reasoning), DeepSeek V4.1 Flash and Flash 1017, Mistral (4), OpenAI GPT-OSS 120B, Gemma 4, GLM 5.2
23
23
 
24
24
  - **Unified streaming**: Single provider, multiple model families
25
25
  - **Full tool calling support**: All models with multi-turn tool use and proper tool result handling
26
- - **Thinking/reasoning**: Gemini 3/4 thinking levels (including XHIGH on Gemini 4 Hydrogen), Gemini 2.5 thinking budgets, per-model reasoning effort for Claude, Muse, and DeepSeek, thought signature preservation
26
+ - **Thinking/reasoning**: Gemini 3/4 thinking levels (including XHIGH on Gemini 4 Neon and Hydrogen), Gemini 2.5 thinking budgets, per-model reasoning effort for Claude, OpenAI GPT, Muse, and DeepSeek, thought signature preservation
27
27
  - **Automatic auth**: Uses Google Application Default Credentials
28
28
  - **Region awareness**: Global endpoints where supported, regional where required
29
- - **Pricing tracking**: Built-in cost per token for all models (including thinking tokens and regional endpoint premiums)
29
+ - **Pricing tracking**: Token cost tracking includes thinking tokens and supported regional premiums. GPT-6 rates are public-API estimates, not Vertex private-offer prices.
30
30
 
31
31
  ## Installation
32
32
 
@@ -92,15 +92,17 @@ pi --provider vertex --model claude-fable-5-2
92
92
  pi --provider vertex --model claude-haiku-5-5
93
93
  pi --provider vertex --model grok-4.7
94
94
  pi --provider vertex --model glm-5.2
95
+ pi --provider vertex --model gemini-4-neon
95
96
  pi --provider vertex --model gemini-4-hydrogen
96
97
  pi --provider vertex --model gemini-4-argon
97
98
  pi --provider vertex --model gemini-3.8-flash
98
99
  pi --provider vertex --model muse-wonder-1.0
99
100
  pi --provider vertex --model llama-4-maverick
100
- pi --provider vertex --model deepseek-v4.1-flash
101
+ pi --provider vertex --model deepseek-v4.1-flash-1017
102
+ pi --provider vertex --model gpt-6.2-sol
101
103
 
102
104
  # With options
103
- pi --provider vertex --model gemini-4-hydrogen --thinking xhigh
105
+ pi --provider vertex --model gemini-4-neon --thinking xhigh
104
106
  ```
105
107
 
106
108
  ### Shell alias (recommended)
@@ -127,6 +129,7 @@ alias pil="GOOGLE_CLOUD_PROJECT=your-project pi --provider vertex --model llama-
127
129
 
128
130
  | Model | Context | Max Tokens | Input | Reasoning | Price (in/out) |
129
131
  |-------|---------|------------|-------|-----------|----------------|
132
+ | gemini-4-neon | 1M | 65,536 | text, image | ✅ | $3.00/$15.00 |
130
133
  | gemini-4-hydrogen | 1M | 65,536 | text, image | ✅ | $1.50/$7.50 |
131
134
  | gemini-4-carbon | 1M | 65,536 | text, image | ✅ | $2.00/$10.00 |
132
135
  | gemini-4-argon | 1M | 65,536 | text, image | ✅ | $2.00/$10.00 |
@@ -144,7 +147,9 @@ alias pil="GOOGLE_CLOUD_PROJECT=your-project pi --provider vertex --model llama-
144
147
 
145
148
  `gemini-4-argon` and `gemini-4-carbon` use introductory pricing of $2.00/$10.00 per 1M tokens (cached input $0.10) through 2026-11-30, rising to $4.00/$20.00 after. Argon supports "long decode" up to 1M output tokens; this extension uses the default 65,536 synchronous limit. `gemini-4-carbon` is a Frontier Model available only to verified enterprise customers.
146
149
 
147
- `gemini-4-hydrogen` is a short-term release: Google retires it with 45 days' notice. Its 1M token limit covers input and output together. It is the only Gemini model that accepts the `xhigh` thinking level.
150
+ [`gemini-4-neon`](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/gemini/4-neon) is a Frontier Model with a unified 1M input/output limit. This extension uses the 65,536-token foreground segment limit, not long decode. Global input/output prices are $3.00/$15.00 per 1M tokens, with $0.15 cached input; non-global prices are $3.30/$16.50, with $0.165 cached input. Cost tracking uses the endpoint's rates.
151
+
152
+ `gemini-4-hydrogen` is a short-term release: Google retires it with 45 days' notice. Its 1M token limit covers input and output together. Neon and Hydrogen accept the `xhigh` thinking level.
148
153
 
149
154
  Gemini 4 models reject the MINIMAL thinking level, so pi does not offer `minimal` for them.
150
155
 
@@ -202,15 +207,29 @@ The Muse models are in Preview. They run only on the global endpoint and only th
202
207
  | mistral-ocr | 30 pages | mistralai | $0.0005/page | global |
203
208
  | codestral-2 | 128K | mistralai | $0.30/$0.90 | global |
204
209
  | deepseek-v4.1-flash | 1M | deepseek-ai | $0.30/$1.20 | global |
210
+ | deepseek-v4.1-flash-1017 | 1M | deepseek-ai | $0.30/$1.20 | global |
211
+ | gpt-6.2-astra | 1,050K | openai | $8.00/$40.00 (estimate) | global |
212
+ | gpt-6.2-sol | 1,050K | openai | $2.00/$10.00 (estimate) | global |
213
+ | gpt-6-astra | 1,050K | openai | $10.00/$50.00 (estimate) | global |
214
+ | gpt-6.1-sol | 1,050K | openai | $2.00/$10.00 (estimate) | global |
215
+ | gpt-6.1-terra | 1,050K | openai | $1.00/$5.00 (estimate) | global |
216
+ | gpt-6-luna | 1,050K | openai | $0.10/$0.50 (estimate) | global |
205
217
  | gpt-oss-120b | 131K | openai | $0.09/$0.36 | global |
206
218
  | glm-5.2 | 1M | zai-org | $1.40/$4.40 | global |
207
219
  | grok-4.7 | 524K | xai | $2.00/$6.00 | global |
208
220
  | grok-4.6 | 524K | xai | $2.00/$6.00 | global |
209
221
  | grok-4.3 | 1M | xai | $1.25/$2.50 | global |
210
222
  | grok-4.20-reasoning | 1M | xai | $1.25/$2.50 | global |
223
+ | grok-4.20-non-reasoning | 1M | xai | $1.25/$2.50 | global |
211
224
  | gemma-4-26b-a4b-it | 262K | google | $0.15/$0.60 | global |
212
225
 
213
- `deepseek-v4.1-flash` accepts text and image input. It thinks only when a reasoning effort is set (`minimal` to `high`, or `max`); at thinking level `off` it answers without thinking.
226
+ `deepseek-v4.1-flash` and `deepseek-v4.1-flash-1017` accept text and image input. They think only when a reasoning effort is set (`minimal` to `high`, or `max`); at thinking level `off` they answer without thinking. Flash 1017 cached input costs $0.006 per 1M tokens, compared with $0.03 for the original Flash.
227
+
228
+ [OpenAI GPT-6 models](https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/partner-models/openai) require Private Preview access, a Marketplace private offer, and Model Garden enablement with the Advanced AI Safety Addendum. They use the publisher Responses API, not Chat Completions. They accept text and images, support tools, and have a 1,050,000-token combined context (922,000 max input, 128,000 max output). Use `GOOGLE_CLOUD_LOCATION=global`.
229
+
230
+ GPT-6 reasoning levels are `low`, `medium`, `high`, `xhigh`, and `max`. At `off`, Astra and Sol use the model default; Terra and Luna send `none` to disable reasoning. Requests omit reasoning summaries and preserve encrypted reasoning for tool replay. `store: false` makes requests stateless; it does **not** enable Zero Data Retention, which requires separate project approval.
231
+
232
+ **GPT-6 cost estimates:** Google does not list these models on its public partner-pricing page. Displayed costs use [OpenAI's public Standard API model rates](https://developers.openai.com/api/docs/models), at up to 272K input tokens. Your Vertex private-offer prices can differ. Long-context surcharges and explicit cache-write charges are not tracked.
214
233
 
215
234
  **Retired:** Google shut down these open model endpoints on 2026-10-21, and they have been removed: `deepseek-v3.2`, `deepseek-v3.1`, `deepseek-r1`, `deepseek-ocr`, `qwen3-235b`, `qwen3-next-instruct`, `qwen3-next-thinking`, `qwen3-coder`, `gpt-oss-20b`, `kimi-k2-thinking`, `minimax-m2`, `glm-5`, `glm-4.7`, and `llama-3.3-70b`. `grok-4.1-fast-reasoning` was shut down on 2026-08-20 and has also been removed.
216
235
 
package/TEST_COVERAGE.md CHANGED
@@ -1,10 +1,23 @@
1
1
  # Test Coverage
2
2
 
3
3
  ## Current Status
4
- - Automated tests: `npm test` runs `tests/first-byte-timeout-check.mjs`. It covers a dead stream, a slow-starting stream, and keepalive stripping on the Chat Completions URL. Since v1.3.0 it also covers a dead stream on the publisher Responses API URL (Muse). Against the v1.2.7 filter, that new case hangs instead of failing fast.
5
- - Lint/type checks: `npm run check` is still a no-op placeholder. `tsc --noEmit` (TypeScript 5) passes clean as of v1.3.0.
4
+ - Automated tests: `npm test` runs two files. `tests/first-byte-timeout-check.mjs` covers a dead stream, a slow-starting stream, and keepalive stripping on Chat Completions, plus dead streams on Meta and OpenAI publisher Responses URLs. `tests/model-catalog-check.mjs` checks new model metadata, unique IDs, supported thinking levels, GPT Responses routing and payload hooks, encrypted tool replay, and unchanged Muse requests. Catalog/request tests use synthetic SSE and stubbed authentication; they make no network requests.
5
+ - Lint/type checks: `npm run check` remains a no-op. `bunx --package typescript@5.9.3 tsc --noEmit` passes for v1.4.0.
6
6
 
7
7
  ## Manual Verification
8
+
9
+ ### v1.4.0 additions (2026-11-20)
10
+ - The registry loads 58 models with unique IDs. Pi 0.99.1's `-ne -e ./index.ts --list-models` shows all nine added IDs.
11
+ - Live two-turn tool round trips through `streamVertex` passed on the global endpoint. Each model called `lookup_probe`, received its result, and returned the marker:
12
+ - `gemini-4-neon`: `xhigh` and unsupported `minimal` (floored to LOW).
13
+ - `deepseek-v4.1-flash-1017`: off and `max`.
14
+ - `grok-4.20-non-reasoning`: off.
15
+ - Regression: `muse-ember-1.0` at `minimal`.
16
+ - Neon on the `us` endpoint returned `NEON_US_OK`. Its reported usage cost matched the regional $3.30/$16.50 rates exactly.
17
+ - Pi end-to-end, with explicit `-e ./index.ts`, `--no-session`, and no tools: Neon at `xhigh` returned `NEON_PI_OK`; DeepSeek 1017 at `max` returned `DEEPSEEK_PI_OK`; Grok Non-Reasoning returned `GROK_PI_OK`.
18
+ - Direct API probes confirmed DeepSeek 1017 accepts `minimal` and `max`, and rejects `xhigh` and `none` with HTTP 400.
19
+
20
+ ### Earlier releases
8
21
  - Claude 4.6 streaming verified via Anthropic Vertex SDK.
9
22
  - Mid-session model switching (tool call replay) verified interactively in pi.
10
23
  - Registry sanity checks verified locally for `claude-opus-4-8` and `grok-4.3` after model additions.
@@ -26,9 +39,10 @@
26
39
  - Direct API probes confirmed the reasoning effort values each model accepts. Muse Wonder and Spark accept minimal..xhigh, and Muse Ember adds max; all three reject `none`. DeepSeek V4.1 Flash accepts minimal/low/medium/high/max and rejects `xhigh` and `none`. All 16 removed ids return HTTP 404.
27
40
 
28
41
  ## Gaps / Next Steps
42
+ - **No OpenAI GPT-6 live request succeeded.** Global publisher Responses probes returned HTTP 429 for `gpt-6.2-astra` and `gpt-6.2-sol`, and HTTP 404 (not found or no project access) for `gpt-6-astra`, `gpt-6.1-sol`, `gpt-6.1-terra`, and `gpt-6-luna`. Routing, payload compatibility, and encrypted replay are verified with synthetic responses, not live inference. Limits come from Google's model pages; displayed cost estimates come from OpenAI's public API model pages, not a Vertex private offer.
29
43
  - **No live request has succeeded against `claude-fable-5-2`, `claude-haiku-5-5`, or `grok-4.7`.** All three return HTTP 404 ("not found or your project does not have access") because they are not enabled in the test project's Model Garden. Their API ids, limits, and prices come from the Google Cloud model pages and the pricing page.
30
44
  - No live request has been made against `gemini-3.7-flash`, `gemini-3.6-flash`, `gemini-3.5-flash-lite`, `claude-opus-5-5`, `claude-fable-5-1`, `claude-opus-5`, or `claude-sonnet-5`.
31
45
  - Promotion of `gemini-3.1-flash-lite` off its `-preview` API id is likewise unverified against a live endpoint.
32
46
  - Add automated integration tests for Anthropic Vertex streaming and tool replay.
33
47
  - Add unit tests for message normalization and replay sequencing.
34
- - Add a catalog regression test so retired model ids cannot silently linger in the registry again.
48
+ - Extend the catalog regression test to check retired model IDs.
package/models/gemini.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  * Pricing: https://cloud.google.com/vertex-ai/generative-ai/pricing
5
5
  * All prices per 1M tokens (standard tier, <= 200K input tokens)
6
6
  * Verified against the Vertex AI model catalog on 2026-10-13; Gemini 4 entries
7
- * re-verified against the Gemini Enterprise Agent Platform catalog on 2026-11-15.
7
+ * re-verified against the Gemini Enterprise Agent Platform catalog on 2026-11-20.
8
8
  */
9
9
 
10
10
  import type { ThinkingLevelMap } from "@earendil-works/pi-ai";
@@ -19,8 +19,37 @@ export const GEMINI_MODELS: VertexModelConfig[] = [
19
19
  // 65536 is the per-segment streaming limit, consistent with the rest of the catalog.
20
20
  // Implicit caching only; durable caching is on by default.
21
21
 
22
+ // GA 2026-11-18, Google Frontier Model. LOW/MEDIUM/HIGH (default)/XHIGH.
23
+ // Single-segment output cap on GenerateContent v1; input and output share 1M.
24
+ {
25
+ id: "gemini-4-neon",
26
+ name: "Gemini 4 Neon",
27
+ apiId: "gemini-4-neon",
28
+ publisher: "google",
29
+ endpointType: "gemini",
30
+ contextWindow: 1048576,
31
+ maxTokens: 65536,
32
+ input: ["text", "image"],
33
+ reasoning: true,
34
+ tools: true,
35
+ cost: {
36
+ input: 3.00,
37
+ output: 15.00,
38
+ cacheRead: 0.15,
39
+ cacheWrite: 0,
40
+ },
41
+ costRegional: {
42
+ input: 3.30,
43
+ output: 16.50,
44
+ cacheRead: 0.165,
45
+ cacheWrite: 0,
46
+ },
47
+ region: "global",
48
+ thinkingLevelMap: { ...GEMINI_4_THINKING, xhigh: "xhigh" },
49
+ },
50
+
22
51
  // GA 2026-11-12, short-term release (45-day retirement notice). Thinking levels
23
- // LOW/MEDIUM/HIGH (default)/XHIGH — the only Gemini model that accepts XHIGH.
52
+ // LOW/MEDIUM/HIGH (default)/XHIGH.
24
53
  // Cache writes ($1.875/1M) bill from 2027-01-12; Gemini streams report no
25
54
  // cache-write tokens, so cacheWrite stays 0.
26
55
  {
package/models/maas.ts CHANGED
@@ -92,6 +92,26 @@ export const MAAS_MODELS: VertexModelConfig[] = [
92
92
  region: "global",
93
93
  },
94
94
 
95
+ {
96
+ id: "grok-4.20-non-reasoning",
97
+ name: "Grok 4.20 Non-Reasoning",
98
+ apiId: "grok-4.20-non-reasoning",
99
+ publisher: "xai",
100
+ endpointType: "maas",
101
+ contextWindow: 1000000,
102
+ maxTokens: 32000,
103
+ input: ["text", "image"],
104
+ reasoning: false,
105
+ tools: true,
106
+ cost: {
107
+ input: 1.25,
108
+ output: 2.50,
109
+ cacheRead: 0.20,
110
+ cacheWrite: 0,
111
+ },
112
+ region: "global",
113
+ },
114
+
95
115
  // --- Meta Muse (Preview) ---
96
116
  // Served only through the stateless OpenAI-compatible Responses API on the
97
117
  // global endpoint (no chat completions, no `store: true`). Input and output
@@ -306,6 +326,160 @@ export const MAAS_MODELS: VertexModelConfig[] = [
306
326
  thinkingLevelMap: { max: "max" },
307
327
  },
308
328
 
329
+ {
330
+ id: "deepseek-v4.1-flash-1017",
331
+ name: "DeepSeek V4.1 Flash 1017",
332
+ apiId: "deepseek-ai/deepseek-v4.1-flash-1017-maas",
333
+ publisher: "deepseek-ai",
334
+ endpointType: "maas",
335
+ contextWindow: 1048576,
336
+ maxTokens: 65536,
337
+ input: ["text", "image"],
338
+ reasoning: true,
339
+ tools: true,
340
+ cost: {
341
+ input: 0.30,
342
+ output: 1.20,
343
+ cacheRead: 0.006,
344
+ cacheWrite: 0,
345
+ },
346
+ region: "global",
347
+ thinkingLevelMap: { max: "max" },
348
+ },
349
+
350
+ // --- OpenAI GPT (Private Preview) ---
351
+ // Responses API only, stateless with encrypted reasoning replay.
352
+ // Prices below are estimates from OpenAI's public Standard API model pages:
353
+ // https://developers.openai.com/api/docs/models (<= 272K input tokens).
354
+ // Vertex billing is governed by the customer's Marketplace private offer;
355
+ // Google does not publish GPT-6 rates on its partner-model pricing page.
356
+ {
357
+ id: "gpt-6.2-astra",
358
+ name: "GPT 6.2 Astra",
359
+ apiId: "gpt-6.2-astra",
360
+ publisher: "openai",
361
+ endpointType: "maas",
362
+ maasApi: "responses",
363
+ contextWindow: 1050000,
364
+ maxTokens: 128000,
365
+ input: ["text", "image"],
366
+ reasoning: true,
367
+ tools: true,
368
+ cost: {
369
+ input: 8.00,
370
+ output: 40.00,
371
+ cacheRead: 0.40,
372
+ cacheWrite: 0,
373
+ },
374
+ region: "global",
375
+ thinkingLevelMap: { minimal: null, xhigh: "xhigh", max: "max" },
376
+ },
377
+ {
378
+ id: "gpt-6.2-sol",
379
+ name: "GPT 6.2 Sol",
380
+ apiId: "gpt-6.2-sol",
381
+ publisher: "openai",
382
+ endpointType: "maas",
383
+ maasApi: "responses",
384
+ contextWindow: 1050000,
385
+ maxTokens: 128000,
386
+ input: ["text", "image"],
387
+ reasoning: true,
388
+ tools: true,
389
+ cost: {
390
+ input: 2.00,
391
+ output: 10.00,
392
+ cacheRead: 0.10,
393
+ cacheWrite: 0,
394
+ },
395
+ region: "global",
396
+ thinkingLevelMap: { minimal: null, xhigh: "xhigh", max: "max" },
397
+ },
398
+ {
399
+ id: "gpt-6-astra",
400
+ name: "GPT 6.0 Astra",
401
+ apiId: "gpt-6-astra",
402
+ publisher: "openai",
403
+ endpointType: "maas",
404
+ maasApi: "responses",
405
+ contextWindow: 1050000,
406
+ maxTokens: 128000,
407
+ input: ["text", "image"],
408
+ reasoning: true,
409
+ tools: true,
410
+ cost: {
411
+ input: 10.00,
412
+ output: 50.00,
413
+ cacheRead: 1.00,
414
+ cacheWrite: 0,
415
+ },
416
+ region: "global",
417
+ thinkingLevelMap: { minimal: null, xhigh: "xhigh", max: "max" },
418
+ },
419
+ {
420
+ id: "gpt-6.1-sol",
421
+ name: "GPT 6.1 Sol",
422
+ apiId: "gpt-6.1-sol",
423
+ publisher: "openai",
424
+ endpointType: "maas",
425
+ maasApi: "responses",
426
+ contextWindow: 1050000,
427
+ maxTokens: 128000,
428
+ input: ["text", "image"],
429
+ reasoning: true,
430
+ tools: true,
431
+ cost: {
432
+ input: 2.00,
433
+ output: 10.00,
434
+ cacheRead: 0.10,
435
+ cacheWrite: 0,
436
+ },
437
+ region: "global",
438
+ thinkingLevelMap: { minimal: null, xhigh: "xhigh", max: "max" },
439
+ },
440
+ {
441
+ id: "gpt-6.1-terra",
442
+ name: "GPT 6.1 Terra",
443
+ apiId: "gpt-6.1-terra",
444
+ publisher: "openai",
445
+ endpointType: "maas",
446
+ maasApi: "responses",
447
+ contextWindow: 1050000,
448
+ maxTokens: 128000,
449
+ input: ["text", "image"],
450
+ reasoning: true,
451
+ tools: true,
452
+ cost: {
453
+ input: 1.00,
454
+ output: 5.00,
455
+ cacheRead: 0.05,
456
+ cacheWrite: 0,
457
+ },
458
+ region: "global",
459
+ thinkingLevelMap: { off: "none", minimal: null, xhigh: "xhigh", max: "max" },
460
+ },
461
+ {
462
+ id: "gpt-6-luna",
463
+ name: "GPT 6.0 Luna",
464
+ apiId: "gpt-6-luna",
465
+ publisher: "openai",
466
+ endpointType: "maas",
467
+ maasApi: "responses",
468
+ contextWindow: 1050000,
469
+ maxTokens: 128000,
470
+ input: ["text", "image"],
471
+ reasoning: true,
472
+ tools: true,
473
+ cost: {
474
+ input: 0.10,
475
+ output: 0.50,
476
+ cacheRead: 0.01,
477
+ cacheWrite: 0,
478
+ },
479
+ region: "global",
480
+ thinkingLevelMap: { off: "none", minimal: null, xhigh: "xhigh", max: "max" },
481
+ },
482
+
309
483
  // --- OpenAI (gpt-oss) ---
310
484
  {
311
485
  id: "gpt-oss-120b",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssweens/pi-vertex",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Google Vertex AI provider for Pi coding agent - supports Gemini, Claude, and all MaaS models",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -103,6 +103,7 @@ export function streamGemini(
103
103
  // Priority: config file > env var > model region > default
104
104
  const location = resolveLocation(model.region);
105
105
  const auth = getAuthConfig(location);
106
+ const cost = auth.location !== "global" && model.costRegional ? model.costRegional : model.cost;
106
107
  const { GoogleGenAI, FinishReason, ThinkingLevel } = await import("@google/genai");
107
108
  const thinkingLevelByEffort = {
108
109
  minimal: ThinkingLevel.MINIMAL,
@@ -143,7 +144,7 @@ export function streamGemini(
143
144
  // Add thinking configuration (matches pi-mono's buildParams logic).
144
145
  if (model.reasoning) {
145
146
  if (options?.reasoning) {
146
- // XHIGH goes only to models that declare it (Gemini 4 Hydrogen); every
147
+ // XHIGH goes only to models that declare it (Neon and Hydrogen); every
147
148
  // other Gemini model answers XHIGH with HTTP 400, so it caps at HIGH.
148
149
  const supportsXhigh = model.thinkingLevelMap?.xhigh != null;
149
150
  const effort = options.reasoning === "xhigh" || options.reasoning === "max" ? "high" : options.reasoning;
@@ -319,7 +320,7 @@ export function streamGemini(
319
320
  totalTokens: meta.totalTokenCount || 0,
320
321
  cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
321
322
  };
322
- calculateCost(model.cost.input, model.cost.output, model.cost.cacheRead, model.cost.cacheWrite, output.usage);
323
+ calculateCost(cost.input, cost.output, cost.cacheRead, cost.cacheWrite, output.usage);
323
324
  }
324
325
  }
325
326
 
package/streaming/maas.ts CHANGED
@@ -358,7 +358,7 @@ function chatCompletionsModel(model: VertexModelConfig, baseUrl: string): Model<
358
358
  /**
359
359
  * Responses model on the publisher's OpenAI-compatible endpoint
360
360
  * (`/publishers/{publisher}/v1/responses`), addressed by bare model id.
361
- * pi-ai always sends `store: false`, which these endpoints require.
361
+ * pi-ai sends `store: false` for stateless replay (required by Muse).
362
362
  */
363
363
  function responsesModel(model: VertexModelConfig, baseUrl: string): Model<"openai-responses"> {
364
364
  return {
@@ -368,9 +368,9 @@ function responsesModel(model: VertexModelConfig, baseUrl: string): Model<"opena
368
368
  provider: "vertex",
369
369
  baseUrl: `${baseUrl}/publishers/${model.publisher}/v1`,
370
370
  reasoning: model.reasoning,
371
- // Effort `none` is rejected; `off: null` makes pi-ai omit `reasoning` when no
372
- // effort is requested, so the model runs at its default.
373
- thinkingLevelMap: { ...model.thinkingLevelMap, off: null },
371
+ // Default to omitting effort at off; only models declaring an off mapping
372
+ // (GPT Terra/Luna accept `none`) override this.
373
+ thinkingLevelMap: { off: null, ...model.thinkingLevelMap },
374
374
  input: model.input,
375
375
  cost: model.cost,
376
376
  contextWindow: model.contextWindow,
@@ -411,6 +411,25 @@ export function streamMaaS(
411
411
  temperature: options?.temperature,
412
412
  };
413
413
 
414
+ if (useResponses && model.publisher === "openai") {
415
+ const onPayload = innerOptions.onPayload;
416
+ innerOptions.onPayload = async (payload, requestModel) => {
417
+ const replacement = await onPayload?.(payload, requestModel);
418
+ const body = (replacement ?? payload) as {
419
+ reasoning?: { summary?: string };
420
+ include?: string[];
421
+ };
422
+ // Vertex's GPT preview does not support reasoning summaries. Keep
423
+ // encrypted reasoning available for stateless replay, even at off.
424
+ if (body.reasoning) delete body.reasoning.summary;
425
+ body.include ??= [];
426
+ if (!body.include.includes("reasoning.encrypted_content")) {
427
+ body.include.push("reasoning.encrypted_content");
428
+ }
429
+ return body;
430
+ };
431
+ }
432
+
414
433
  // Pi 0.99 moved per-API stream functions off the pi-ai root.
415
434
  // Pi's extension loader maps the compat entry at runtime.
416
435
  const { openAICompletionsApi, openAIResponsesApi } = await import("@earendil-works/pi-ai/compat");
@@ -24,8 +24,9 @@ const { port } = server.address();
24
24
  // The wrapper matches Vertex streaming URLs by substring, so a local URL carrying those
25
25
  // markers in its path exercises the real wrapper without DNS or credentials.
26
26
  const base = `http://127.0.0.1:${port}/aiplatform.googleapis.com/endpoints/openapi`;
27
- // Meta Muse streams from the publisher Responses API instead of /endpoints/openapi.
28
- const responsesBase = `http://127.0.0.1:${port}/aiplatform.googleapis.com/publishers/meta/v1/responses`;
27
+ // Muse and GPT stream from publisher Responses APIs instead of /endpoints/openapi.
28
+ const responsesBases = ["meta", "openai"].map(publisher =>
29
+ `http://127.0.0.1:${port}/aiplatform.googleapis.com/publishers/${publisher}/v1/responses`);
29
30
  installSseCommentFilter();
30
31
 
31
32
  async function read(path, root = base) {
@@ -40,7 +41,9 @@ await assert.rejects(read("/dead"), /sent no data for 0s after accepting this st
40
41
  const elapsed = Date.now() - started;
41
42
  assert(elapsed < 3000, `a dead stream must fail fast, took ${elapsed}ms`);
42
43
  assert(elapsed >= 300, `must wait its budget first, gave up after ${elapsed}ms`);
43
- await assert.rejects(read("/dead", responsesBase), /sent no data/, "a dead Responses API stream must fail fast too");
44
+ for (const root of responsesBases) {
45
+ await assert.rejects(read("/dead", root), /sent no data/, "a dead Responses API stream must fail fast too");
46
+ }
44
47
 
45
48
  for (const path of ["/live", "/slow-start"]) {
46
49
  const body = await read(path);
@@ -0,0 +1,122 @@
1
+ /** Catalog additions and Vertex's GPT Responses request/replay contract. No network. */
2
+ import assert from "node:assert/strict";
3
+ import { existsSync, mkdtempSync, rmSync } from "node:fs";
4
+ import { registerHooks } from "node:module";
5
+ import { tmpdir } from "node:os";
6
+ import { join } from "node:path";
7
+ import { fileURLToPath } from "node:url";
8
+ import { GoogleAuth } from "google-auth-library";
9
+ import { getSupportedThinkingLevels } from "@earendil-works/pi-ai";
10
+
11
+ // Production uses Pi's TS loader. Resolve its .js source imports for Node's type stripper.
12
+ const root = new URL("../", import.meta.url).href;
13
+ registerHooks({
14
+ resolve(specifier, context, nextResolve) {
15
+ if (specifier.startsWith(".") && specifier.endsWith(".js") &&
16
+ context.parentURL?.startsWith(root) && !context.parentURL.includes("/node_modules/")) {
17
+ const source = new URL(specifier.slice(0, -3) + ".ts", context.parentURL);
18
+ if (existsSync(source)) return nextResolve(source.href, context);
19
+ }
20
+ return nextResolve(specifier, context);
21
+ },
22
+ });
23
+ const { ALL_MODELS, getModelById } = await import("../models/index.ts");
24
+ const { streamVertex } = await import("../streaming/index.ts");
25
+ assert.equal(new Set(ALL_MODELS.map(m => m.id)).size, ALL_MODELS.length, "unique model IDs");
26
+
27
+ const neon = getModelById("gemini-4-neon");
28
+ assert.equal(neon.apiId, "gemini-4-neon");
29
+ assert.equal(neon.endpointType, "gemini");
30
+ assert.equal(neon.contextWindow, 1048576);
31
+ assert.equal(neon.maxTokens, 65536);
32
+ assert.deepEqual(neon.cost, { input: 3, output: 15, cacheRead: 0.15, cacheWrite: 0 });
33
+ assert.deepEqual(getSupportedThinkingLevels(neon), ["off", "low", "medium", "high", "xhigh"]);
34
+ const deepseek = getModelById("deepseek-v4.1-flash-1017");
35
+ assert.equal(deepseek.apiId, "deepseek-ai/deepseek-v4.1-flash-1017-maas");
36
+ assert.equal(deepseek.cost.cacheRead, 0.006);
37
+ assert.deepEqual(getSupportedThinkingLevels(deepseek), ["off", "minimal", "low", "medium", "high", "max"]);
38
+ const grok = getModelById("grok-4.20-non-reasoning");
39
+ assert.equal(grok.apiId, "grok-4.20-non-reasoning");
40
+ assert.equal(grok.tools, true);
41
+ assert.deepEqual(getSupportedThinkingLevels(grok), ["off"]);
42
+ const gptIds = ["gpt-6.2-astra", "gpt-6.2-sol", "gpt-6-astra", "gpt-6.1-sol", "gpt-6.1-terra", "gpt-6-luna"];
43
+ for (const id of gptIds) {
44
+ const m = getModelById(id);
45
+ assert.equal(m.apiId, id);
46
+ assert.equal(m.publisher, "openai");
47
+ assert.equal(m.maasApi, "responses");
48
+ assert.equal(m.contextWindow, 1050000);
49
+ assert.equal(m.maxTokens, 128000);
50
+ assert.deepEqual(m.input, ["text", "image"]);
51
+ assert.equal(m.tools, true);
52
+ assert.deepEqual(getSupportedThinkingLevels(m), ["off", "low", "medium", "high", "xhigh", "max"]);
53
+ }
54
+ assert.equal(getModelById("gpt-oss-120b").maasApi, undefined, "GPT-OSS stays on Chat Completions");
55
+
56
+ const dir = mkdtempSync(join(tmpdir(), "pi-vertex-catalog-"));
57
+ const savedEnv = { ...process.env };
58
+ const getClient = GoogleAuth.prototype.getClient;
59
+ process.env.PI_CODING_AGENT_DIR = dir;
60
+ process.env.GOOGLE_CLOUD_PROJECT = "vertex-test-project";
61
+ process.env.GOOGLE_CLOUD_LOCATION = "global";
62
+ // Existence is checked by the extension; getClient is stubbed so no ADC file is parsed.
63
+ process.env.GOOGLE_APPLICATION_CREDENTIALS = fileURLToPath(import.meta.url);
64
+ GoogleAuth.prototype.getClient = async () => ({ getAccessToken: async () => ({ token: "test-token" }) });
65
+ const tool = { name: "probe", description: "Probe", parameters: { type: "object", properties: {} } };
66
+ const context = { messages: [
67
+ { role: "system", content: "Use probe.", toolsAdded: [tool], timestamp: 0 },
68
+ { role: "user", content: "Probe.", timestamp: 0 },
69
+ ] };
70
+ const reasoningItem = { type: "reasoning", id: "rs_test", summary: [], encrypted_content: "test-ciphertext" };
71
+ const call = { type: "function_call", id: "fc_test", call_id: "call_test", name: "probe", arguments: "{}" };
72
+ let captured;
73
+ async function request(id, reasoning, ctx = context, onPayload) {
74
+ captured = undefined;
75
+ const result = await streamVertex(getModelById(id), ctx, {
76
+ reasoning, maxTokens: 1024, maxRetries: 0, onPayload,
77
+ fetch: async (url, init) => {
78
+ captured = { url: String(url), body: JSON.parse(init.body) };
79
+ const events = [reasoningItem, call].map((item, output_index) => ({ type: "response.output_item.done", output_index, item }));
80
+ events.push({ type: "response.completed", response: { id: "resp_test", status: "completed", output: [reasoningItem, call], usage: { input_tokens: 10, output_tokens: 5 } } });
81
+ return new Response(events.map(e => `data: ${JSON.stringify(e)}\n\n`).join(""), { headers: { "content-type": "text/event-stream" } });
82
+ },
83
+ }).result();
84
+ assert.equal(result.stopReason, "toolUse", result.errorMessage);
85
+ return result;
86
+ }
87
+ try {
88
+ const first = await request("gpt-6.2-sol", "xhigh", context, payload => ({ ...payload, metadata: { hook: "preserved" } }));
89
+ assert.equal(first.stopReason, "toolUse", first.errorMessage);
90
+ assert.equal(captured.url, "https://aiplatform.googleapis.com/v1/projects/vertex-test-project/locations/global/publishers/openai/v1/responses");
91
+ assert.equal(captured.body.model, "gpt-6.2-sol");
92
+ assert.equal(captured.body.store, false);
93
+ assert.equal(captured.body.max_output_tokens, 1024);
94
+ assert.deepEqual(captured.body.reasoning, { effort: "xhigh" }, "no unsupported summary");
95
+ assert.deepEqual(captured.body.metadata, { hook: "preserved" });
96
+ assert(captured.body.include.includes("reasoning.encrypted_content"));
97
+ assert.equal(captured.body.tools[0].name, "probe");
98
+ assert.equal(captured.body.prompt_cache_retention, undefined);
99
+ const toolCall = first.content.find(b => b.type === "toolCall");
100
+ assert.equal(toolCall.name, "probe");
101
+ const replay = await request("gpt-6.2-sol", undefined, { messages: [...context.messages, first,
102
+ { role: "toolResult", toolCallId: toolCall.id, toolName: "probe", content: [{ type: "text", text: "ok" }], timestamp: 0 },
103
+ ] });
104
+ assert.equal(replay.stopReason, "toolUse", replay.errorMessage);
105
+ assert.equal(captured.body.reasoning, undefined, "Astra/Sol off uses model default, not rejected none");
106
+ assert(captured.body.include.includes("reasoning.encrypted_content"), "off still requests replay state");
107
+ assert(captured.body.input.some(i => i.type === "reasoning" && i.encrypted_content === "test-ciphertext"));
108
+ assert(captured.body.input.some(i => i.type === "function_call_output" && i.output === "ok"));
109
+ await request("gpt-6-luna", undefined);
110
+ assert.deepEqual(captured.body.reasoning, { effort: "none" }, "Luna off disables reasoning");
111
+ await request("gpt-6.1-terra", "max");
112
+ assert.deepEqual(captured.body.reasoning, { effort: "max" });
113
+ await request("muse-ember-1.0", "minimal");
114
+ assert(captured.url.endsWith("/publishers/meta/v1/responses"));
115
+ assert.deepEqual(captured.body.reasoning, { effort: "minimal", summary: "auto" }, "Muse is unchanged");
116
+ } finally {
117
+ GoogleAuth.prototype.getClient = getClient;
118
+ for (const key of Object.keys(process.env)) if (!(key in savedEnv)) delete process.env[key];
119
+ Object.assign(process.env, savedEnv);
120
+ rmSync(dir, { recursive: true, force: true });
121
+ }
122
+ console.log("PASS new model catalog and GPT Responses routing, effort, payload hook, and encrypted tool replay");
package/types.ts CHANGED
@@ -37,7 +37,7 @@ export type EndpointType = "gemini" | "maas";
37
37
 
38
38
  /**
39
39
  * Wire API for non-Anthropic MaaS models. Most use the OpenAI-compatible Chat
40
- * Completions endpoint (`/endpoints/openapi`); some publishers (Meta Muse) only
40
+ * Completions endpoint (`/endpoints/openapi`); Meta Muse and OpenAI GPT only
41
41
  * serve the OpenAI-compatible Responses API (`/publishers/{publisher}/v1/responses`).
42
42
  */
43
43
  export type MaasApi = "chat-completions" | "responses";