-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix: handle global region correctly for Vertex AI Claude models #8573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add custom baseURL for global region to use aiplatform.googleapis.com - Prevents incorrect hostname construction (global-aiplatform.googleapis.com) - Add comprehensive test coverage for global region scenarios Fixes #8571
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-review: auditing my own diff like a mirror with unit tests—still me, just with fewer 404s.
| // For the "global" region, we need to use a custom base URL | ||
| // The default would be "global-aiplatform.googleapis.com" which is incorrect | ||
| // The correct endpoint for global is "aiplatform.googleapis.com" | ||
| const baseURL = region === "global" ? `https://aiplatform.googleapis.com/v1` : undefined // Let the SDK use its default for other regions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Region comparison is exact-match; a user-provided value like "Global" or trailing whitespace would miss this branch. Consider normalizing before compare.
| const baseURL = region === "global" ? `https://aiplatform.googleapis.com/v1` : undefined // Let the SDK use its default for other regions | |
| const baseURL = region.trim().toLowerCase() === "global" ? `https://aiplatform.googleapis.com/v1` : undefined // Let the SDK use its default for other regions |
| // For the "global" region, we need to use a custom base URL | ||
| // The default would be "global-aiplatform.googleapis.com" which is incorrect | ||
| // The correct endpoint for global is "aiplatform.googleapis.com" | ||
| const baseURL = region === "global" ? `https://aiplatform.googleapis.com/v1` : undefined // Let the SDK use its default for other regions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] Verify SDK behavior regarding baseURL path: if the Vertex SDK appends "/v1" internally, this string may yield a double "/v1/v1". If so, prefer host-only.
| const baseURL = region === "global" ? `https://aiplatform.googleapis.com/v1` : undefined // Let the SDK use its default for other regions | |
| const baseURL = region.trim().toLowerCase() === "global" ? `https://aiplatform.googleapis.com` : undefined // Let the SDK use its default for other regions |
| }) | ||
| }) | ||
|
|
||
| it("should use custom baseURL for global region with JSON credentials", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P3] Consider complementary tests for non-global regions with JSON credentials and with key files to assert baseURL remains undefined. This guards against regressions in the credential branches.
Summary
This PR fixes an issue where using Google's Vertex AI provider with the "global" region and Claude models resulted in 404 errors due to incorrect hostname construction.
Problem
When the region is set to "global", the AnthropicVertex SDK was constructing the URL as
global-aiplatform.googleapis.cominstead of the correctaiplatform.googleapis.com.Solution
baseURLwhen the region is "global"https://aiplatform.googleapis.com/v1) is used for global regionTesting
Changes
src/api/providers/anthropic-vertex.tsto handle global regionsrc/api/providers/__tests__/anthropic-vertex.spec.tsFixes #8571
Important
Fixes global region handling in
AnthropicVertexHandlerby setting correctbaseURLfor Vertex AI Claude models and adds tests for verification.AnthropicVertexHandlerby settingbaseURLtohttps://aiplatform.googleapis.com/v1.anthropic-vertex.spec.tsfor global region with default, JSON credentials, and key file authentication.anthropic-vertex.ts: Adds logic for custombaseURLfor global region.anthropic-vertex.spec.ts: Adds test cases for global region handling.This description was created by
for e0fd25a. You can customize this summary. It will automatically update as commits are pushed.