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
refactor(proxy): resolve supported_openai_params aliases via Router.resolved_litellm_models
mateo-berri11a747190288
diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.pyindex 693769446f4..170845babdb 100644--- a/litellm/proxy/proxy_server.py+++ b/litellm/proxy/proxy_server.py@@ -12480,9 +12480,10 @@ async def supported_openai_params(model: str):"""global llm_routertry:- 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"].get("model") or model) if deployments else model- litellm_model, custom_llm_provider, _, _ = litellm.get_llm_provider(model=model_to_map)+ resolved_models: Final = llm_router.resolved_litellm_models(model) if llm_router is not None else ()+ litellm_model, custom_llm_provider, _, _ = litellm.get_llm_provider(+ model=resolved_models[0] if resolved_models else model+ )return {"supported_openai_params": litellm.get_supported_openai_params(model=litellm_model, custom_llm_provider=custom_llm_providerdiff --git a/tests/test_litellm/proxy/proxy_server/test_routes_utils.py b/tests/test_litellm/proxy/proxy_server/test_routes_utils.pyindex 4d6ce0812a4..629d829ef8a 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,6 @@ Pins (PR2):from __future__ import annotationsimport asyncio-from unittest.mock import MagicMockimport pytest@@ -126,32 +125,24 @@ def test_supported_openai_params_happy_path(client, auth_as, patched_supported_pdef test_supported_openai_params_resolves_router_alias(client, auth_as, monkeypatch):- """A router alias unknown to the cost map resolves via the deployment's ``litellm_params.model``."""- 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"],+ """A router alias absent from the cost map resolves through the deployment's underlying model."""+ router = litellm.Router(+ model_list=[+ {+ "model_name": "claude-opus-4-6-cached",+ "litellm_params": {"model": "anthropic/claude-opus-4-6", "api_key": "sk-test"},+ }+ ])+ monkeypatch.setattr(proxy_server, "llm_router", router)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"]+ expected = litellm.get_supported_openai_params(model="claude-opus-4-6", custom_llm_provider="anthropic")+ assert response.json() == {"supported_openai_params": expected}+ assert "max_tokens" in response.json()["supported_openai_params"]def test_supported_openai_params_invalid_model(client, auth_as, monkeypatch):