Skip to content

[Bug]: hermes doctor falsely reports valid Google AI Studio Gemini API key as invalid #21481

@thisisryanswift

Description

@thisisryanswift

Bug Description

hermes doctor reports a working Google AI Studio / Gemini API key as invalid.

Runtime Gemini chat succeeds with provider gemini, model gemma-4-31b-it, base URL https://generativelanguage.googleapis.com/v1beta, and GOOGLE_API_KEY set. For example, hermes chat -Q -q "Reply with exactly: hermes-ok" --max-turns 3 returns hermes-ok.

However, hermes doctor reports gemini (invalid API key) under API Connectivity.

Steps to Reproduce

  1. Set a working Google AI Studio key as GOOGLE_API_KEY.
  2. Configure:
    • model.provider = gemini
    • model.default = gemma-4-31b-it
    • model.base_url = https://generativelanguage.googleapis.com/v1beta
  3. Confirm runtime works: hermes chat -Q -q "Reply with exactly: hermes-ok" --max-turns 3 returns hermes-ok.
  4. Run hermes doctor.
  5. Observe gemini (invalid API key) under API Connectivity.

Expected Behavior

hermes doctor should report Gemini API connectivity as healthy for a valid Google AI Studio key.

Actual Behavior

hermes doctor reports gemini (invalid API key) and suggests checking GOOGLE_API_KEY, even though runtime Gemini chat works with the same key.

Affected Component

Other

Messaging Platform (if gateway-related)

No response

Debug Report

Not collected yet. Runtime validation and code-level diagnosis are included below.

Operating System

Linux

Python Version

3.11.15

Hermes Version

Config version 23; exact hermes version not captured yet.

Additional Logs / Traceback (optional)

Relevant doctor output:

◆ API Connectivity
  Checking gemini API...
  ✗ gemini (invalid API key)

Root Cause Analysis (optional)

hermes_cli/doctor.py dynamically includes the gemini API-key provider via _build_apikey_providers_list(). The dynamic tuple includes GOOGLE_API_KEY / GEMINI_API_KEY and https://generativelanguage.googleapis.com/v1beta/models.

The API-key health-check loop then uses the generic OpenAI-compatible probe: GET {base}/models with Authorization: Bearer <key>. Google AI Studio Gemini API keys are not OpenAI-compatible bearer tokens; they require Google-style auth such as x-goog-api-key: <key> or ?key=<key> against Gemini endpoints.

Proposed Fix (optional)

Add a Gemini-specific doctor connectivity path that probes GET {base}/models using x-goog-api-key, with default base URL https://generativelanguage.googleapis.com/v1beta and optional GEMINI_BASE_URL override. Also ensure GOOGLE_API_KEY, GEMINI_API_KEY, and GEMINI_BASE_URL are recognized by the .env provider-config detector.

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/cliCLI entry point, hermes_cli/, setup wizardprovider/geminiGoogle Gemini (AI Studio, Cloud Code)type/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions