From fba9eac7ebb750b3cd0e7685b398491ea1deaab2 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 1 Jun 2026 00:34:20 +0100 Subject: [PATCH] fix(google): register Vertex static catalog rows --- extensions/google/provider-catalog.test.ts | 23 ++++++++++++++ extensions/google/provider-catalog.ts | 36 ++++++++++++++++++++++ extensions/google/provider-discovery.ts | 12 ++++++-- extensions/google/provider-registration.ts | 12 ++++++-- 4 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 extensions/google/provider-catalog.test.ts diff --git a/extensions/google/provider-catalog.test.ts b/extensions/google/provider-catalog.test.ts new file mode 100644 index 00000000000..a94652fbc6f --- /dev/null +++ b/extensions/google/provider-catalog.test.ts @@ -0,0 +1,23 @@ +import { describe, expect, it } from "vitest"; +import { + buildGoogleStaticCatalogProvider, + buildGoogleVertexStaticCatalogProvider, +} from "./provider-catalog.js"; + +describe("google provider catalog", () => { + it("registers current Gemini rows for the Google Vertex provider", () => { + const provider = buildGoogleVertexStaticCatalogProvider(); + + expect(provider.api).toBe("google-vertex"); + expect(provider.baseUrl).toBe("https://{location}-aiplatform.googleapis.com"); + expect(provider.models.map((model) => model.id)).toEqual( + expect.arrayContaining(["gemini-2.5-pro", "gemini-3.1-pro-preview"]), + ); + }); + + it("keeps Google AI Studio and Vertex model ids aligned", () => { + expect(buildGoogleVertexStaticCatalogProvider().models.map((model) => model.id)).toEqual( + buildGoogleStaticCatalogProvider().models.map((model) => model.id), + ); + }); +}); diff --git a/extensions/google/provider-catalog.ts b/extensions/google/provider-catalog.ts index 9dd375f522c..1c982c8e570 100644 --- a/extensions/google/provider-catalog.ts +++ b/extensions/google/provider-catalog.ts @@ -4,8 +4,36 @@ import type { } from "openclaw/plugin-sdk/provider-model-shared"; const GOOGLE_GEMINI_BASE_URL = "https://generativelanguage.googleapis.com/v1beta"; +const GOOGLE_VERTEX_BASE_URL = "https://{location}-aiplatform.googleapis.com"; const GOOGLE_GEMINI_COST = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 } as const; const GOOGLE_GEMINI_TEXT_MODELS: ModelDefinitionConfig[] = [ + { + id: "gemini-2.5-pro", + name: "Gemini 2.5 Pro", + reasoning: true, + input: ["text", "image"], + cost: GOOGLE_GEMINI_COST, + contextWindow: 1_048_576, + maxTokens: 65_536, + }, + { + id: "gemini-2.5-flash", + name: "Gemini 2.5 Flash", + reasoning: true, + input: ["text", "image"], + cost: GOOGLE_GEMINI_COST, + contextWindow: 1_048_576, + maxTokens: 65_536, + }, + { + id: "gemini-2.5-flash-lite", + name: "Gemini 2.5 Flash-Lite", + reasoning: true, + input: ["text", "image"], + cost: GOOGLE_GEMINI_COST, + contextWindow: 1_048_576, + maxTokens: 65_536, + }, { id: "gemini-3.1-pro-preview", name: "Gemini 3.1 Pro Preview", @@ -33,3 +61,11 @@ export function buildGoogleStaticCatalogProvider(): ModelProviderConfig { models: GOOGLE_GEMINI_TEXT_MODELS, }; } + +export function buildGoogleVertexStaticCatalogProvider(): ModelProviderConfig { + return { + baseUrl: GOOGLE_VERTEX_BASE_URL, + api: "google-vertex", + models: GOOGLE_GEMINI_TEXT_MODELS, + }; +} diff --git a/extensions/google/provider-discovery.ts b/extensions/google/provider-discovery.ts index d8c5ecaf55a..8692fc66f29 100644 --- a/extensions/google/provider-discovery.ts +++ b/extensions/google/provider-discovery.ts @@ -1,5 +1,8 @@ import type { ProviderPlugin } from "openclaw/plugin-sdk/provider-model-shared"; -import { buildGoogleStaticCatalogProvider } from "./provider-catalog.js"; +import { + buildGoogleStaticCatalogProvider, + buildGoogleVertexStaticCatalogProvider, +} from "./provider-catalog.js"; const googleProviderDiscovery: ProviderPlugin = { id: "google", @@ -8,7 +11,12 @@ const googleProviderDiscovery: ProviderPlugin = { auth: [], staticCatalog: { order: "simple", - run: async () => ({ providers: { google: buildGoogleStaticCatalogProvider() } }), + run: async () => ({ + providers: { + google: buildGoogleStaticCatalogProvider(), + "google-vertex": buildGoogleVertexStaticCatalogProvider(), + }, + }), }, }; diff --git a/extensions/google/provider-registration.ts b/extensions/google/provider-registration.ts index a55e2b4d855..40cce9256b6 100644 --- a/extensions/google/provider-registration.ts +++ b/extensions/google/provider-registration.ts @@ -3,7 +3,10 @@ import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-aut import type { ProviderPlugin } from "openclaw/plugin-sdk/provider-model-shared"; import { normalizeGoogleModelId } from "./model-id.js"; import { GOOGLE_GEMINI_DEFAULT_MODEL, applyGoogleGeminiModelDefault } from "./onboard.js"; -import { buildGoogleStaticCatalogProvider } from "./provider-catalog.js"; +import { + buildGoogleStaticCatalogProvider, + buildGoogleVertexStaticCatalogProvider, +} from "./provider-catalog.js"; import { GOOGLE_GEMINI_PROVIDER_HOOKS } from "./provider-hooks.js"; import { isModernGoogleModel, resolveGoogleGeminiForwardCompatModel } from "./provider-models.js"; import { @@ -50,7 +53,12 @@ export function buildGoogleProvider(): ProviderPlugin { normalizeGoogleProviderConfig(provider, providerConfig), staticCatalog: { order: "simple", - run: async () => ({ providers: { google: buildGoogleStaticCatalogProvider() } }), + run: async () => ({ + providers: { + google: buildGoogleStaticCatalogProvider(), + "google-vertex": buildGoogleVertexStaticCatalogProvider(), + }, + }), }, normalizeModelId: ({ modelId }) => normalizeGoogleModelId(modelId), resolveDynamicModel: (ctx) =>