fix(gemini): route Google AI Studio auth via x-goog-api-key header (#7893)#11961
Merged
Conversation
This was referenced Apr 18, 2026
1 task
8 tasks
This was referenced May 24, 2026
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.
Gemini AI Studio requests now succeed on both legacy AIza… and new AQ.-prefixed API keys. Google's OpenAI-compat endpoint rejects Authorization: Bearer with
HTTP 400 Multiple authentication credentials receivedfor AQ. keys (confirmed by Google AI Dev Forum thread and 8+ user reports on #7893).Salvaged from @AviArora02-commits' PR #8530 onto current main. Original authorship preserved via cherry-pick. Also supersedes #8128, #9247, #8172 which addressed the same bug with narrower coverage or incorrect logic.
Changes
run_agent.py: primary client init +_apply_client_headers_for_base_url(mid-session switch)agent/auxiliary_client.py:_resolve_api_key_provider(pool + non-pool) +resolve_provider_clientapi_key=real_key→api_key="not-used"+default_headers={x-goog-api-key: real_key}when base_url targetsgenerativelanguage.googleapis.comtests/hermes_cli/test_gemini_provider.pyValidation
tests/hermes_cli/test_gemini_provider.py(43 tests)tests/agent/test_auxiliary_client.py(58 tests)Conflict resolution: PR #8530's test updates targeted tests that #11472 deleted; dropped those re-introductions and kept the new regression coverage in test_gemini_provider.py.
Closes #7893
Supersedes #8128, #9247, #8172, #8530