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): expose configured model mode
moe-berri425e3069b93e
diff --git a/litellm/proxy/utils.py b/litellm/proxy/utils.pyindex cab2bd6d9db..24a65457928 100644--- a/litellm/proxy/utils.py+++ b/litellm/proxy/utils.py@@ -7531,6 +7531,9 @@ def create_model_info_response(max_input_tokens = configured_inputif configured_output is not None:max_output_tokens = configured_output+ configured_mode: Final = llm_router.get_configured_mode(model_id)+ if isinstance(configured_mode, str):+ base["mode"] = configured_modeif max_input_tokens is not None:base["max_input_tokens"] = max_input_tokensdiff --git a/litellm/router.py b/litellm/router.pyindex 2b8b342d253..cfb080a24a0 100644--- a/litellm/router.py+++ b/litellm/router.py@@ -9981,6 +9981,17 @@ class Router:coerce_token_limit(model_info.get("max_output_tokens")),)+ def get_configured_mode(self, model_name: str) -> "str | None":+ """Return the mode explicitly configured for a concrete deployment."""+ deployment: Final = self.get_deployment_by_model_group_name(model_group_name=model_name)+ if deployment is None:+ return None++ mode: Final = deployment.model_info.get("mode")+ if isinstance(mode, str) and mode.strip():+ return mode+ return None+def get_configured_display_name(self, model_name: str) -> "str | None":"""Return the display_name explicitly configured in a concrete deployment'sdiff --git a/litellm/types/proxy/model_listing.py b/litellm/types/proxy/model_listing.pyindex b59c0f2cf19..24cfa85eee4 100644--- a/litellm/types/proxy/model_listing.py+++ b/litellm/types/proxy/model_listing.py@@ -11,8 +11,8 @@ class ModelInfoMetadata(TypedDict):class ModelInfoResponse(TypedDict):"""OpenAI-compatible model object. `mode`, `max_input_tokens`, and- `max_output_tokens` are attached when the cost map knows them; `metadata`- is present only when the endpoint is called with include_metadata=true.+ `max_output_tokens` are attached when the cost map or deployment config+ knows them; `metadata` is present only with include_metadata=true."""id: strdiff --git a/tests/test_litellm/proxy/test_proxy_utils.py b/tests/test_litellm/proxy/test_proxy_utils.pyindex dcaad968663..f16c6c937d0 100644--- a/tests/test_litellm/proxy/test_proxy_utils.py+++ b/tests/test_litellm/proxy/test_proxy_utils.py@@ -942,6 +942,47 @@ def test_create_model_info_response_uses_deployment_limits_when_not_in_cost_map(assert response["max_output_tokens"] == 8000+def test_create_model_info_response_uses_deployment_mode_for_auto_router():+ router = litellm.Router(+ model_list=[+ {+ "model_name": "claude-sonnet",+ "litellm_params": {"model": "openai/gpt-4o-mini", "api_key": "test-key"},+ },+ {+ "model_name": "claude-auto",+ "litellm_params": {+ "model": "auto_router/complexity_router",+ "complexity_router_config": {+ "tiers": {+ "SIMPLE": "claude-sonnet",+ "MEDIUM": "claude-sonnet",+ "COMPLEX": "claude-sonnet",+ }+ },+ "complexity_router_default_model": "claude-sonnet",+ },+ "model_info": {+ "mode": "chat",+ "max_input_tokens": 1_000_000,+ "max_output_tokens": 128_000,+ },+ },+ ]+ )++ response = create_model_info_response(+ model_id="claude-auto",+ provider="openai",+ llm_router=router,+ get_model_info=_raise_unmapped,+ )++ assert response["mode"] == "chat"+ assert response["max_input_tokens"] == 1_000_000+ assert response["max_output_tokens"] == 128_000++def test_create_model_info_response_deployment_limits_override_cost_map():router = MagicMock()router.get_configured_token_limits.return_value = (200000, None)