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): only create Router when models or search_tools exist (#20661)
shin-bot-litellm5fb7644d8ee4
diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.pyindex cf9e00512b1..22d63579986 100644--- a/litellm/proxy/proxy_server.py+++ b/litellm/proxy/proxy_server.py@@ -3249,18 +3249,19 @@ class ProxyConfig:_model_list: list = self.decrypt_model_list_from_db(new_models=models_list)- # Create router even with empty model list to support search_tools- # Router can function with model_list=[] and only search_tools- verbose_proxy_logger.debug(f"_model_list: {_model_list}")- llm_router = litellm.Router(- model_list=_model_list,- router_general_settings=RouterGeneralSettings(- async_only_mode=True # only init async clients- ),- search_tools=search_tools,- ignore_invalid_deployments=True,- )- verbose_proxy_logger.debug(f"updated llm_router: {llm_router}")+ # Only create router if we have models or search_tools to route+ # Router can function with model_list=[] if search_tools are configured+ if len(_model_list) > 0 or search_tools:+ verbose_proxy_logger.debug(f"_model_list: {_model_list}")+ llm_router = litellm.Router(+ model_list=_model_list,+ router_general_settings=RouterGeneralSettings(+ async_only_mode=True # only init async clients+ ),+ search_tools=search_tools,+ ignore_invalid_deployments=True,+ )+ verbose_proxy_logger.debug(f"updated llm_router: {llm_router}")else:verbose_proxy_logger.debug(f"len new_models: {len(models_list)}")if search_tools is not None and llm_router is not None: