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: remove getattr, unused param, and unnecessary comments
devin-ai-integration[bot]9ea149b49efb
diff --git a/litellm/proxy/common_request_processing.py b/litellm/proxy/common_request_processing.pyindex 1acc0b6ebba..ddae83e50ae 100644--- a/litellm/proxy/common_request_processing.py+++ b/litellm/proxy/common_request_processing.py@@ -1218,7 +1218,6 @@ class ProxyBaseLLMRequestProcessing:fallback_models = self._resolve_fallback_models(model=original_model,llm_router=llm_router,- proxy_config=proxy_config,user_api_key_dict=user_api_key_dict,)if not fallback_models:@@ -1261,14 +1260,13 @@ class ProxyBaseLLMRequestProcessing:self,model: str,llm_router: Router,- proxy_config: ProxyConfig,user_api_key_dict: UserAPIKeyAuth,) -> Optional[list]:from litellm.router_utils.fallback_event_handlers import get_fallback_model_groupfallbacks = None- key_router_settings = getattr(user_api_key_dict, "router_settings", None)+ key_router_settings = user_api_key_dict.router_settingsif isinstance(key_router_settings, dict) and "fallbacks" in key_router_settings:fallbacks = key_router_settings["fallbacks"]diff --git a/tests/test_litellm/proxy/test_common_request_processing.py b/tests/test_litellm/proxy/test_common_request_processing.pyindex d6527a4cb90..a8a74200c25 100644--- a/tests/test_litellm/proxy/test_common_request_processing.py+++ b/tests/test_litellm/proxy/test_common_request_processing.py@@ -4355,17 +4355,9 @@ class TestResponseCostHeaderForTypedDictResponses:class TestPreCallWithFallbacksOnLocalRateLimit:- """- Regression tests for LIT-3890: proxy fallbacks must trigger when local rate- limits (key-level TPM/RPM or dynamic_rate_limiter_v3) reject a request.- """@pytest.mark.asyncioasync def test_fallback_triggered_on_local_rate_limit(self):- """- When the primary model is locally rate-limited, the request should- proceed with a configured fallback model.- """from litellm.proxy.common_utils.proxy_rate_limit_error import ProxyRateLimitErrorfrom litellm.proxy.common_request_processing import ProxyBaseLLMRequestProcessing@@ -4418,10 +4410,6 @@ class TestPreCallWithFallbacksOnLocalRateLimit:@pytest.mark.asyncioasync def test_raises_when_no_fallbacks_configured(self):- """- When no fallbacks are configured, the original rate limit error- should propagate unchanged.- """from litellm.proxy.common_utils.proxy_rate_limit_error import ProxyRateLimitErrorfrom litellm.proxy.common_request_processing import ProxyBaseLLMRequestProcessing@@ -4461,10 +4449,6 @@ class TestPreCallWithFallbacksOnLocalRateLimit:@pytest.mark.asyncioasync def test_raises_when_all_fallbacks_also_rate_limited(self):- """- When all fallback models are also locally rate-limited, the original- error for the primary model should be re-raised.- """from litellm.proxy.common_utils.proxy_rate_limit_error import ProxyRateLimitErrorfrom litellm.proxy.common_request_processing import ProxyBaseLLMRequestProcessing@@ -4502,15 +4486,10 @@ class TestPreCallWithFallbacksOnLocalRateLimit:llm_router=mock_router,)- # Model should be restored to originalassert processor.data["model"] == "gpt-4"@pytest.mark.asyncioasync def test_fallback_uses_key_level_router_settings(self):- """- Key-level router_settings fallbacks should take precedence over- router-level fallbacks.- """from litellm.proxy.common_utils.proxy_rate_limit_error import ProxyRateLimitErrorfrom litellm.proxy.common_request_processing import ProxyBaseLLMRequestProcessing@@ -4554,15 +4533,10 @@ class TestPreCallWithFallbacksOnLocalRateLimit:llm_router=mock_router,)- # Should use key-level fallback, not router-levelassert processor.data["model"] == "claude-3-haiku"@pytest.mark.asyncioasync def test_disable_fallbacks_flag_respected(self):- """- When disable_fallbacks is set in request data, local rate limit- errors should not trigger fallback logic.- """from litellm.proxy.common_utils.proxy_rate_limit_error import ProxyRateLimitErrorfrom litellm.proxy.common_request_processing import ProxyBaseLLMRequestProcessing