Skip to content

The agent that grows with you

fix(gemini): stop rerouting AQ. keys off the default Studio surface

liuhao1024c19246557a23
diff --git a/agent/gemini_native_adapter.py b/agent/gemini_native_adapter.py
index 9bb54037b49..d06255bc1ef 100644
--- a/agent/gemini_native_adapter.py
+++ b/agent/gemini_native_adapter.py
@@ -34,9 +34,11 @@ except Exception:
_API_CLIENT = f"hermes-agent/{_HERMES_VERSION}" # client context per Gemini's partner-integration guidance
DEFAULT_GEMINI_BASE_URL = "https://generativelanguage.googleapis.com/v1beta"
-# Vertex AI express-mode keys (``AQ.…``) only authenticate against aiplatform, which serves the
+# A Vertex AI express-mode base, when the user configures one explicitly: aiplatform serves the
# same native API under ``{version}/publishers/google/models/…``; the base carries that prefix so
# every ``{base}/models/{model}:…`` builder (chat, tier probe, TTS) needs no path branching.
+# The key itself never decides routing — Google now issues ``AQ.…`` keys for BOTH Google AI Studio
+# and Vertex express mode (#115306), so an express key reaches aiplatform only via this base config.
VERTEX_EXPRESS_BASE_URL = "https://aiplatform.googleapis.com/v1beta1/publishers/google"
# Published max output-token ceiling shared by every current Gemini text model; used
@@ -58,6 +60,20 @@ _STANDARD_KEY_GUIDANCE = (
"delete any leftover Windows/system copy of those variables, and restart. A stale shell key can hide "
"the .env value. Details: https://ai.google.dev/gemini-api/docs/api-key"
)
+# Google issues ``AQ.…`` keys for both AI Studio and Vertex express mode; each surface only accepts
+# its own keys, so a 403 usually means the key/host pairing is crossed rather than a bad key (#115306).
+_EXPRESS_KEY_ON_STUDIO_GUIDANCE = (
+ "\n\nGoogle issues 'AQ.' keys for both Google AI Studio and Vertex AI express mode, and each surface "
+ "only accepts its own keys: a Vertex express key always gets 403 PERMISSION_DENIED on "
+ "generativelanguage.googleapis.com. If this key came from Google Cloud / Vertex (express mode), point "
+ "the provider at the express surface, e.g. set base_url / GEMINI_BASE_URL to "
+ "https://aiplatform.googleapis.com/v1beta1."
+)
+_STUDIO_KEY_ON_EXPRESS_GUIDANCE = (
+ "\n\nIf this 'AQ.' key came from Google AI Studio (https://aistudio.google.com/apikey), it only works "
+ "on the default generativelanguage.googleapis.com host — remove the explicit aiplatform base_url so "
+ "the default surface is used."
+)
# Stands in for a model turn that never arrived (stream failure / interrupt / quota
# fallback) when a human user text turn directly follows a tool-result turn, keeping
# the request alternation-valid while the user's message stays a turn of its own
@@ -104,11 +120,6 @@ def gemini_requires_tool_call_ids(model: str) -> bool:
_API_VERSION_SEGMENT = re.compile(r"^v\d+(?:alpha|beta)?\d*$", re.IGNORECASE)
-def is_vertex_express_key(api_key: str) -> bool:
- """Vertex AI express-mode keys are ``AQ.…``; AI Studio keys are ``AIza…``."""
- return str(api_key or "").strip().startswith("AQ.")
-
-
def is_vertex_express_base_url(base_url: str) -> bool:
"""An aiplatform host without a project path — the express surface. The OAuth Vertex provider's
``…/projects/{p}/locations/{r}/endpoints/openapi`` base is OpenAI-compatible and must stay off
@@ -117,7 +128,7 @@ def is_vertex_express_base_url(base_url: str) -> bool:
return "aiplatform.googleapis.com" in normalized and "/projects/" not in normalized
-def normalize_gemini_base_url(base_url: Optional[str], api_key: str = "") -> str:
+def normalize_gemini_base_url(base_url: Optional[str]) -> str:
"""Gemini native base URL with the API version segment guaranteed. Google's own client treats the
base as a host root and appends the version itself, so users configure ``GEMINI_BASE_URL`` (or a
proxy root like ``http://localhost:4000/gemini``) that way; our request builders expect
@@ -128,16 +139,13 @@ def normalize_gemini_base_url(base_url: Optional[str], api_key: str = "") -> str
decide routing (see ``is_native_gemini_base_url``).
A Vertex express base (``aiplatform.googleapis.com``, ``…/v1beta1`` or the full
- ``…/v1beta1/publishers/google``) is completed to the ``publishers/google`` form. With ``api_key``
- given, an express key (``AQ.``) that would land on the Studio host is routed to
- ``VERTEX_EXPRESS_BASE_URL`` instead — it can only ever 403 there — while an explicit proxy or
- Vertex base is left alone."""
+ ``…/v1beta1/publishers/google``) is completed to the ``publishers/google`` form. The key never
+ decides routing: Google issues ``AQ.…`` keys for both AI Studio and Vertex express mode
+ (#115306), so an express key reaches aiplatform only through this explicit base configuration."""
trimmed = str(base_url or "").strip().rstrip("/")
trimmed = re.sub(r"/openai\Z", "", trimmed, flags=re.IGNORECASE).rstrip("/")
if not trimmed:
trimmed = DEFAULT_GEMINI_BASE_URL
- if is_vertex_express_key(api_key) and "generativelanguage.googleapis.com" in trimmed.lower():
- return VERTEX_EXPRESS_BASE_URL
if is_vertex_express_base_url(trimmed):
if trimmed.lower().endswith("/publishers/google"):
return trimmed
@@ -171,7 +179,7 @@ def probe_gemini_tier(
key = (api_key or "").strip()
if not key:
return "unknown"
- base = normalize_gemini_base_url(base_url, key)
+ base = normalize_gemini_base_url(base_url)
payload = {"contents": [{"role": "user", "parts": [{"text": "hi"}]}], "generationConfig": {"maxOutputTokens": 1}}
headers = {"Content-Type": "application/json", "X-Goog-Api-Client": _API_CLIENT}
try:
@@ -203,6 +211,25 @@ def is_free_tier_quota_error(error_message: str) -> bool:
return bool(error_message) and "free_tier" in error_message.lower()
+def wrong_gemini_surface_guidance(base_url: str, api_key: str, err_status: str) -> str:
+ """Guidance text for the 403 PERMISSION_DENIED key/host mismatches Google's AQ. rollout created.
+
+ Google issues ``AQ.…`` keys for both AI Studio and Vertex express mode, so neither the key prefix
+ nor the host alone proves the pairing; on a PERMISSION_DENIED, point the user at the surface their
+ key likely belongs to: an AQ. key rejected by the Studio host may be an express key (the explicit
+ aiplatform base_url is that key's only route there), and any key rejected by an explicitly
+ configured aiplatform base may be an AI Studio key (#115306). Empty string when the shape matches
+ neither."""
+ if (err_status or "").strip().upper() != "PERMISSION_DENIED":
+ return ""
+ normalized = str(base_url or "").strip().lower()
+ if is_vertex_express_base_url(normalized):
+ return _STUDIO_KEY_ON_EXPRESS_GUIDANCE
+ if "generativelanguage.googleapis.com" in normalized and str(api_key or "").strip().upper().startswith("AQ."):
+ return _EXPRESS_KEY_ON_STUDIO_GUIDANCE
+ return ""
+
+
def is_standard_key_auth_error(
status: int, error_message: str, reason: str = "", *, api_key: str = "",
) -> bool:
@@ -716,7 +743,7 @@ def _error_object(body_text: str) -> Dict[str, Any]:
def gemini_http_error(
- response: httpx.Response, *, body_text: Optional[str] = None, api_key: str = "",
+ response: httpx.Response, *, body_text: Optional[str] = None, api_key: str = "", base_url: str = "",
) -> GeminiAPIError:
status = response.status_code
body_text = (_response_text(response) if body_text is None else body_text) or ""
@@ -735,6 +762,8 @@ def gemini_http_error(
message += _FREE_TIER_GUIDANCE
if is_standard_key_auth_error(status, err_message or body_text, reason, api_key=api_key):
message += _STANDARD_KEY_GUIDANCE
+ if status == 403:
+ message += wrong_gemini_surface_guidance(base_url, api_key, err_status)
return GeminiAPIError(
message, code=_HTTP_ERROR_CODES.get(status, f"gemini_http_{status}"), status_code=status, response=response,
retry_after=retry_after, details={"status": err_status, "reason": reason, "metadata": metadata, "message": err_message},
@@ -755,7 +784,7 @@ class GeminiNativeClient:
if not (api_key or "").strip():
raise RuntimeError(_MISSING_KEY_ERROR)
self.api_key, self.is_closed = api_key, False
- self.base_url = normalize_gemini_base_url(base_url, api_key)
+ self.base_url = normalize_gemini_base_url(base_url)
self._default_headers = dict(default_headers or {})
self.chat = SimpleNamespace(completions=SimpleNamespace(create=self._create_chat_completion))
self._http = http_client or httpx.Client(timeout=timeout or httpx.Timeout(connect=15.0, read=600.0, write=30.0, pool=30.0))
@@ -798,7 +827,7 @@ class GeminiNativeClient:
return self._stream_completion(model, url + "streamGenerateContent?alt=sse", request, timeout)
response = self._http.post(url + "generateContent", json=request, headers=self._headers(), timeout=timeout)
if response.status_code != 200:
- raise gemini_http_error(response, api_key=self.api_key)
+ raise gemini_http_error(response, api_key=self.api_key, base_url=self.base_url)
try:
payload = response.json()
except ValueError as exc:
@@ -813,7 +842,7 @@ class GeminiNativeClient:
with self._http.stream("POST", url, json=request, headers=headers, timeout=timeout) as response:
if response.status_code != 200:
raise gemini_http_error(
- response, body_text=read_streaming_error_body(response), api_key=self.api_key,
+ response, body_text=read_streaming_error_body(response), api_key=self.api_key, base_url=self.base_url,
)
tool_call_indices: Dict[str, Dict[str, Any]] = {}
for event in _iter_sse_events(response):
diff --git a/hermes_cli/doctor_connectivity.py b/hermes_cli/doctor_connectivity.py
index a99af007598..7ac5f44d412 100644
--- a/hermes_cli/doctor_connectivity.py
+++ b/hermes_cli/doctor_connectivity.py
@@ -247,12 +247,18 @@ def _apikey_request(key: str, base_env, default_url) -> tuple:
headers["User-Agent"] = "claude-code/0.1.0"
# Google's Generative Language API rejects ``Authorization: Bearer <api-key>`` with 401
# ACCESS_TOKEN_TYPE_UNSUPPORTED (reserved for OAuth 2 tokens); plain keys use ``x-goog-api-key``.
- if url and base_url_host_matches(url, "generativelanguage.googleapis.com"):
- from agent.gemini_native_adapter import normalize_gemini_base_url
- # A Vertex express key (AQ.) can only 403 on the Studio host; normalize routes it to aiplatform.
- url = normalize_gemini_base_url(url.rsplit("/models", 1)[0], key) + "/models"
- headers.pop("Authorization", None)
- headers["x-goog-api-key"] = key
+ if url and (base_url_host_matches(url, "generativelanguage.googleapis.com")
+ or base_url_host_matches(url, "aiplatform.googleapis.com")):
+ from agent.gemini_native_adapter import is_vertex_express_base_url, normalize_gemini_base_url
+ root = url.rsplit("/models", 1)[0]
+ if base_url_host_matches(url, "generativelanguage.googleapis.com") or is_vertex_express_base_url(root):
+ # Normalize guarantees the version segment and completes an explicitly configured express
+ # aiplatform base to the publishers form; the key itself never decides the surface — AQ.
+ # keys exist for both AI Studio and Vertex express mode (#115306). The OAuth Vertex
+ # ``…/endpoints/openapi`` base is OpenAI-compatible and stays exactly as configured.
+ url = normalize_gemini_base_url(root) + "/models"
+ headers.pop("Authorization", None)
+ headers["x-goog-api-key"] = key
return base, url, headers
diff --git a/hermes_cli/web_routers/config_env.py b/hermes_cli/web_routers/config_env.py
index 1a46447f7e0..1f8eb8b059c 100644
--- a/hermes_cli/web_routers/config_env.py
+++ b/hermes_cli/web_routers/config_env.py
@@ -916,8 +916,9 @@ async def validate_provider_credential(body: EnvVarUpdate, request: Request):
url, auth = probe
if key == "GEMINI_API_KEY":
from agent.gemini_native_adapter import normalize_gemini_base_url
- # A Vertex express key (AQ.) can only 403 on the Studio host; normalize routes it to aiplatform.
- url = normalize_gemini_base_url(url.rsplit("/models", 1)[0], value) + "/models"
+ # Normalize guarantees the version segment; the key itself never decides the surface —
+ # AQ. keys exist for both AI Studio and Vertex express mode (#115306).
+ url = normalize_gemini_base_url(url.rsplit("/models", 1)[0]) + "/models"
headers = {"Accept": "application/json"}
params = {}
if auth == "bearer":
diff --git a/tests/agent/test_gemini_key_surface_guidance.py b/tests/agent/test_gemini_key_surface_guidance.py
new file mode 100644
index 00000000000..e973dedac7b
--- /dev/null
+++ b/tests/agent/test_gemini_key_surface_guidance.py
@@ -0,0 +1,109 @@
+"""Tests for the 403 PERMISSION_DENIED key-surface guidance (#115306).
+
+Google issues ``AQ.`` keys for both Google AI Studio and Vertex AI express mode, and each
+surface only accepts its own keys. The prefix therefore never decides routing; instead, a
+403 PERMISSION_DENIED appends guidance pointing at the surface the key likely belongs to:
+
+- an ``AQ.`` key rejected by the default generativelanguage host may be a Vertex express key
+ (the explicit aiplatform base_url is its only route there), and
+- any key rejected by an explicitly configured aiplatform base may be an AI Studio key.
+"""
+
+from __future__ import annotations
+
+import json
+from unittest.mock import MagicMock
+
+from agent.gemini_native_adapter import gemini_http_error, wrong_gemini_surface_guidance
+
+# Concatenated so the file never contains a contiguous real-format key.
+_AQ_KEY = "AQ." + "C" * 24
+_AIZA_KEY = "AIza" + "Sy_TEST_" + "x" * 24
+
+_STUDIO_BASE = "https://generativelanguage.googleapis.com/v1beta"
+_EXPRESS_BASE = "https://aiplatform.googleapis.com/v1beta1/publishers/google"
+
+
+def _mock_response(status: int, body: str) -> MagicMock:
+ resp = MagicMock()
+ resp.status_code = status
+ resp.headers = {}
+ resp.text = body
+ return resp
+
+
+def _permission_denied_body() -> str:
+ return json.dumps({
+ "error": {
+ "code": 403,
+ "message": "Requests to this API aiplatform.googleapis.com method "
+ "google.cloud.aiplatform.v1beta1.PredictionService.StreamGenerateContent are blocked.",
+ "status": "PERMISSION_DENIED",
+ }
+ })
+
+
+class TestWrongGeminiSurfaceGuidance:
+ def test_aq_key_on_studio_host_points_at_express_surface(self):
+ text = wrong_gemini_surface_guidance(_STUDIO_BASE, _AQ_KEY, "PERMISSION_DENIED")
+ assert text and "aiplatform.googleapis.com/v1beta1" in text
+ assert "Vertex" in text
+
+ def test_key_on_express_base_points_at_studio_surface(self):
+ text = wrong_gemini_surface_guidance(
+ _EXPRESS_BASE, _AQ_KEY, "PERMISSION_DENIED"
+ )
+ assert text and "generativelanguage.googleapis.com" in text
+ assert "aistudio.google.com" in text
+
+ def test_non_permission_denied_status_gets_no_guidance(self):
+ assert (
+ wrong_gemini_surface_guidance(_STUDIO_BASE, _AQ_KEY, "UNAUTHENTICATED")
+ == ""
+ )
+ assert wrong_gemini_surface_guidance(_STUDIO_BASE, _AQ_KEY, "") == ""
+
+ def test_aiza_key_on_studio_host_gets_no_guidance(self):
+ # A legacy AIza key cannot be an express key; a bare 403 has another cause.
+ assert (
+ wrong_gemini_surface_guidance(_STUDIO_BASE, _AIZA_KEY, "PERMISSION_DENIED")
+ == ""
+ )
+
+ def test_vertex_oauth_openapi_base_gets_no_guidance(self):
+ # The .../projects/.../endpoints/openapi base is OpenAI-compatible, not the express surface.
+ base = "https://aiplatform.googleapis.com/v1beta1/projects/p/locations/global/endpoints/openapi"
+ assert wrong_gemini_surface_guidance(base, _AQ_KEY, "PERMISSION_DENIED") == ""
+
+
+class TestGeminiHttpErrorSurfaceGuidance:
+ def test_403_on_studio_host_appends_express_guidance(self):
+ err = gemini_http_error(
+ _mock_response(403, _permission_denied_body()),
+ api_key=_AQ_KEY,
+ base_url=_STUDIO_BASE,
+ )
+ assert "aiplatform.googleapis.com/v1beta1" in str(err)
+ assert err.status_code == 403
+
+ def test_403_on_express_base_appends_studio_guidance(self):
+ err = gemini_http_error(
+ _mock_response(403, _permission_denied_body()),
+ api_key=_AQ_KEY,
+ base_url=_EXPRESS_BASE,
+ )
+ assert "aistudio.google.com" in str(err)
+
+ def test_403_without_aq_key_keeps_raw_message(self):
+ body = json.dumps({
+ "error": {
+ "code": 403,
+ "message": "Location is not found",
+ "status": "PERMISSION_DENIED",
+ }
+ })
+ err = gemini_http_error(
+ _mock_response(403, body), api_key=_AIZA_KEY, base_url=_STUDIO_BASE
+ )
+ assert "aiplatform.googleapis.com/v1beta1" not in str(err)
+ assert "aistudio.google.com" not in str(err)
diff --git a/tests/agent/test_gemini_native_adapter.py b/tests/agent/test_gemini_native_adapter.py
index 268452ac330..ee4eba984cc 100644
--- a/tests/agent/test_gemini_native_adapter.py
+++ b/tests/agent/test_gemini_native_adapter.py
@@ -792,20 +792,23 @@ def test_iter_sse_events_stops_at_done_and_ignores_trailing_frames():
@pytest.mark.parametrize(
"api_key, configured, expected_prefix",
[
- # Express key + default Studio host: the only place it can never work → aiplatform express surface.
- ("AQ.express-key", None, "https://aiplatform.googleapis.com/v1beta1/publishers/google/models/"),
- # Control: Studio key keeps the Studio host.
+ # AQ. keys exist for BOTH AI Studio and Vertex express mode (#115306): the prefix never
+ # reroutes, so an AI-Studio AQ. key keeps working on the default Studio host.
+ ("AQ.studio-key", None, "https://generativelanguage.googleapis.com/v1beta/models/"),
+ # Control: legacy AIza Studio key keeps the Studio host too.
("AIza-test", None, "https://generativelanguage.googleapis.com/v1beta/models/"),
- # An explicit aiplatform base (host root or versioned) is completed to the publishers form.
+ # An explicit aiplatform base (host root or versioned) is completed to the publishers form —
+ # the express key's only route to aiplatform now that the prefix no longer reroutes.
("AQ.express-key", "https://aiplatform.googleapis.com", "https://aiplatform.googleapis.com/v1beta1/publishers/google/models/"),
("AIza-test", "https://aiplatform.googleapis.com/v1beta1", "https://aiplatform.googleapis.com/v1beta1/publishers/google/models/"),
# An explicit proxy is never overridden by the key shape.
- ("AQ.express-key", "http://localhost:4000/gemini", "http://localhost:4000/gemini/v1beta/models/"),
+ ("AQ.studio-key", "http://localhost:4000/gemini", "http://localhost:4000/gemini/v1beta/models/"),
],
)
-def test_native_client_routes_vertex_express_keys_to_aiplatform(api_key, configured, expected_prefix):
- """Vertex express keys (``AQ.``) 403 on generativelanguage; the request must hit
- ``aiplatform.googleapis.com/v1beta1/publishers/google/models/…`` unless the user pointed elsewhere."""
+def test_native_client_never_reroutes_aq_keys_off_the_configured_surface(api_key, configured, expected_prefix):
+ """Google issues ``AQ.`` keys for both AI Studio and Vertex express mode, so the key prefix must
+ not decide the surface (#115306): the default (or explicitly configured) base is used verbatim,
+ and an explicit aiplatform base is completed to ``…/publishers/google/models/…``."""
from agent.gemini_native_adapter import GeminiNativeClient
seen = []
diff --git a/tests/hermes_cli/test_gemini_express_key_probes.py b/tests/hermes_cli/test_gemini_express_key_probes.py
index 855c5b45b2a..f148b7568be 100644
--- a/tests/hermes_cli/test_gemini_express_key_probes.py
+++ b/tests/hermes_cli/test_gemini_express_key_probes.py
@@ -1,7 +1,8 @@
-"""Key-validation surfaces route Vertex AI express keys (``AQ.``) to aiplatform, matching chat (#114335).
+"""Key-validation surfaces never reroute a key by its prefix, matching chat (#115306).
-Sending an express key to generativelanguage.googleapis.com always 403s, so ``hermes doctor`` and the
-dashboard key test would report a working key as rejected while chat succeeded.
+Google issues ``AQ.`` keys for both Google AI Studio and Vertex express mode, so a key prefix can
+no longer pick the surface: ``hermes doctor`` and the dashboard key test probe the default Studio
+host, and an express key reaches aiplatform only through an explicitly configured base URL.
"""
from __future__ import annotations
@@ -13,18 +14,33 @@ from agent.gemini_native_adapter import VERTEX_EXPRESS_BASE_URL
_STUDIO_MODELS = "https://generativelanguage.googleapis.com/v1beta/models"
-def test_doctor_gemini_probe_routes_express_key_to_aiplatform():
+def test_doctor_gemini_probe_keeps_aq_keys_on_the_studio_host(monkeypatch):
from hermes_cli.doctor_connectivity import _apikey_request
- _, url, headers = _apikey_request("AQ.express-key", None, _STUDIO_MODELS)
+ _, url, headers = _apikey_request(
+ "AQ.studio-key", "GEMINI_BASE_URL", _STUDIO_MODELS
+ )
+ assert url == _STUDIO_MODELS
+ assert (
+ headers["x-goog-api-key"] == "AQ.studio-key" and "Authorization" not in headers
+ )
+
+ # Legacy AIza Studio keys keep hitting the Studio host as well.
+ assert (
+ _apikey_request("AIza-studio-key", "GEMINI_BASE_URL", _STUDIO_MODELS)[1]
+ == _STUDIO_MODELS
+ )
+
+ # An explicitly configured aiplatform base is still completed to the publishers form.
+ monkeypatch.setenv("GEMINI_BASE_URL", "https://aiplatform.googleapis.com")
+ _, url, headers = _apikey_request(
+ "AQ.express-key", "GEMINI_BASE_URL", _STUDIO_MODELS
+ )
assert url == VERTEX_EXPRESS_BASE_URL + "/models"
- assert headers["x-goog-api-key"] == "AQ.express-key" and "Authorization" not in headers
+ assert headers["x-goog-api-key"] == "AQ.express-key"
- # AI Studio keys keep hitting the Studio host.
- assert _apikey_request("AIza-studio-key", None, _STUDIO_MODELS)[1] == _STUDIO_MODELS
-
-def test_dashboard_gemini_key_probe_routes_express_key_to_aiplatform(monkeypatch):
+def test_dashboard_gemini_key_probe_keeps_aq_keys_on_the_studio_host(monkeypatch):
import hermes_cli.web_routers.config_env as mod
from hermes_cli.web_models import EnvVarUpdate
@@ -53,8 +69,8 @@ def test_dashboard_gemini_key_probe_routes_express_key_to_aiplatform(monkeypatch
monkeypatch.setattr(httpx, "AsyncClient", _Client)
monkeypatch.setattr(mod, "_require_token", lambda request: None)
- body = EnvVarUpdate(key="GEMINI_API_KEY", value="AQ.express-key")
+ body = EnvVarUpdate(key="GEMINI_API_KEY", value="AQ.studio-key")
out = asyncio.run(mod.validate_provider_credential(body, request=None)) # type: ignore[arg-type]
assert out["ok"] is True
- assert seen["url"] == VERTEX_EXPRESS_BASE_URL + "/models"
+ assert seen["url"] == _STUDIO_MODELS
diff --git a/tools/tts_streaming.py b/tools/tts_streaming.py
index 5c4ea4af63c..33f1fb1acce 100644
--- a/tools/tts_streaming.py
+++ b/tools/tts_streaming.py
@@ -300,7 +300,7 @@ class GeminiStreamer(StreamingTTSProvider):
voice = str(self.section.get("voice", DEFAULT_GEMINI_TTS_VOICE)).strip() or DEFAULT_GEMINI_TTS_VOICE
from agent.gemini_native_adapter import normalize_gemini_base_url
base_url = normalize_gemini_base_url(
- self.section.get("base_url") or get_env_value("GEMINI_BASE_URL") or DEFAULT_GEMINI_TTS_BASE_URL, api_key,
+ self.section.get("base_url") or get_env_value("GEMINI_BASE_URL") or DEFAULT_GEMINI_TTS_BASE_URL,
)
payload = {
"contents": [{"parts": [{"text": text}]}],
diff --git a/tools/tts_tool_providers.py b/tools/tts_tool_providers.py
index c57256ac24c..441a79d6ede 100644
--- a/tools/tts_tool_providers.py
+++ b/tools/tts_tool_providers.py
@@ -570,7 +570,7 @@ def _generate_gemini_tts(text: str, output_path: str, tts_config: Dict[str, Any]
from hermes_cli.config import get_env_value
from agent.gemini_native_adapter import normalize_gemini_base_url
base_url = normalize_gemini_base_url(
- gemini_config.get("base_url") or get_env_value("GEMINI_BASE_URL") or DEFAULT_GEMINI_TTS_BASE_URL, api_key,
+ gemini_config.get("base_url") or get_env_value("GEMINI_BASE_URL") or DEFAULT_GEMINI_TTS_BASE_URL,
)
persona_prompt = _read_gemini_persona_prompt(gemini_config)
tts_script = text