Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(router): resolve hidden aliases for explicit lookup

Daniel Meismer31f7b9409ad9
diff --git a/litellm/router.py b/litellm/router.py
index d07effd0d90..4609440a5cd 100644
--- a/litellm/router.py
+++ b/litellm/router.py
@@ -10644,10 +10644,9 @@ class Router:
_router_model_name: str = model_value
elif isinstance(model_value, dict):
_model_value = RouterModelGroupAliasItem(**model_value)
- if _model_value["hidden"] is True:
+ if _model_value["hidden"] is True and model_name is None:
continue
- else:
- _router_model_name = _model_value["model"]
+ _router_model_name = _model_value["model"]
else:
continue
diff --git a/tests/test_litellm/test_router_order_fallback.py b/tests/test_litellm/test_router_order_fallback.py
index 083f35456a3..7743cb005d0 100644
--- a/tests/test_litellm/test_router_order_fallback.py
+++ b/tests/test_litellm/test_router_order_fallback.py
@@ -367,6 +367,45 @@ async def test_router_order_fallback_with_wildcard_model_group():
assert response._hidden_params["model_id"] == "2"
+async def test_router_order_fallback_with_hidden_model_group_alias():
+ router = Router(
+ model_list=[
+ {
+ "model_name": "canonical-model",
+ "litellm_params": {
+ "model": "gpt-4o",
+ "api_key": "bad",
+ "mock_response": Exception("fail order 1"),
+ "order": 1,
+ },
+ "model_info": {"id": "1"},
+ },
+ {
+ "model_name": "canonical-model",
+ "litellm_params": {
+ "model": "gpt-4o",
+ "api_key": "good",
+ "mock_response": "success from order 2",
+ "order": 2,
+ },
+ "model_info": {"id": "2"},
+ },
+ ],
+ model_group_alias={"hidden-alias": {"model": "canonical-model", "hidden": True}},
+ num_retries=0,
+ )
+
+ assert "hidden-alias" not in {deployment["model_name"] for deployment in router.get_model_list() or []}
+
+ response = await router.acompletion(
+ model="hidden-alias",
+ messages=[{"role": "user", "content": "hi"}],
+ )
+
+ assert response._hidden_params["model_id"] == "2"
+
+
def test_check_non_standard_fallback_format():
from litellm.router_utils.fallback_event_handlers import (
_check_non_standard_fallback_format,