Skip to content

fix(py/google-genai): omit default location in Vertex AI express mode - #36

Closed
huangjeff5 wants to merge 1 commit into
mainfrom
fix/py-vertexai-express-location
Closed

huangjeff5 wants to merge 1 commit into
mainfrom
fix/py-vertexai-express-location

Conversation

@huangjeff5

Copy link
Copy Markdown
Collaborator

Problem

In Vertex AI Express mode (VertexAI(api_key=...) without a GCP project), VertexAI.__init__ previously defaulted self._location to 'us-central1' when no explicit location or environment variable was set. Passing location='us-central1' alongside api_key=... causes the Google GenAI client to target regional endpoints (https://us-central1-aiplatform.googleapis.com/) and generate resource URLs with projects/None/locations/us-central1, causing Express Mode requests to fail.

Mechanism

In VertexAI.__init__, default self._location to const.DEFAULT_REGION only when not in Express Mode (api_key and not self._project). When initializing Express Mode without an explicit location, self._location is None, allowing genai.Client to default to the global express endpoint (https://aiplatform.googleapis.com/).

Verification

  • Added test_api_key_omits_default_location in packages/genkit-google-genai/tests/vertexai_location_test.py verifying that VertexAI(api_key='k') leaves location unset.
  • Ran pytest packages/genkit-google-genai (1518 passed).
  • Verified ruff check, ruff format, and pyright clean.

@huangjeff5

Copy link
Copy Markdown
Collaborator Author

Superseded by #49.

@huangjeff5 huangjeff5 closed this Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant