fix(google): register Vertex static catalog rows

This commit is contained in:
Peter Steinberger
2026-06-01 00:34:20 +01:00
parent 5965522af5
commit fba9eac7eb
4 changed files with 79 additions and 4 deletions

View File

@@ -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),
);
});
});

View File

@@ -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,
};
}

View File

@@ -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(),
},
}),
},
};

View File

@@ -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) =>