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
AlexsanderHamir294fb94b1873
diff --git a/litellm/router.py b/litellm/router.pyindex 5972b06f01a..4616d77b2c9 100644--- a/litellm/router.py+++ b/litellm/router.py@@ -6257,7 +6257,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:@@ -6271,7 +6273,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: