Skip to content

Commit fba9eac

Browse files
committed
fix(google): register Vertex static catalog rows
1 parent 5965522 commit fba9eac

4 files changed

Lines changed: 79 additions & 4 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { describe, expect, it } from "vitest";
2+
import {
3+
buildGoogleStaticCatalogProvider,
4+
buildGoogleVertexStaticCatalogProvider,
5+
} from "./provider-catalog.js";
6+
7+
describe("google provider catalog", () => {
8+
it("registers current Gemini rows for the Google Vertex provider", () => {
9+
const provider = buildGoogleVertexStaticCatalogProvider();
10+
11+
expect(provider.api).toBe("google-vertex");
12+
expect(provider.baseUrl).toBe("https://{location}-aiplatform.googleapis.com");
13+
expect(provider.models.map((model) => model.id)).toEqual(
14+
expect.arrayContaining(["gemini-2.5-pro", "gemini-3.1-pro-preview"]),
15+
);
16+
});
17+
18+
it("keeps Google AI Studio and Vertex model ids aligned", () => {
19+
expect(buildGoogleVertexStaticCatalogProvider().models.map((model) => model.id)).toEqual(
20+
buildGoogleStaticCatalogProvider().models.map((model) => model.id),
21+
);
22+
});
23+
});

extensions/google/provider-catalog.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,36 @@ import type {
44
} from "openclaw/plugin-sdk/provider-model-shared";
55

66
const GOOGLE_GEMINI_BASE_URL = "https://generativelanguage.googleapis.com/v1beta";
7+
const GOOGLE_VERTEX_BASE_URL = "https://{location}-aiplatform.googleapis.com";
78
const GOOGLE_GEMINI_COST = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 } as const;
89
const GOOGLE_GEMINI_TEXT_MODELS: ModelDefinitionConfig[] = [
10+
{
11+
id: "gemini-2.5-pro",
12+
name: "Gemini 2.5 Pro",
13+
reasoning: true,
14+
input: ["text", "image"],
15+
cost: GOOGLE_GEMINI_COST,
16+
contextWindow: 1_048_576,
17+
maxTokens: 65_536,
18+
},
19+
{
20+
id: "gemini-2.5-flash",
21+
name: "Gemini 2.5 Flash",
22+
reasoning: true,
23+
input: ["text", "image"],
24+
cost: GOOGLE_GEMINI_COST,
25+
contextWindow: 1_048_576,
26+
maxTokens: 65_536,
27+
},
28+
{
29+
id: "gemini-2.5-flash-lite",
30+
name: "Gemini 2.5 Flash-Lite",
31+
reasoning: true,
32+
input: ["text", "image"],
33+
cost: GOOGLE_GEMINI_COST,
34+
contextWindow: 1_048_576,
35+
maxTokens: 65_536,
36+
},
937
{
1038
id: "gemini-3.1-pro-preview",
1139
name: "Gemini 3.1 Pro Preview",
@@ -33,3 +61,11 @@ export function buildGoogleStaticCatalogProvider(): ModelProviderConfig {
3361
models: GOOGLE_GEMINI_TEXT_MODELS,
3462
};
3563
}
64+
65+
export function buildGoogleVertexStaticCatalogProvider(): ModelProviderConfig {
66+
return {
67+
baseUrl: GOOGLE_VERTEX_BASE_URL,
68+
api: "google-vertex",
69+
models: GOOGLE_GEMINI_TEXT_MODELS,
70+
};
71+
}

extensions/google/provider-discovery.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import type { ProviderPlugin } from "openclaw/plugin-sdk/provider-model-shared";
2-
import { buildGoogleStaticCatalogProvider } from "./provider-catalog.js";
2+
import {
3+
buildGoogleStaticCatalogProvider,
4+
buildGoogleVertexStaticCatalogProvider,
5+
} from "./provider-catalog.js";
36

47
const googleProviderDiscovery: ProviderPlugin = {
58
id: "google",
@@ -8,7 +11,12 @@ const googleProviderDiscovery: ProviderPlugin = {
811
auth: [],
912
staticCatalog: {
1013
order: "simple",
11-
run: async () => ({ providers: { google: buildGoogleStaticCatalogProvider() } }),
14+
run: async () => ({
15+
providers: {
16+
google: buildGoogleStaticCatalogProvider(),
17+
"google-vertex": buildGoogleVertexStaticCatalogProvider(),
18+
},
19+
}),
1220
},
1321
};
1422

extensions/google/provider-registration.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { createProviderApiKeyAuthMethod } from "openclaw/plugin-sdk/provider-aut
33
import type { ProviderPlugin } from "openclaw/plugin-sdk/provider-model-shared";
44
import { normalizeGoogleModelId } from "./model-id.js";
55
import { GOOGLE_GEMINI_DEFAULT_MODEL, applyGoogleGeminiModelDefault } from "./onboard.js";
6-
import { buildGoogleStaticCatalogProvider } from "./provider-catalog.js";
6+
import {
7+
buildGoogleStaticCatalogProvider,
8+
buildGoogleVertexStaticCatalogProvider,
9+
} from "./provider-catalog.js";
710
import { GOOGLE_GEMINI_PROVIDER_HOOKS } from "./provider-hooks.js";
811
import { isModernGoogleModel, resolveGoogleGeminiForwardCompatModel } from "./provider-models.js";
912
import {
@@ -50,7 +53,12 @@ export function buildGoogleProvider(): ProviderPlugin {
5053
normalizeGoogleProviderConfig(provider, providerConfig),
5154
staticCatalog: {
5255
order: "simple",
53-
run: async () => ({ providers: { google: buildGoogleStaticCatalogProvider() } }),
56+
run: async () => ({
57+
providers: {
58+
google: buildGoogleStaticCatalogProvider(),
59+
"google-vertex": buildGoogleVertexStaticCatalogProvider(),
60+
},
61+
}),
5462
},
5563
normalizeModelId: ({ modelId }) => normalizeGoogleModelId(modelId),
5664
resolveDynamicModel: (ctx) =>

0 commit comments

Comments
 (0)