Python: fix(google): allow Vertex AI usage without API key when using ADC#13510
Open
PrathamAditya wants to merge 1 commit intomicrosoft:mainfrom
Open
Python: fix(google): allow Vertex AI usage without API key when using ADC#13510PrathamAditya wants to merge 1 commit intomicrosoft:mainfrom
PrathamAditya wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Gate API key validation behind use_vertexai=False so that GoogleAIChatCompletion can be initialized with Application Default Credentials (ADC) when using Vertex AI. Adds a unit test to verify that no API key is required when use_vertexai=True. Fixes microsoft#13483
Contributor
Author
|
@moonbox3 since you added tag to this bug, can you review this PR? Or Can tag someone who can. |
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.
Allow GoogleAIChatCompletion to be initialized without an API key when use_vertexai=True, enabling authentication via Application Default Credentials (ADC).
Adds a unit test covering the ADC-based Vertex AI scenario.
Fixes #13483
Motivation and Context
Vertex AI authentication commonly relies on Application Default Credentials rather than explicit API keys. The current implementation enforces an API key even when use_vertexai=True, which prevents valid ADC-based usage.
This change aligns the SDK behavior with Google’s recommended authentication model for Vertex AI.
Description
The API key validation logic in GoogleAIChatCompletion is updated to only require an API key when use_vertexai=False. When Vertex AI is enabled, API key validation is skipped and authentication is assumed to be handled via ADC.
A unit test is added to verify that initializing the client with use_vertexai=True does not require an API key.
Contribution Checklist