Skip to content

Commit 09d5be3

Browse files
google-genai-botcopybara-github
authored andcommitted
fix: support us region routing
PiperOrigin-RevId: 890026941
1 parent 3fab63a commit 09d5be3

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ func NewInternalAPIClient(ctx context.Context, cc *ClientConfig) (*InternalAPICl
293293
if cc.HTTPOptions.BaseURL == "" {
294294
if cc.Location == "global" || cc.APIKey != "" {
295295
cc.HTTPOptions.BaseURL = "https://aiplatform.googleapis.com/"
296+
} else if cc.Location == "us" {
297+
cc.HTTPOptions.BaseURL = fmt.Sprintf("https://aiplatform.%s.rep.googleapis.com/", cc.Location)
296298
} else {
297299
cc.HTTPOptions.BaseURL = fmt.Sprintf("https://%s-aiplatform.googleapis.com/", cc.Location)
298300
}

client_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,32 @@ func TestClientConfigHTTPOptions(t *testing.T) {
963963
expectedBaseURL: "https://aiplatform.googleapis.com/",
964964
expectedAPIVersion: "v1beta1",
965965
},
966+
{
967+
name: "Vertex AI Backend with us location",
968+
clientConfig: ClientConfig{
969+
Backend: BackendVertexAI,
970+
Project: "test-project",
971+
Location: "us",
972+
HTTPOptions: HTTPOptions{},
973+
Credentials: &auth.Credentials{},
974+
},
975+
expectedBaseURL: "https://aiplatform.us.rep.googleapis.com/",
976+
expectedAPIVersion: "v1beta1",
977+
},
978+
{
979+
name: "Vertex AI Backend with us location and base URL override",
980+
clientConfig: ClientConfig{
981+
Backend: BackendVertexAI,
982+
Project: "test-project",
983+
Location: "us",
984+
HTTPOptions: HTTPOptions{
985+
BaseURL: "https://my-custom-url.com/",
986+
},
987+
Credentials: &auth.Credentials{},
988+
},
989+
expectedBaseURL: "https://my-custom-url.com/",
990+
expectedAPIVersion: "v1beta1",
991+
},
966992
{
967993
name: "Google AI Backend with HTTP Client Timeout and no HTTPOptions",
968994
clientConfig: ClientConfig{

0 commit comments

Comments
 (0)