From 2953cd70ed89c158567d393275d101f75972229a Mon Sep 17 00:00:00 2001 From: parththakkar106 Date: Tue, 21 Jul 2026 01:01:29 +0530 Subject: [PATCH] Show a friendly message on 429 instead of raw JSON Map HTTP 429 in _friendly_http_error: OpenRouter's free-models-per-day cap gets a "daily limit, resets 00:00 UTC" message; other rate limits get a generic "too many requests, try again" note. Avoids leaking the raw error JSON (incl. user_id) to players. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01TEpWMjnfPqzZ13nPMoGhs5 --- backend/app/providers/openai_compatible.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backend/app/providers/openai_compatible.py b/backend/app/providers/openai_compatible.py index d1c283d..af669a6 100644 --- a/backend/app/providers/openai_compatible.py +++ b/backend/app/providers/openai_compatible.py @@ -267,4 +267,13 @@ class OpenAICompatibleProvider(Provider): f"Endpoint or model not found (HTTP 404). Check the endpoint URL and that " f"model '{self.model}' exists. {detail}" ) + if status == 429: + # OpenRouter's shared free tier has a per-day cap; distinguish it + # from a short-term burst limit so the message is actionable. + if "free-models-per-day" in detail: + return ( + "The free demo has hit its daily request limit (resets at " + "00:00 UTC). Please try again later." + ) + return "The AI is getting too many requests right now — wait a moment and try again." return f"AI endpoint returned HTTP {status}: {detail}"