The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tts): stop downgrading tts-1/tts-1-hd on the managed audio gateway
Tekniumca5246bff914
diff --git a/tests/tools/test_tts_openai_config.py b/tests/tools/test_tts_openai_config.pyindex 989dfb91a80..0e487bb4489 100644--- a/tests/tools/test_tts_openai_config.py+++ b/tests/tools/test_tts_openai_config.py@@ -104,3 +104,26 @@ class TestResolveOpenaiAudioClientConfig:config = {"openai": {"api_key": "cfg-key"}}with patch.object(tts_tool, "_load_tts_config", return_value=config):assert tts_tool_openai._has_openai_audio_backend() is True++[email protected]("configured, sent", [+ ("tts-1-hd", "tts-1-hd"), ("tts-1", "tts-1"), ("gpt-4o-mini-tts", "gpt-4o-mini-tts"),+ ("gpt-4o-mini-tts-2025-12-15", "gpt-4o-mini-tts")])+def test_managed_gateway_sends_served_models_and_coerces_the_rest(tmp_path, configured, sent):+ """The managed gateway serves tts-1/tts-1-hd too; only unserved models fall back."""+ created = []++ class _Client:+ def __init__(self, **_kwargs):+ self.audio = SimpleNamespace(speech=SimpleNamespace(create=self._create))++ def _create(self, **kwargs):+ created.append(kwargs["model"])+ return SimpleNamespace(stream_to_file=lambda p: open(p, "wb").write(b"ID3"))++ with patch.object(tts_tool, "_import_openai_client", return_value=_Client), \+ patch.object(tts_tool_openai, "_resolve_openai_audio_client_config",+ return_value=("managed-key", "https://openai-audio-gateway.example/v1", True)):+ tts_tool_openai._generate_openai_tts(+ "Hello", str(tmp_path / "out.mp3"), {"openai": {"model": configured}})+ assert created == [sent]diff --git a/tools/tts_tool_openai.py b/tools/tts_tool_openai.pyindex aa10ff3607b..7db694305ea 100644--- a/tools/tts_tool_openai.py+++ b/tools/tts_tool_openai.py@@ -23,8 +23,9 @@ from tools.tts_tool_providers import _tts_response_format_from_pathlogger = logging.getLogger("tools.tts_tool")DEFAULT_OPENAI_MODEL = "gpt-4o-mini-tts"-# The managed OpenAI audio gateway only proxies these; anything else is 400 "Unsupported".-MANAGED_OPENAI_TTS_MODELS = frozenset({"gpt-4o-mini-tts"})+# Speech models the managed Nous audio gateway serves (it bills a model only when NAS has a priced+# rule for it, so anything else fails closed). Others are coerced to DEFAULT_OPENAI_MODEL.+MANAGED_OPENAI_TTS_MODELS = frozenset({"gpt-4o-mini-tts", "tts-1", "tts-1-hd"})DEFAULT_OPENAI_VOICE = "alloy"DEFAULT_OPENAI_BASE_URL = "https://api.openai.com/v1"# DeepInfra base URL is resolved via hermes_cli.models.deepinfra_base_url (shared).@@ -117,8 +118,8 @@ def _generate_openai_tts(if speed is None:speed_default = tts_config.get("speed", 1.0) if isinstance(tts_config, dict) else 1.0speed = float(oai_config.get("speed", speed_default))- # The managed gateway only proxies MANAGED_OPENAI_TTS_MODELS; coerce a direct-OpenAI- # model (e.g. "tts-1-hd") unless the user redirected base_url to their own endpoint.+ # The managed gateway only serves MANAGED_OPENAI_TTS_MODELS; coerce any other model+ # unless the user redirected base_url to their own endpoint.if is_managed and not explicit_base_url and not config_base_url and model not in MANAGED_OPENAI_TTS_MODELS:logger.warning("TTS: managed OpenAI audio gateway does not support model %r; "