Skip to content

Conversation

@nicodemuz
Copy link

Q A
Bug fix? no
New feature? yes
Docs? need to be updated
License MIT

Vertex AI supports multiple methods of authentication. This PR adds support for API keys.

@carsonbot carsonbot added Feature New feature Platform Issues & PRs about the AI Platform component Status: Needs Review labels Dec 15, 2025
@OskarStark
Copy link
Contributor

Please add tests

@nicodemuz
Copy link
Author

Please add tests

Sure. Before I spend more time on tests, can you review that the approach/solution is correct? I'm relatively new to the symfony/ai project and not sure how other Bridges handle this.

Copy link
Contributor

@OskarStark OskarStark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. WDYT @chr-hertel ?

@nicodemuz can you please check if it is also supported for Gemini. This should also be configurable via the AiBundle config

@nicodemuz
Copy link
Author

Looks good to me. WDYT @chr-hertel ?

@nicodemuz can you please check if it is also supported for Gemini. This should also be configurable via the AiBundle config

@OskarStark You mean to configure whether the key should be sent via a query parameter or the headers? For Gemini, I think the API key is sent via HTTP headers:

return new RawHttpResult($this->httpClient->request('POST', $url, [
'headers' => [
'x-goog-api-key' => $this->apiKey,
],
'json' => array_merge($generationConfig, $payload),
]));

@OskarStark
Copy link
Contributor

@OskarStark You mean to configure whether the key should be sent via a query parameter or the headers? For Gemini, I think the API key is sent via HTTP headers:

Thanks for double checking

Comment on lines 26 to 28
========================================
1. Application Default Credentials (ADC)
========================================
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
========================================
1. Application Default Credentials (ADC)
========================================
Application Default Credentials (ADC)
-------------------------------------

Same for the other headlines

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the headings as per your suggestion. I was trying to make these headings as subheadings of "Authentication", but now they became top level headings:

image

@nicodemuz
Copy link
Author

Please add tests

@OskarStark I'm trying to fix the tests, and there's one test failing with:

1) Symfony\AI\AiBundle\Tests\DependencyInjection\AiBundleTest::testExtensionLoadDoesNotThrow
Failed to load platform service "ai.platform.vertexai" or call getModelCatalog(). Original error: Symfony\AI\Platform\Bridge\VertexAi\PlatformFactory::create(): Argument #3 ($httpClient) must be of type ?Symfony\Contracts\HttpClient\HttpClientInterface, string given, called in /home/runner/work/ai/ai/src/ai-bundle/vendor/symfony/dependency-injection/ContainerBuilder.php on line 1178 (in /home/runner/work/ai/ai/src/ai-bundle/vendor/symfony/ai-vertex-ai-platform/PlatformFactory.php:33)

/home/runner/work/ai/ai/src/ai-bundle/tests/DependencyInjection/AiBundleTest.php:123

Is it trying to run code from some other repo/branch? Since it's referring to ai-vertex-ai-platform/PlatformFactory.php:33? How do I fix this?

@OskarStark
Copy link
Contributor

Tests still needed


require_once __DIR__.'/bootstrap.php';

$platform = PlatformFactory::create(env('GOOGLE_CLOUD_LOCATION'), env('GOOGLE_CLOUD_PROJECT'), env('GOOGLE_CLOUD_VERTEX_API_KEY'), httpClient: adc_aware_http_client());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but this still uses the adc_aware_http_client

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Fixed! 👍

@OskarStark
Copy link
Contributor

It looks like your committer email is not associated with your GitHub account

Copy link
Contributor

@OskarStark OskarStark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Comment on lines 56 to 59
if (null !== $this->apiKey) {
$url .= '?key='.$this->apiKey;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Member

@chr-hertel chr-hertel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we def need this - thanks @nicodemuz!

only minor comments but broken pipeline

@nicodemuz
Copy link
Author

Yes, we def need this - thanks @nicodemuz!

only minor comments but broken pipeline

Any ideas about the broken pipeline? See my comment here:

#1139 (comment)

@nicodemuz
Copy link
Author

It looks like your committer email is not associated with your GitHub account

Will this prevent from the PR getting merged? I remember getting a lot of spam after entering my email address in public repos.

@OskarStark
Copy link
Contributor

How should I address this? Should I add the new parameter as the last parameter in PlatformFactory::create()?

Did you rebased properly?

Nico Hiort af Ornäs and others added 23 commits December 21, 2025 14:48
Co-authored-by: Oskar Stark <[email protected]>
@nicodemuz nicodemuz force-pushed the VertexAiApiKeySupport branch from 9495255 to 30497c4 Compare December 21, 2025 12:49
@nicodemuz
Copy link
Author

How should I address this? Should I add the new parameter as the last parameter in PlatformFactory::create()?

Did you rebased properly?

@OskarStark I have rebased just now with the main branch of symfony/ai. The tests are still failing:

Symfony\AI\AiBundle\Tests\DependencyInjection\AiBundleTest::testExtensionLoadDoesNotThrow
Failed to load platform service "ai.platform.vertexai" or call getModelCatalog(). Original error: Symfony\AI\Platform\Bridge\VertexAi\PlatformFactory::create(): Argument 3 ($httpClient) must be of type ?Symfony\Contracts\HttpClient\HttpClientInterface, string given, called in /home/runner/work/ai/ai/src/ai-bundle/vendor/symfony/dependency-injection/ContainerBuilder.php on line 1174 (in /home/runner/work/ai/ai/src/ai-bundle/vendor/symfony/ai-vertex-ai-platform/PlatformFactory.php:36)

/home/runner/work/ai/ai/src/ai-bundle/tests/DependencyInjection/AiBundleTest.php:123

@OskarStark
Copy link
Contributor

Looks like the Order of the arguments is wrong.

IIRC @Guikingone had the same issue in the past, right?

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

Labels

Feature New feature Platform Issues & PRs about the AI Platform component Status: Needs Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants