Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ func NewInternalAPIClient(ctx context.Context, cc *ClientConfig) (*InternalAPICl
if cc.HTTPOptions.BaseURL == "" {
if cc.Location == "global" || cc.APIKey != "" {
cc.HTTPOptions.BaseURL = "https://aiplatform.googleapis.com/"
} else if cc.Location == "us" {
cc.HTTPOptions.BaseURL = fmt.Sprintf("https://aiplatform.%s.rep.googleapis.com/", cc.Location)
} else {
cc.HTTPOptions.BaseURL = fmt.Sprintf("https://%s-aiplatform.googleapis.com/", cc.Location)
}
Expand Down
26 changes: 26 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,32 @@ func TestClientConfigHTTPOptions(t *testing.T) {
expectedBaseURL: "https://aiplatform.googleapis.com/",
expectedAPIVersion: "v1beta1",
},
{
name: "Vertex AI Backend with us location",
clientConfig: ClientConfig{
Backend: BackendVertexAI,
Project: "test-project",
Location: "us",
HTTPOptions: HTTPOptions{},
Credentials: &auth.Credentials{},
},
expectedBaseURL: "https://aiplatform.us.rep.googleapis.com/",
expectedAPIVersion: "v1beta1",
},
{
name: "Vertex AI Backend with us location and base URL override",
clientConfig: ClientConfig{
Backend: BackendVertexAI,
Project: "test-project",
Location: "us",
HTTPOptions: HTTPOptions{
BaseURL: "https://my-custom-url.com/",
},
Credentials: &auth.Credentials{},
},
expectedBaseURL: "https://my-custom-url.com/",
expectedAPIVersion: "v1beta1",
},
{
name: "Google AI Backend with HTTP Client Timeout and no HTTPOptions",
clientConfig: ClientConfig{
Expand Down
Loading