Skip to content

fix(doctor): use ?key= auth for Gemini API key validation#23364

Closed
uzunkuyruk wants to merge 1 commit into
NousResearch:mainfrom
uzunkuyruk:fix/doctor-gemini-apikey-auth
Closed

fix(doctor): use ?key= auth for Gemini API key validation#23364
uzunkuyruk wants to merge 1 commit into
NousResearch:mainfrom
uzunkuyruk:fix/doctor-gemini-apikey-auth

Conversation

@uzunkuyruk

Copy link
Copy Markdown
Contributor

What does this PR do?

_probe_apikey_provider uses Authorization: Bearer for all providers, but Google's generativelanguage.googleapis.com requires the API key as a ?key= query parameter. Sending a Bearer token to /v1beta/models always returns HTTP 401 — even for a perfectly valid key — causing hermes doctor to falsely report Gemini credentials as invalid.

Fix: before firing the health-check request, detect URLs pointing to generativelanguage.googleapis.com and switch to params={"key": key} auth, matching the Gemini REST API contract. All other providers continue through the existing Bearer path unchanged.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

References

Fixes #23354

Checklist

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • My PR contains only changes related to this fix

_probe_apikey_provider uses Authorization: Bearer for all providers,
but Google's generativelanguage.googleapis.com requires key= as a
query parameter instead. Bearer auth always returns HTTP 401 on the
/v1beta/models endpoint even for a valid key, so doctor falsely
reported Gemini keys as invalid.

Fix: detect generativelanguage.googleapis.com URLs and switch to
params={"key": key} auth, matching the Gemini REST API contract.

Fixes NousResearch#23354
@uzunkuyruk uzunkuyruk force-pushed the fix/doctor-gemini-apikey-auth branch from 53c70e8 to 67b3a06 Compare May 10, 2026 18:53
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #21490 / #20642 — same fix (use ?key= query param instead of Bearer auth for Gemini doctor probe). Multiple competing PRs exist for this fix.

@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard provider/gemini Google Gemini (AI Studio, Cloud Code) duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists labels May 10, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Closing as superseded by #11961.

Triage notes (high confidence):
Gemini auth fix already on main (hermes_cli/doctor.py:1549 routes generativelanguage.googleapis.com through x-goog-api-key header; PR #11961 merged). PR is mostly cosmetic black-style reformatting with the auth fix superseded.

Thanks for the contribution — the underlying problem this PR addresses has been resolved by the linked PR on current main. If you believe this was closed in error, please comment and we'll reopen.

(Bulk-closed during a CLI PR triage sweep.)

@teknium1 teknium1 closed this May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists provider/gemini Google Gemini (AI Studio, Cloud Code) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hermes Doctor flags Google Gemini API key as invalid even when the key works

3 participants