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
perf(router): use shallow copy instead of deepcopy for model aliases
AlexsanderHamir8c58d165a7eb
diff --git a/litellm/router.py b/litellm/router.pyindex 6191e046aa4..50868c385c7 100644--- a/litellm/router.py+++ b/litellm/router.py@@ -6281,7 +6281,9 @@ class Router:model_name=model_name, model=model, team_id=team_id):if model_alias is not None:- alias_model = copy.deepcopy(model)+ # Optimized: Use shallow copy since we only modify top-level model_name+ # This is much faster than deepcopy for nested dict structures+ alias_model = model.copy()alias_model["model_name"] = model_aliasreturned_models.append(alias_model)else:@@ -6295,7 +6297,8 @@ class Router:model_name=model_name, model=model, team_id=team_id):if model_alias is not None:- alias_model = copy.deepcopy(model)+ # Optimized: Use shallow copy since we only modify top-level model_name+ alias_model = model.copy()alias_model["model_name"] = model_aliasreturned_models.append(alias_model)else: