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(router): drop _target_order via pop to satisfy the mutable-collection budget
ryan-crabbe-berric7212e7fe206
diff --git a/litellm/router.py b/litellm/router.pyindex 6eadaaa9913..bc0b1280d12 100644--- a/litellm/router.py+++ b/litellm/router.py@@ -2172,8 +2172,9 @@ class Router:"messages": messages,"caching": self.cache_responses,"client": model_client,- **{k: v for k, v in kwargs.items() if k != "_target_order"},+ **kwargs,}+ input_kwargs.pop("_target_order", None)response: Final = litellm.completion(**input_kwargs)verbose_router_logger.info("litellm.completion(model=%s)\x1b[32m 200 OK\x1b[0m", model_name)@@ -3193,8 +3194,9 @@ class Router:"messages": messages,"caching": self.cache_responses,"client": model_client,- **{k: v for k, v in kwargs.items() if k != "_target_order"},+ **kwargs,}+ input_kwargs.pop("_target_order", None)input_kwargs.pop("silent_model", None)input_kwargs.pop("include_fallback_errors", None)diff --git a/litellm/router_utils/fallback_event_handlers.py b/litellm/router_utils/fallback_event_handlers.pyindex 934065aba6e..d2842294a08 100644--- a/litellm/router_utils/fallback_event_handlers.py+++ b/litellm/router_utils/fallback_event_handlers.py@@ -412,9 +412,7 @@ async def run_async_fallback(# LOGGINGkwargs = litellm_router.log_retry(kwargs=kwargs, e=original_exception)verbose_router_logger.info("Falling back to model_group = %s", mask_sensitive_structure(mg))- kwargs = {- k: v for k, v in kwargs.items() if k != "_target_order"- } # rebind-ok: next hop must not inherit the previous order target+ kwargs.pop("_target_order", None) # rebind-ok: next hop must not inherit the previous order targetif isinstance(mg, str):kwargs["model"] = mgelif isinstance(mg, dict):