feat(models): allow configuring Vertex AI API version (v1/v1beta1)#6183
Open
vaibhav-patel wants to merge 2 commits into
Open
feat(models): allow configuring Vertex AI API version (v1/v1beta1)#6183vaibhav-patel wants to merge 2 commits into
vaibhav-patel wants to merge 2 commits into
Conversation
The Gemini model integration relied on the google-genai SDK's default API version, which is v1beta1 for the Vertex AI backend. Production users that need a stable, SLA-eligible endpoint had no supported way to opt into the GA v1 Vertex AI API short of subclassing Gemini and overriding api_client. Add an optional api_version field on Gemini and honor the GOOGLE_GENAI_API_VERSION environment variable as a fallback. The resolved version flows through the existing _base_url_and_api_version chokepoint, so it applies consistently to the standard api_client, the live API client, and the per-request http_options patching. Resolution order: a version embedded in base_url wins, then the api_version field, then GOOGLE_GENAI_API_VERSION, then the SDK default. When none is configured the behavior is unchanged, so existing users are unaffected. Fixes google#3246.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Author
|
@googlebot I signed it! |
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.
Summary
ADK relies on the google-genai SDK's default API version, which is
v1beta1for the Vertex AI backend. Production users want to opt into the stable, GAv1Vertex AI endpoint for SLA eligibility, but today the only workaround is subclassingGeminiand overridingapi_client.This adds a clean, backward-compatible way to configure the API version:
api_versionfield onGemini(e.g.Gemini(model=..., api_version="v1")).GOOGLE_GENAI_API_VERSIONenvironment variable, honored as a fallback.The resolved version flows through the existing
_base_url_and_api_versionchokepoint, so it applies consistently to the standard client, the live API client, and the per-requesthttp_options.Resolution order: a version embedded in
base_urlwins, then theapi_versionfield, thenGOOGLE_GENAI_API_VERSION, then the SDK default. When nothing is configured, behavior is unchanged — existing users are unaffected.Usage
or set
GOOGLE_GENAI_API_VERSION=v1in the environment.Testing
tests/unittests/models/test_google_llm.pycovering the field, the env var, precedence rules, the live API path, and the request-config patching, plus an assertion that the default is unchanged.test_google_llm.pysuite passes (74 tests);pyinkandisortclean.Fixes #3246.