Skip to content

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]

fix(proxy_server.py): support env vars for controlling global max parallel request retry/timeouts

Krrish Dholakiaab28e55b764e
diff --git a/litellm/proxy/_new_secret_config.yaml b/litellm/proxy/_new_secret_config.yaml
index 96a0242a8e4..f049bfeb3c4 100644
--- a/litellm/proxy/_new_secret_config.yaml
+++ b/litellm/proxy/_new_secret_config.yaml
@@ -2,3 +2,6 @@ model_list:
- model_name: "*"
litellm_params:
model: "*"
+
+general_settings:
+ global_max_parallel_requests: 0
\ No newline at end of file
diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py
index f4206f726ac..436913bfe1a 100644
--- a/litellm/proxy/proxy_server.py
+++ b/litellm/proxy/proxy_server.py
@@ -311,6 +311,24 @@ except Exception as e:
server_root_path = os.getenv("SERVER_ROOT_PATH", "")
_license_check = LicenseCheck()
premium_user: bool = _license_check.is_premium()
+global_max_parallel_request_retries_env: Optional[str] = os.getenv(
+ "LITELLM_GLOBAL_MAX_PARALLEL_REQUEST_RETRIES"
+)
+if global_max_parallel_request_retries_env is None:
+ global_max_parallel_request_retries: int = 3
+else:
+ global_max_parallel_request_retries = int(global_max_parallel_request_retries_env)
+
+global_max_parallel_request_retry_timeout_env: Optional[str] = os.getenv(
+ "LITELLM_GLOBAL_MAX_PARALLEL_REQUEST_RETRY_TIMEOUT"
+)
+if global_max_parallel_request_retry_timeout_env is None:
+ global_max_parallel_request_retry_timeout: float = 60.0
+else:
+ global_max_parallel_request_retry_timeout = float(
+ global_max_parallel_request_retry_timeout_env
+ )
+
ui_link = f"{server_root_path}/ui/"
ui_message = (
f"👉 [```LiteLLM Admin Panel on /ui```]({ui_link}). Create, Edit Keys with SSO"
@@ -3021,8 +3039,8 @@ def model_list(
@backoff.on_exception(
backoff.expo,
Exception, # base exception to catch for the backoff
- max_tries=litellm.num_retries or 3, # maximum number of retries
- max_time=litellm.request_timeout or 60, # maximum total time to retry for
+ max_tries=global_max_parallel_request_retries, # maximum number of retries
+ max_time=global_max_parallel_request_retry_timeout, # maximum total time to retry for
on_backoff=on_backoff, # specifying the function to call on backoff
giveup=giveup,
logger=verbose_proxy_logger,