Skip to content

feat(gemini): authenticate using x-goog-api-key header - #661

Merged
dwash96 merged 1 commit into
cecli-dev:v1.3.2from
DinoChiesa:gemini-x-goog-api-key
Aug 31, 2026
Merged

dwash96 merged 1 commit into
cecli-dev:v1.3.2from
DinoChiesa:gemini-x-goog-api-key

Conversation

@DinoChiesa

Copy link
Copy Markdown

Switch Gemini provider authentication from query parameters (?key=...) to the x-goog-api-key HTTP header in alignment with Google Gemini API guidelines.

  • Override build_headers in GeminiProvider to populate x-goog-api-key and suppress Authorization: Bearer.

  • Remove key query parameter construction in gemini_complete and gemini_stream domain adapters.

  • Add test coverage in tests/helpers/test_llms_gemini_auth.py.

Co-authored-by: cecli (gemini/gemini-3.6-flash)

Switch Gemini provider authentication from query parameters (`?key=...`)
to the `x-goog-api-key` HTTP header in alignment with Google Gemini API
guidelines.

- Override `build_headers` in `GeminiProvider` to populate
  `x-goog-api-key` and suppress `Authorization: Bearer`.

- Remove `key` query parameter construction in `gemini_complete` and
  `gemini_stream` domain adapters.

- Add test coverage in `tests/helpers/test_llms_gemini_auth.py`.

Co-authored-by: cecli (gemini/gemini-3.6-flash)
@dwash96

dwash96 commented Aug 31, 2026 •

Copy link
Copy Markdown
Collaborator

Oh man, of course there's a header for it! Thank you 🙏

Edit: This really did surprise me during the litellm removal/creating the api domain concept that this was how gemini authenticates. I definitely saw it in the mitmproxy logs while trying to figure out the API differences between the 2+ and 3+ models

@dwash96
dwash96 changed the base branch from main to v1.3.2 August 31, 2026 00:37
@dwash96
dwash96 merged commit 96aae65 into cecli-dev:v1.3.2 Aug 31, 2026
This was referenced Aug 31, 2026
@DinoChiesa
DinoChiesa deleted the gemini-x-goog-api-key branch September 1, 2026 03:43
JessicaMulein pushed a commit to Digital-Defiance/cecli that referenced this pull request Sep 23, 2026
feat(gemini): authenticate using x-goog-api-key header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants