Repository navigation
fix(py/google-genai): omit default location in Vertex AI express mode - #36
Closed
huangjeff5 wants to merge 1 commit into
Closed
huangjeff5 wants to merge 1 commit into
huangjeff5 wants to merge 1 commit into
Conversation
huangjeff5
force-pushed
the
fix/py-vertexai-express-location
branch
from
November 9, 2026 19:07
c1b846d to
8873c33
Compare
Collaborator
Author
|
Superseded by #49. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In Vertex AI Express mode (
VertexAI(api_key=...)without a GCP project),VertexAI.__init__previously defaultedself._locationto'us-central1'when no explicit location or environment variable was set. Passinglocation='us-central1'alongsideapi_key=...causes the Google GenAI client to target regional endpoints (https://us-central1-aiplatform.googleapis.com/) and generate resource URLs withprojects/None/locations/us-central1, causing Express Mode requests to fail.Mechanism
In
VertexAI.__init__, defaultself._locationtoconst.DEFAULT_REGIONonly when not in Express Mode (api_key and not self._project). When initializing Express Mode without an explicit location,self._locationisNone, allowinggenai.Clientto default to the global express endpoint (https://aiplatform.googleapis.com/).Verification
test_api_key_omits_default_locationinpackages/genkit-google-genai/tests/vertexai_location_test.pyverifying thatVertexAI(api_key='k')leaves location unset.pytest packages/genkit-google-genai(1518 passed).ruff check,ruff format, andpyrightclean.