.Net: Fix VertexAI global endpoint URI construction (#13620) - #13621
Conversation
The global VertexAI location uses `https://aiplatform.googleapis.com` rather than the regional `https://{location}-aiplatform.googleapis.com` pattern. This adds a `GetVertexAIBaseUri` helper to ClientBase that selects the correct base URI and updates all VertexAI clients (chat completion, token counter, embeddings) to use it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Any idea on when this PR will be reviewed? We have run into this bug in production as well and it removes our ability to use preview models without a janky workaround. Thanks Schmitt and to the Microsoft team for handling this! |
There was a problem hiding this comment.
Pull request overview
Updates the .NET Google connectors’ Vertex AI endpoint construction so that location=global correctly targets the global Vertex AI host (https://aiplatform.googleapis.com) instead of the regional host pattern (https://{location}-aiplatform.googleapis.com), and adds tests to prevent regressions.
Changes:
- Added a
ClientBase.GetVertexAIBaseUri(location)helper to select the correct Vertex AI host for global vs regional locations. - Updated Vertex AI-backed clients (embeddings, Gemini chat, Gemini token counting) to build request URIs using the new helper.
- Added unit tests to verify global and regional host selection and to treat
"global"as an accepted location segment.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/src/Connectors/Connectors.Google/Core/VertexAI/VertexAIEmbeddingClient.cs | Uses GetVertexAIBaseUri(location) when constructing the embeddings endpoint URI. |
| dotnet/src/Connectors/Connectors.Google/Core/Gemini/Clients/GeminiTokenCounterClient.cs | Uses GetVertexAIBaseUri(location) when constructing the Vertex AI token counting endpoint URI. |
| dotnet/src/Connectors/Connectors.Google/Core/Gemini/Clients/GeminiChatCompletionClient.cs | Uses GetVertexAIBaseUri(location) when constructing Vertex AI chat generation/streaming endpoint URIs. |
| dotnet/src/Connectors/Connectors.Google/Core/ClientBase.cs | Introduces GetVertexAIBaseUri helper with global vs regional host selection. |
| dotnet/src/Connectors/Connectors.Google.UnitTests/Core/VertexAI/VertexAIClientEmbeddingsGenerationTests.cs | Adds coverage ensuring global vs regional endpoints are selected correctly for embeddings. |
| dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/Clients/GeminiCountingTokensTests.cs | Adds coverage ensuring global vs regional endpoints are selected correctly for token counting. |
| dotnet/src/Connectors/Connectors.Google.UnitTests/Core/Gemini/Clients/GeminiChatGenerationTests.cs | Adds coverage ensuring global vs regional endpoints are selected correctly for chat generation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The global VertexAI location uses
https://aiplatform.googleapis.comrather than the regionalhttps://{location}-aiplatform.googleapis.compattern. This adds aGetVertexAIBaseUrihelper to ClientBase that selects the correct base URI and updates all VertexAI clients (chat completion, token counter, embeddings) to use it.