feat(gemini): extend x-goog-api-client to TTS path + cite Google requirement

Follow-up to salvaged PR #47385. Google's partner-integration guidance
requires platform/library clients to send the x-goog-api-client header
(company-product/version) on Gemini API calls:
https://ai.google.dev/gemini-api/docs/partner-integration

- tools/tts_tool.py: add the header to the native Gemini TTS generateContent
  call (sibling site the original PR missed)
- agent/gemini_native_adapter.py: cite the requirement doc inline
- tests/tools/test_tts_gemini.py: assert the TTS header is present
- scripts/release.py: AUTHOR_MAP entry for dharmadhikari@google.com
This commit is contained in:
teknium1 2026-06-18 19:15:24 -07:00
parent 4437a5dade
commit ce2d3bed2a
No known key found for this signature in database
4 changed files with 28 additions and 1 deletions

View file

@ -889,6 +889,9 @@ class GeminiNativeClient:
"Content-Type": "application/json",
"Accept": "application/json",
"x-goog-api-key": self.api_key,
# Google requires platform/library clients to identify themselves
# via x-goog-api-client (company-product/version format).
# See https://ai.google.dev/gemini-api/docs/partner-integration
"User-Agent": f"hermes-agent/{_HERMES_VERSION} (gemini-native)",
"X-Goog-Api-Client": f"hermes-agent/{_HERMES_VERSION}",
}

View file

@ -475,6 +475,7 @@ AUTHOR_MAP = {
"bzarnitz13@gmail.com": "Beandon13",
"tony@tonysimons.dev": "asimons81",
"jetha@google.com": "jethac",
"dharmadhikari@google.com": "vishal-dharm",
"jani@0xhoneyjar.xyz": "deep-name",
# LINE messaging plugin (synthesis PR)
"32443648+leepoweii@users.noreply.github.com": "leepoweii",

View file

@ -115,6 +115,19 @@ class TestGenerateGeminiTts:
# Audio payload should match the PCM we put in
assert data[44:] == fake_pcm_bytes
def test_x_goog_api_client_header_is_set(self, tmp_path, monkeypatch, mock_gemini_response):
"""Google requires platform clients to send x-goog-api-client."""
from tools.tts_tool import _generate_gemini_tts
monkeypatch.setenv("GEMINI_API_KEY", "test-key")
with patch("requests.post", return_value=mock_gemini_response) as mock_post:
_generate_gemini_tts("Hi", str(tmp_path / "test.wav"), {})
headers = mock_post.call_args[1]["headers"]
assert "X-Goog-Api-Client" in headers
assert headers["X-Goog-Api-Client"].startswith("hermes-agent/")
def test_default_voice_and_model(self, tmp_path, monkeypatch, mock_gemini_response):
from tools.tts_tool import (
DEFAULT_GEMINI_TTS_MODEL,

View file

@ -1617,11 +1617,21 @@ def _generate_gemini_tts(text: str, output_path: str, tts_config: Dict[str, Any]
},
}
try:
from hermes_cli import __version__ as _hermes_version
except Exception:
_hermes_version = "0.0.0"
endpoint = f"{base_url}/models/{model}:generateContent"
response = requests.post(
endpoint,
params={"key": api_key},
headers={"Content-Type": "application/json"},
headers={
"Content-Type": "application/json",
# Google requires platform/library clients to identify themselves
# via x-goog-api-client. See https://ai.google.dev/gemini-api/docs/partner-integration
"X-Goog-Api-Client": f"hermes-agent/{_hermes_version}",
},
json=payload,
timeout=60,
)