Skip to content

Commit 78e7134

Browse files
authored
feat(llm-bridge): google cloud vertex ai support global location (#1109)
update from `aiplatform.googleapis.com/v1/` to `aiplatform.googleapis.com/v1beta1/` as described at https://cloud.google.com/vertex-ai/generative-ai/docs/migrate/openai/overview and, add support for `global` location support. ```yaml vertexai: project_id: PRJ_ID credentials_file: "./credential.json" model: gemini-2.5-pro location: global ```
1 parent 63b1453 commit 78e7134

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pkg/bridge/ai/provider/vertexai/provider.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,27 @@ var _ provider.LLMProvider = &Provider{}
2525
func NewProvider(projectID, location, model, credentialsFile string) *Provider {
2626
httpClient, _, err := transport.NewHTTPClient(
2727
context.Background(),
28-
option.WithEndpoint(fmt.Sprintf("%s-aiplatform.googleapis.com", location)),
2928
option.WithScopes("https://www.googleapis.com/auth/cloud-platform"),
3029
option.WithCredentialsFile(credentialsFile),
3130
)
3231
if err != nil {
3332
log.Fatalln("vertexai new http client: ", err)
3433
}
3534

35+
// if location is "global"
36+
baseURL := fmt.Sprintf("https://%s-aiplatform.googleapis.com/v1beta1/projects/%s/locations/%s/endpoints/openapi", location, projectID, location)
37+
if location == "global" {
38+
baseURL = fmt.Sprintf("https://aiplatform.googleapis.com/v1beta1/projects/%s/locations/global/endpoints/openapi", projectID)
39+
}
40+
3641
client := openai.NewClientWithConfig(openai.ClientConfig{
37-
BaseURL: fmt.Sprintf("https://%s-aiplatform.googleapis.com/v1/projects/%s/locations/%s/endpoints/openapi", location, projectID, location),
42+
BaseURL: baseURL,
3843
HTTPClient: httpClient,
3944
EmptyMessagesLimit: 300,
4045
})
4146

4247
if model == "" {
43-
model = "gemini-1.5-pro-002"
48+
model = "gemini-2.5-flash"
4449
}
4550

4651
model = "google/" + model

0 commit comments

Comments
 (0)