Skip to content

Python: fix(google): allow Vertex AI usage without API key when using ADC#13510

Open
PrathamAditya wants to merge 1 commit intomicrosoft:mainfrom
PrathamAditya:main2
Open

Python: fix(google): allow Vertex AI usage without API key when using ADC#13510
PrathamAditya wants to merge 1 commit intomicrosoft:mainfrom
PrathamAditya:main2

Conversation

@PrathamAditya
Copy link
Contributor

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

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
@PrathamAditya PrathamAditya requested a review from a team as a code owner February 4, 2026 15:59
@moonbox3 moonbox3 added the python Pull requests for the Python Semantic Kernel label Feb 4, 2026
@github-actions github-actions bot changed the title fix(google): allow Vertex AI usage without API key when using ADC Python: fix(google): allow Vertex AI usage without API key when using ADC Feb 4, 2026
@PrathamAditya
Copy link
Contributor Author

@moonbox3 since you added tag to this bug, can you review this PR? Or Can tag someone who can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests for the Python Semantic Kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: Bug: GoogleAIChatCompletion wrongly requires api_key even when use_vertexai is set to True

2 participants