xtekky/gpt4free · error · RateLimitError

{chunk_text}

Error message

{chunk_text}

What it means

Raised as RateLimitError by BlackboxPro.py while consuming the streaming response: each raw chunk is decoded and scanned for the literal text "You have reached your request limit for the hour". When Blackbox embeds that message in the stream instead of returning an HTTP 4xx, the provider converts it into a RateLimitError so callers can distinguish quota exhaustion from other failures.

Source

Thrown at g4f/Provider/needs_auth/BlackboxPro.py:2834

                "selectedElement": None,
            }

            # Continue with the API request and async generator behavior
            async with session.post(
                cls.api_endpoint, json=data, proxy=proxy
            ) as response:
                await raise_for_status(response)

                # Collect the full response
                full_response = []
                async for chunk in response.content.iter_any():
                    if chunk:
                        chunk_text = chunk.decode()
                        if (
                            "You have reached your request limit for the hour"
                            in chunk_text
                        ):
                            raise RateLimitError(chunk_text)
                        full_response.append(chunk_text)
                        # Only yield chunks for non-image models
                        if model != cls.default_image_model:
                            yield chunk_text

                full_response_text = "".join(full_response)

                # For image models, check for image markdown
                if model == cls.default_image_model:
                    image_url_match = re.search(
                        r"!\[.*?\]\((.*?)\)", full_response_text
                    )
                    if image_url_match:
                        image_url = image_url_match.group(1)
                        yield ImageResponse(
                            urls=[image_url], alt=format_media_prompt(messages, prompt)
                        )
                        return

View on GitHub (pinned to 973504e177)

Solutions

  1. Wait until the hourly window resets (up to 60 minutes) before sending more requests.
  2. Throttle your request rate (queue, token bucket) so you stay under Blackbox's hourly cap.
  3. Upgrade the Blackbox plan or use a different provider for high-volume traffic.
  4. Cache responses for repeated prompts to reduce request count.

Example fix

# before
for chunk in stream:
    handle(chunk)  # dies mid-stream with RateLimitError

# after
try:
    for chunk in stream:
        handle(chunk)
except RateLimitError:
    backoff_and_resume_after_window()
Defensive patterns

Strategy: retry

Try / catch

from g4f.errors import RateLimitError

async def blackbox_with_backoff(call, max_retries=5):
    for attempt in range(max_retries):
        try:
            return await call()
        except RateLimitError:
            await asyncio.sleep(min(600, 60 * (2 ** attempt)))
    raise RateLimitError("exhausted retries")

Prevention

When it happens

Trigger: Sending more requests within the current hour than the Blackbox Pro account/session allows; the response body streams normally (HTTP 200) but contains the limit text, so raise RateLimitError(chunk_text) fires mid-iteration.

Common situations: Bursty automated workloads on a shared/Free Blackbox account; many parallel g4f requests reusing the same HAR session; long-running jobs that cross the hourly quota window.

Related errors


AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14). Data as JSON: /api/errors/22d0f1314dc0854e. Report an issue: GitHub.