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
handle hf rate limit error
Ishaan Jaffb987d9948605
diff --git a/litellm/tests/test_text_completion.py b/litellm/tests/test_text_completion.pyindex e6a4a0499cc..7e599012eb4 100644--- a/litellm/tests/test_text_completion.py+++ b/litellm/tests/test_text_completion.py@@ -3951,6 +3951,9 @@ def test_completion_hf_prompt_array():print(response.choices)assert len(response.choices) == 2# response_str = response["choices"][0]["text"]+ except litellm.RateLimitError:+ print("got rate limit error from hugging face... passsing")+ returnexcept Exception as e:print(str(e))if "is currently loading" in str(e):diff --git a/litellm/utils.py b/litellm/utils.pyindex 2bb5e15296d..2b97e9d71aa 100644--- a/litellm/utils.py+++ b/litellm/utils.py@@ -7455,6 +7455,14 @@ def exception_type(model=model,response=original_exception.response,)+ elif "Rate limit reached" in error_str:+ exception_mapping_worked = True+ raise RateLimitError(+ message=error_str,+ llm_provider="huggingface",+ model=model,+ response=original_exception.response,+ )if hasattr(original_exception, "status_code"):if original_exception.status_code == 401:exception_mapping_worked = True