Skip to content

feat(models): allow configuring Vertex AI API version (v1/v1beta1)#6183

Open
vaibhav-patel wants to merge 2 commits into
google:mainfrom
vaibhav-patel:fix/3246-vertex-v1-api-option
Open

feat(models): allow configuring Vertex AI API version (v1/v1beta1)#6183
vaibhav-patel wants to merge 2 commits into
google:mainfrom
vaibhav-patel:fix/3246-vertex-v1-api-option

Conversation

@vaibhav-patel

Copy link
Copy Markdown

Summary

ADK relies on the google-genai SDK's default API version, which is v1beta1 for the Vertex AI backend. Production users want to opt into the stable, GA v1 Vertex AI endpoint for SLA eligibility, but today the only workaround is subclassing Gemini and overriding api_client.

This adds a clean, backward-compatible way to configure the API version:

  • New optional api_version field on Gemini (e.g. Gemini(model=..., api_version="v1")).
  • New GOOGLE_GENAI_API_VERSION environment variable, honored as a fallback.

The resolved version flows through the existing _base_url_and_api_version chokepoint, so it applies consistently to the standard client, the live API client, and the per-request http_options.

Resolution order: a version embedded in base_url wins, then the api_version field, then GOOGLE_GENAI_API_VERSION, then the SDK default. When nothing is configured, behavior is unchanged — existing users are unaffected.

Usage

from google.adk.models import Gemini

# stable GA Vertex AI endpoint
agent = Agent(model=Gemini(model="gemini-2.5-pro", api_version="v1"))

or set GOOGLE_GENAI_API_VERSION=v1 in the environment.

Testing

  • Added 8 focused unit tests in tests/unittests/models/test_google_llm.py covering the field, the env var, precedence rules, the live API path, and the request-config patching, plus an assertion that the default is unchanged.
  • Full test_google_llm.py suite passes (74 tests); pyink and isort clean.

Fixes #3246.

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.
@google-cla

google-cla Bot commented Jun 22, 2026

Copy link
Copy Markdown

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.

@vaibhav-patel

Copy link
Copy Markdown
Author

@googlebot I signed it!

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.

Support for stable Vertex AI v1 API

1 participant