hermes - ✅(Solved) Fix Gemini provider: /model selection cannot route to /v1beta (generateContent endpoint) [1 pull requests, 1 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#16484Fetched 2026-04-28 06:53:00
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Participants
Timeline (top)
labeled ×4cross-referenced ×1unsubscribed ×1

Root Cause

Root cause - Hermes always appends /chat/completions to base_url - Gemini /v1beta endpoint does not support this path - Gemini requires x-goog-api-key header and native JSON body format, not OpenAI format

Fix Action

Fix / Workaround

Current workaround Conversational trigger — detect "用 Gemini" → direct curl to Antigravity Tools proxy → bypass Hermes routing entirely.

PR fix notes

PR #16499: fix(gemini): route /model gemini to native /v1beta endpoint (#16484)

Description (problem / solution / changelog)

What does this PR do?

The runtime provider resolver in hermes_cli/runtime_provider.py had no explicit branch for the gemini provider, so /model switches to a Gemini model would fall through to the generic OpenAI-style path. With api_mode=chat_completions and a possibly stale base_url left over from a previous provider, the OpenAI SDK would POST to {base_url}/chat/completions — which Google's native /v1beta API does not support (it speaks :generateContent + x-goog-api-key headers).

This adds a dedicated gemini branch that ensures base_url is always pointed at a Gemini-aware endpoint so GeminiNativeClient (already in agent/gemini_native_adapter.py) takes over and constructs the correct :generateContent URL itself.

Related Issue

Fixes #16484

Type of Change

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

Changes Made

  • hermes_cli/runtime_provider.py: add explicit elif provider == "gemini" branch in _apply_provider_runtime_kwargs that
    • defaults base_url to https://generativelanguage.googleapis.com/v1beta (the canonical native endpoint)
    • honours GEMINI_BASE_URL env override
    • honours model.base_url from config when provider: gemini
    • preserves the /v1beta/openai OpenAI-compatibility suffix when explicitly configured (that path does accept /chat/completions)
    • recovers from a stale non-Google pool entry base_url (e.g. left over from a previous /model switch on a different provider) instead of appending /chat/completions to it
  • tests/hermes_cli/test_runtime_provider_resolution.py: 4 new tests covering each of the above branches

How to Test

  1. Configure a Google AI Studio API key: export GEMINI_API_KEY=...
  2. From a fresh hermes session on a non-gemini provider (e.g. anthropic), run /model gemini gemini-2.5-pro
  3. Send a prompt — request now routes to https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro:generateContent (verifiable via DEBUG logs / network capture) instead of …/v1beta/chat/completions (404).
  4. Run the test suite:
    pytest tests/hermes_cli/test_runtime_provider_resolution.py -k gemini -q

All 4 new tests pass; full file (88 tests) passes.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(gemini):)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix
  • I've run pytest tests/hermes_cli/test_runtime_provider_resolution.py tests/hermes_cli/test_gemini_provider.py tests/agent/test_gemini_native_adapter.py -q and all tests pass
  • I've added tests for my changes

Changed files

  • hermes_cli/runtime_provider.py (modified, +34/-0)
  • tests/hermes_cli/test_runtime_provider_resolution.py (modified, +111/-0)
RAW_BUFFERClick to expand / collapse

Problem Hermes /model menu appends /chat/completions to any provider base_url, making it impossible to reach Gemini's native /v1beta/models/{model}:generateContent endpoint.

Expected behavior
Select a Gemini model via /model gemini and have requests route to /v1beta with proper Gemini-native request format.

Root cause
- Hermes always appends /chat/completions to base_url
- Gemini /v1beta endpoint does not support this path
- Gemini requires x-goog-api-key header and native JSON body format, not OpenAI format

Current workaround
Conversational trigger — detect "用 Gemini" → direct curl to Antigravity Tools proxy → bypass Hermes routing entirely.

extent analysis

TL;DR

Modify the Hermes routing logic to conditionally append paths based on the selected provider, allowing Gemini requests to reach their native endpoint without the /chat/completions suffix.

Guidance

  • Identify the code responsible for appending /chat/completions to the base_url in Hermes and modify it to check the provider before appending the path.
  • Verify that the Gemini provider is correctly configured to use the native /v1beta/models/{model}:generateContent endpoint and to include the required x-goog-api-key header.
  • Update the request format for Gemini to use the native JSON body format instead of the OpenAI format.
  • Consider implementing a more robust routing mechanism in Hermes that can handle different provider-specific endpoints and request formats.

Example

# Pseudo-code example of conditional path appending
if provider == 'Gemini':
    url = base_url + '/v1beta/models/{model}:generateContent'
else:
    url = base_url + '/chat/completions'

Notes

The provided workaround using the Conversational trigger and Antigravity Tools proxy may not be scalable or reliable, and a more permanent fix should be implemented to modify the Hermes routing logic.

Recommendation

Apply workaround: Modify the Hermes routing logic to conditionally append paths based on the selected provider, as this will allow Gemini requests to reach their native endpoint without the /chat/completions suffix, and also update the request format to match Gemini's native requirements.

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