fix: Do not retry litellm.APIError for insufficient credits.

This commit is contained in:
Paul Gauthier (aider) 2025-04-04 21:45:56 +13:00
parent c057dc9466
commit e0b42d51db

View file

@ -92,4 +92,16 @@ class LiteLLMExceptions:
" limiting your requests."
),
)
# Check for specific non-retryable APIError cases like insufficient credits
if ex.__class__ is litellm.APIError:
err_str = str(ex).lower()
if "insufficient credits" in err_str and '"code":402' in err_str:
return ExInfo(
"APIError",
False,
"Insufficient credits with the API provider. Please add credits.",
)
# Fall through to default APIError handling if not the specific credits error
return self.exceptions.get(ex.__class__, ExInfo(None, None, None))