hermes - ✅(Solved) Fix [Bug]: hermes doctor validates Gemini API keys with Bearer auth instead of ?key= [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#25108Fetched 2026-05-14 03:48:52
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
labeled ×4commented ×1cross-referenced ×1

Root Cause

Doctor treats Gemini like a generic Bearer-token provider instead of using Gemini's native API-key authentication convention.

Fix Action

Fixed

PR fix notes

PR #25139: fix: use Gemini API key query auth in doctor

Description (problem / solution / changelog)

Bug

hermes doctor probed Google Generative Language /models with Authorization: Bearer, which returns false 401 invalid-key results for valid Gemini API keys. Google native Gemini API keys are supplied via the key query parameter.

Fixes #25108

Summary

Extract the generic /models probe request builder and make generativelanguage.googleapis.com use ?key= with URL encoding and no Bearer header. Other OpenAI-compatible providers continue to use Authorization: Bearer.

TDD / ATDD coverage

  • Added a focused regression test that reproduces the reported behavior.
  • Implemented the minimal production change needed to satisfy the regression.
  • Re-ran the targeted test file to guard nearby behavior.

Test plan

  • /Users/mudrii/src/hermes/hermes-agent/venv/bin/python -m pytest tests/hermes_cli/test_doctor_gemini_auth.py -q -o 'addopts=' -> 3 passed

Review notes

  • Kept the change scoped to the issue-specific runtime path.
  • No secrets are persisted or logged.

Changed files

  • hermes_cli/doctor.py (modified, +21/-4)
  • tests/hermes_cli/test_doctor_gemini_auth.py (added, +40/-0)

Code Example

Authorization: Bearer <GEMINI_API_KEY>

---

https://generativelanguage.googleapis.com/v1beta/models?key=<GEMINI_API_KEY>

---

httpx.get(url, params={"key": key}, headers={"User-Agent": ...})

---

curl "https://generativelanguage.googleapis.com/v1beta/models?key=$GEMINI_API_KEY"
RAW_BUFFERClick to expand / collapse

Bug Description

hermes doctor can falsely report a valid Gemini API key as invalid because the health check uses OpenAI-style Bearer authentication against Google's native Generative Language API.

For Gemini API keys, this is wrong:

Authorization: Bearer <GEMINI_API_KEY>

The native Gemini API accepts API-key authentication via query parameter:

https://generativelanguage.googleapis.com/v1beta/models?key=<GEMINI_API_KEY>

or equivalent Google API-key auth mechanisms.

Expected Behavior

When probing generativelanguage.googleapis.com / Gemini native API, hermes doctor should validate with Gemini-compatible API-key auth, e.g.:

httpx.get(url, params={"key": key}, headers={"User-Agent": ...})

and should not send Authorization: Bearer for Gemini API-key checks.

Actual Behavior

Doctor uses Bearer auth for the Gemini /models probe, causing HTTP 401 even when the key is valid and runtime Gemini calls work.

Reproduction

  1. Configure a valid GEMINI_API_KEY.
  2. Run hermes doctor.
  3. Observe Gemini is reported invalid or unhealthy.
  4. Verify the same key directly:
curl "https://generativelanguage.googleapis.com/v1beta/models?key=$GEMINI_API_KEY"
  1. Direct Gemini API-key auth succeeds, while Bearer auth fails with 401.

Root Cause

Doctor treats Gemini like a generic Bearer-token provider instead of using Gemini's native API-key authentication convention.

Suggested Fix

In the doctor provider probe, when provider is Gemini or the probe URL host matches generativelanguage.googleapis.com:

  • remove the Authorization: Bearer ... header
  • send params={"key": key} or another Gemini-supported API-key auth style
  • keep existing Bearer behavior for non-Gemini providers

Related Existing Reports / PRs

This is a focused current-main report related to:

  • #23354
  • #23364
  • #20642

Environment

  • Hermes Agent current main around commit 4fdfdf674
  • Provider: Gemini / Google AI Studio
  • Command: hermes doctor

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix [Bug]: hermes doctor validates Gemini API keys with Bearer auth instead of ?key= [1 pull requests, 1 comments, 2 participants]