Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 9724a28

Browse files
committed
fix: support custom/third-party model paths in Vertex AI provider
When users specify a custom or third-party MaaS model ID (e.g. "gpt-oss-120b-maas" or "publishers/openai/models/gpt-oss-120b-maas"), the VertexHandler now passes it through as-is instead of silently falling back to the default model. This fixes 404 NOT_FOUND errors when using non-Google models on Vertex AI. Closes #12074
1 parent c3cae39 commit 9724a28

2 files changed

Lines changed: 79 additions & 2 deletions

File tree

src/api/providers/__tests__/vertex.spec.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,56 @@ describe("VertexHandler", () => {
163163
expect(excludedCount).toBe(1)
164164
expect(includedCount).toBe(1)
165165
})
166+
167+
it("should pass through custom/unknown model IDs instead of falling back to default", () => {
168+
const testHandler = new VertexHandler({
169+
apiModelId: "gpt-oss-120b-maas",
170+
vertexProjectId: "test-project",
171+
vertexRegion: "us-central1",
172+
})
173+
174+
const modelInfo = testHandler.getModel()
175+
// The critical fix: custom model ID is preserved, not replaced with the default
176+
expect(modelInfo.id).toBe("gpt-oss-120b-maas")
177+
expect(modelInfo.info).toBeDefined()
178+
})
179+
180+
it("should pass through publisher-qualified model paths as-is", () => {
181+
const testHandler = new VertexHandler({
182+
apiModelId: "publishers/openai/models/gpt-oss-120b-maas",
183+
vertexProjectId: "test-project",
184+
vertexRegion: "us-central1",
185+
})
186+
187+
const modelInfo = testHandler.getModel()
188+
// Full publisher path is passed through unchanged
189+
expect(modelInfo.id).toBe("publishers/openai/models/gpt-oss-120b-maas")
190+
expect(modelInfo.info).toBeDefined()
191+
})
192+
193+
it("should still apply edit/apply_diff tool preferences to custom models", () => {
194+
const testHandler = new VertexHandler({
195+
apiModelId: "publishers/openai/models/gpt-oss-120b-maas",
196+
vertexProjectId: "test-project",
197+
vertexRegion: "us-central1",
198+
})
199+
200+
const modelInfo = testHandler.getModel()
201+
expect(modelInfo.info.excludedTools).toContain("apply_diff")
202+
expect(modelInfo.info.includedTools).toContain("edit")
203+
})
204+
205+
it("should fall back to default model when no model ID is provided", () => {
206+
const testHandler = new VertexHandler({
207+
vertexProjectId: "test-project",
208+
vertexRegion: "us-central1",
209+
})
210+
211+
const modelInfo = testHandler.getModel()
212+
// Should use the default vertex model, not crash
213+
expect(modelInfo.id).toBeDefined()
214+
expect(modelInfo.info).toBeDefined()
215+
expect(modelInfo.info.maxTokens).toBeGreaterThan(0)
216+
})
166217
})
167218
})

src/api/providers/vertex.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,34 @@ export class VertexHandler extends GeminiHandler implements SingleCompletionHand
1414

1515
override getModel() {
1616
const modelId = this.options.apiModelId
17-
let id = modelId && modelId in vertexModels ? (modelId as VertexModelId) : vertexDefaultModelId
18-
let info: ModelInfo = vertexModels[id]
17+
18+
let id: string
19+
let info: ModelInfo
20+
21+
if (modelId && modelId in vertexModels) {
22+
// Known Vertex model -- use its curated ModelInfo.
23+
id = modelId as VertexModelId
24+
info = vertexModels[id as VertexModelId]
25+
} else if (modelId) {
26+
// Custom / third-party MaaS model.
27+
// Users may supply either a bare model name (e.g. "gpt-oss-120b-maas")
28+
// or a fully-qualified publisher path
29+
// (e.g. "publishers/openai/models/gpt-oss-120b-maas").
30+
// Both forms are passed through as-is; the @google/genai SDK and
31+
// Vertex AI API accept full resource names directly.
32+
id = modelId
33+
info = {
34+
maxTokens: 8192,
35+
contextWindow: 128_000,
36+
supportsImages: true,
37+
supportsPromptCache: false,
38+
}
39+
} else {
40+
// No model specified -- fall back to the default.
41+
id = vertexDefaultModelId
42+
info = vertexModels[vertexDefaultModelId]
43+
}
44+
1945
const params = getModelParams({
2046
format: "gemini",
2147
modelId: id,

0 commit comments

Comments
 (0)