hermes - 💡(How to fix) Fix [Bug]: Gemini setup reports API keys as paid without a reliable tier signal [1 pull requests]

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…

Error Message

Additional Logs / Traceback (optional)

Root Cause

for a free-tier key, because the Gemini generation request succeeds with HTTP 200 but does not include x-ratelimit-* headers.

Fix Action

Fixed

Code Example

agent/gemini_native_adapter.py
probe_gemini_tier()

---

if 200 <= resp.status_code < 300:
    return "paid"

---

POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent

---

status=200
rate_limit_headers=(none)

---

API key valid; tier could not be determined. Check active limits in AI Studio: https://aistudio.google.com/rate-limit

---

Tier check: paid ✓

---

https://aistudio.google.com/rate-limit
https://aistudio.google.com/projects

---

Not uploaded. This report is based on setup behavior and a minimal API probe; no debug logs are needed to reproduce.

---



---

if 200 <= resp.status_code < 300:
    return "paid"

---

if 200 <= resp.status_code < 300:
    return "unknown"
RAW_BUFFERClick to expand / collapse

Bug Description

Hermes setup checks Gemini tier by calling gemini-2.5-flash and then treats any 2xx response as paid when x-ratelimit-limit-requests-per-day is absent.

Relevant code:

agent/gemini_native_adapter.py
probe_gemini_tier()

Buggy logic:

if 200 <= resp.status_code < 300:
    return "paid"

I searched existing issues for probe_gemini_tier, x-ratelimit-limit-requests-per-day, "Tier check", "Google AI Studio free tier", and related Gemini setup reports and did not find an exact duplicate.

Steps to Reproduce

  1. Install/update Hermes from the current installer/main.
  2. Run hermes setup.
  3. Select Google AI Studio / Gemini as the provider.
  4. Enter a Google AI Studio API key.
  5. Observe the tier check message.

I also tested both a known free-tier Google AI Studio API key and a known paid/billing-enabled Gemini API key against the same endpoint:

POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent

Both returned:

status=200
rate_limit_headers=(none)

Expected Behavior

A successful Gemini generation probe should validate that the API key works, but it should not classify the key as paid unless there is a reliable paid-tier signal.

If rate-limit headers are absent, probe_gemini_tier() should return unknown rather than paid.

Setup could print something like:

API key valid; tier could not be determined. Check active limits in AI Studio: https://aistudio.google.com/rate-limit

Actual Behavior

Setup can print:

Tier check: paid ✓

for a free-tier key, because the Gemini generation request succeeds with HTTP 200 but does not include x-ratelimit-* headers.

Google's docs point users to AI Studio to view active rate limits, and note that rate limits are applied per project, not per API key:

https://aistudio.google.com/rate-limit
https://aistudio.google.com/projects

Affected Component

Setup / Installation

Messaging Platform (if gateway-related)

No response

Debug Report

Not uploaded. This report is based on setup behavior and a minimal API probe; no debug logs are needed to reproduce.

Operating System

Fedora 44 KDE

Python Version

Python 3.11.15

Hermes Version

No response

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

This appears inconsistent with how other providers are handled in Hermes:

  • Nous uses a provider-owned account/subscription API and checks a real subscription field.
  • OpenRouter and AI Gateway use provider-owned model catalog pricing to label models free/paid.
  • Runtime billing/quota classification reacts to actual provider errors such as 402, insufficient_quota, billing_not_active, or rate-limit errors.

For Gemini API keys, a 2xx generation response without rate-limit headers does not distinguish free vs paid.

Proposed Fix (optional)

Change probe_gemini_tier() so a 2xx response without a reliable tier signal returns unknown, not paid.

For example, replace:

if 200 <= resp.status_code < 300:
    return "paid"

with:

if 200 <= resp.status_code < 300:
    return "unknown"

Are you willing to submit a PR for this?

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

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