diff --git a/litellm/litellm_core_utils/prompt_templates/server_tool_stream.py b/litellm/litellm_core_utils/prompt_templates/server_tool_stream.py index 4d75bca05fa..8f7fd856850 100644 --- a/litellm/litellm_core_utils/prompt_templates/server_tool_stream.py +++ b/litellm/litellm_core_utils/prompt_templates/server_tool_stream.py @@ -35,7 +35,10 @@ class ServerToolStreamError(ValueError): int(code) if code.isascii() and code.isdecimal() and len(code) == 3 and 400 <= int(code) < 600 else 429 - if (error.get("type") or code) in ("rate_limit_error", "rate_limit_exceeded", "insufficient_quota") + if any( + value in ("rate_limit_error", "rate_limit_exceeded", "insufficient_quota") + for value in (error.get("type"), code) + ) else 503 if error.get("type") == "overloaded_error" else 502