Detect OpenAI "no credits" 429 as exhausted balance

A real API call returned 429 "You have no credits remaining" without the
word "quota", so the UI wrongly said the AI was busy. Match quota,
credit and billing wording; test uses the real message.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Kyle Dammann
2026-10-30 22:15:33 +01:00
co-authored by Claude Opus 5.5
parent 3b72436119
commit 2f73520150
2 changed files with 6 additions and 2 deletions
+3
View File
@@ -108,6 +108,9 @@ def api_error(cls, status, message="error", body=None):
(openai.APITimeoutError(request=REQUEST), "zu lange"),
(api_error(openai.RateLimitError, 429, "Rate limit reached"), "ausgelastet"),
(api_error(openai.RateLimitError, 429, "You exceeded your current quota", {"code": "insufficient_quota"}), "Guthaben"),
# Real-world message seen from the API (2026-10) for an account without credit
(api_error(openai.RateLimitError, 429, "Error code: 429 - You have no credits remaining. Add credits to "
"continue using the API at https://platform.openai.com/settings/organization/billing/."), "Guthaben"),
(api_error(openai.AuthenticationError, 401), "API-Key"),
(api_error(openai.NotFoundError, 404), "OPENAI_MODEL"),
(api_error(openai.BadRequestError, 400), "nicht verarbeiten"),