feat: support Gemini authorization API keys#406
Open
elliot75 wants to merge 2 commits into
Open
Conversation
orangecatQ
pushed a commit
to orangecatQ/gemini-balance
that referenced
this pull request
Jul 14, 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.
Summary
AIza...keys and service-account-boundAQ.authorization keys in the configuration UI and backend validation.x-goog-api-keyheader for model, generation, streaming, token-counting, embedding, and Files API requests.AQ.keys from access logs and avoid logging custom header values.TemplateResponseand pin the verified FastAPI/Starlette versions so source builds work with the current template API.Context
Google AI Studio now creates authorization API keys by default. These keys use the
AQ.format, while the current UI only extractsAIza...keys and outbound Gemini requests place credentials in the URL query string.Google documentation: https://ai.google.dev/gemini-api/docs/api-key
Compatibility
AIza...keys remain supported.CUSTOM_HEADERSare preserved, but the key selected by the key manager always wins forx-goog-api-key.Testing
python -m unittest discover -s tests -v— 18 tests passed./,/keys,/config,/logs, and/health; all returned HTTP 200.An actual Gemini request was not made in the automated test suite because it would require a real API key.