{"record":{"id":"22d0f1314dc0854e","repo":"xtekky/gpt4free","slug":"chunk-text","errorCode":null,"errorMessage":"{chunk_text}","messagePattern":"\\{chunk_text\\}","errorType":"exception","errorClass":"RateLimitError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/BlackboxPro.py","lineNumber":2834,"sourceCode":"                \"selectedElement\": None,\n            }\n\n            # Continue with the API request and async generator behavior\n            async with session.post(\n                cls.api_endpoint, json=data, proxy=proxy\n            ) as response:\n                await raise_for_status(response)\n\n                # Collect the full response\n                full_response = []\n                async for chunk in response.content.iter_any():\n                    if chunk:\n                        chunk_text = chunk.decode()\n                        if (\n                            \"You have reached your request limit for the hour\"\n                            in chunk_text\n                        ):\n                            raise RateLimitError(chunk_text)\n                        full_response.append(chunk_text)\n                        # Only yield chunks for non-image models\n                        if model != cls.default_image_model:\n                            yield chunk_text\n\n                full_response_text = \"\".join(full_response)\n\n                # For image models, check for image markdown\n                if model == cls.default_image_model:\n                    image_url_match = re.search(\n                        r\"!\\[.*?\\]\\((.*?)\\)\", full_response_text\n                    )\n                    if image_url_match:\n                        image_url = image_url_match.group(1)\n                        yield ImageResponse(\n                            urls=[image_url], alt=format_media_prompt(messages, prompt)\n                        )\n                        return","sourceCodeStart":2816,"sourceCodeEnd":2852,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/BlackboxPro.py#L2816-L2852","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Wait until the hourly window resets (up to 60 minutes) before sending more requests.","Throttle your request rate (queue, token bucket) so you stay under Blackbox's hourly cap.","Upgrade the Blackbox plan or use a different provider for high-volume traffic.","Cache responses for repeated prompts to reduce request count."],"exampleFix":"# before\nfor chunk in stream:\n    handle(chunk)  # dies mid-stream with RateLimitError\n\n# after\ntry:\n    for chunk in stream:\n        handle(chunk)\nexcept RateLimitError:\n    backoff_and_resume_after_window()","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"from g4f.errors import RateLimitError\n\nasync def blackbox_with_backoff(call, max_retries=5):\n    for attempt in range(max_retries):\n        try:\n            return await call()\n        except RateLimitError:\n            await asyncio.sleep(min(600, 60 * (2 ** attempt)))\n    raise RateLimitError(\"exhausted retries\")","preventionTips":["Rate-limit outgoing Blackbox requests below the hourly cap.","Cache identical prompts within the hour window.","Distinguish RateLimitError from auth errors so backoff, not re-login, is the response."],"tags":["rate-limit","quota","streaming","blackbox"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}