fix(gemini): use x-goog-api-key header instead of Bearer token#9247
Closed
Tranquil-Flow wants to merge 1 commit into
Closed
fix(gemini): use x-goog-api-key header instead of Bearer token#9247Tranquil-Flow wants to merge 1 commit into
Tranquil-Flow wants to merge 1 commit into
Conversation
Google's Gemini API rejects requests with HTTP 400 "Multiple authentication credentials received" when the OpenAI SDK injects both an Authorization: Bearer header and the x-goog-api-key header. Route the API key through x-goog-api-key and set a placeholder api_key to suppress the SDK's automatic Bearer header. Closes NousResearch#7893
Contributor
|
Closing in favor of #11961 (merged), which uses the same |
1 task
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.
What
Routes the Gemini API key through the
x-goog-api-keyheader and sets a placeholderapi_keyto suppress the OpenAI SDK's automaticAuthorization: Bearerheader.Why
Google's Gemini API rejects requests with HTTP 400 "Multiple authentication credentials received" when both
Authorization: Bearerandx-goog-api-keyheaders are present. The OpenAI SDK automatically injects the Bearer header whenapi_keyis set.How
_apply_client_headers_for_base_url(used during model switches), matching the existing pattern for Copilot, Kimi, and Qwen providers.Test plan
pytest tests/hermes_cli/test_gemini_provider.py -v— all 44 tests passPlatform
All platforms
Closes #7893