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
chore(router): simplify unknown-model error message construction
user453aedef95e6
diff --git a/litellm/router.py b/litellm/router.pyindex cdb45de66db..8abdd60ccad 100644--- a/litellm/router.py+++ b/litellm/router.py@@ -10032,11 +10032,9 @@ class Router:# If still no deployments after checking for fallbacks, raise an errorif len(healthy_deployments) == 0:if self.get_model_list(model_name=model) is None:- message = f"You passed in model={model}. There is no 'model_name' with this string".format(model)+ message = f"You passed in model={model}. There is no 'model_name' with this string"else:- message = f"You passed in model={model}. There are no healthy deployments for this model".format(- model- )+ message = f"You passed in model={model}. There are no healthy deployments for this model"raise litellm.BadRequestError(message=message,diff --git a/tests/test_litellm/test_router.py b/tests/test_litellm/test_router.pyindex 5f214506197..9c4d83ff7ea 100644--- a/tests/test_litellm/test_router.py+++ b/tests/test_litellm/test_router.py@@ -3268,6 +3268,34 @@ async def test_router_acompletion_with_unknown_model_and_no_fallback():assert "no healthy deployments for this model" in str(excinfo.value)+async def test_router_unknown_model_error_message_renders_model_name_literally():+ """+ The unknown-model error message renders the caller-supplied model name+ verbatim. A name containing Python format-field syntax must be treated as+ literal text, not re-interpreted as a format template, which would distort+ the message and balloon its length.+ """+ router = litellm.Router(+ model_list=[+ {+ "model_name": "gpt-4o",+ "litellm_params": {"model": "azure/gpt-4o-real", "api_key": "fake-key"},+ }+ ]+ )++ weird_model = "ghost{:>200}model"+ messages = [{"role": "user", "content": "hi"}]++ with pytest.raises(litellm.BadRequestError) as excinfo:+ await router.acompletion(model=weird_model, messages=messages)++ message = str(excinfo.value)+ assert weird_model in message+ assert " " not in message # no padding run from an expanded format field++def test_get_deployment_credentials_with_provider_aws_bedrock_runtime_endpoint():"""Test that get_deployment_credentials_with_provider correctly copies