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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(proxy): resolve router model aliases in /utils/supported_openai_params
Devin AI1bf3ab53884b
diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.pyindex 887716a383a..d1771cc9088 100644--- a/litellm/proxy/proxy_server.py+++ b/litellm/proxy/proxy_server.py@@ -12478,11 +12478,14 @@ async def supported_openai_params(model: str):--header 'Authorization: Bearer sk-1234'```"""+ global llm_routertry:- model, custom_llm_provider, _, _ = litellm.get_llm_provider(model=model)+ deployments: Final = llm_router.get_model_list(model_name=model) if llm_router is not None else None+ model_to_map: Final = deployments[0]["litellm_params"]["model"] if deployments else model+ litellm_model, custom_llm_provider, _, _ = litellm.get_llm_provider(model=model_to_map)return {"supported_openai_params": litellm.get_supported_openai_params(- model=model, custom_llm_provider=custom_llm_provider+ model=litellm_model, custom_llm_provider=custom_llm_provider)}except Exception:diff --git a/tests/test_litellm/proxy/proxy_server/test_routes_utils.py b/tests/test_litellm/proxy/proxy_server/test_routes_utils.pyindex 35b5c72f92e..7615c5e66db 100644--- a/tests/test_litellm/proxy/proxy_server/test_routes_utils.py+++ b/tests/test_litellm/proxy/proxy_server/test_routes_utils.py@@ -9,7 +9,7 @@ Pins (PR2):from __future__ import annotationsimport asyncio-from unittest.mock import AsyncMock, MagicMock+from unittest.mock import MagicMockimport pytest@@ -124,6 +124,35 @@ def test_supported_openai_params_happy_path(client, auth_as, patched_supported_p}+def test_supported_openai_params_resolves_router_alias(client, auth_as, monkeypatch):+ """A router ``model_name`` alias unknown to the cost map (e.g. ``claude-opus-4-6-cached``) resolves via the router's underlying ``litellm_params.model`` instead of 400ing."""+ router = MagicMock()+ router.get_model_list.return_value = [+ {"model_name": "claude-opus-4-6-cached", "litellm_params": {"model": "anthropic/claude-opus-4-6"}}+ ]+ monkeypatch.setattr(proxy_server, "llm_router", router)+ seen = []++ def _get_llm_provider(model):+ seen.append(model)+ return (model, "anthropic", None, None)++ monkeypatch.setattr(litellm, "get_llm_provider", _get_llm_provider)+ monkeypatch.setattr(+ litellm,+ "get_supported_openai_params",+ lambda model, custom_llm_provider=None: ["max_tokens"],+ )++ with auth_as():+ response = client.get("/utils/supported_openai_params", params={"model": "claude-opus-4-6-cached"})++ assert response.status_code == 200+ assert response.json() == {"supported_openai_params": ["max_tokens"]}+ router.get_model_list.assert_called_once_with(model_name="claude-opus-4-6-cached")+ assert seen == ["anthropic/claude-opus-4-6"]++def test_supported_openai_params_invalid_model(client, auth_as, monkeypatch):"""Pins ``GET /utils/supported_openai_params`` (error: unknown model)."""