{"record":{"id":"28aff528866e7481","repo":"xtekky/gpt4free","slug":"gpu-token-limit-exceeded-chunk-decode-errors-re","errorCode":null,"errorMessage":"GPU token limit exceeded: {chunk.decode(errors='replace')}","messagePattern":"GPU token limit exceeded: (.+?)","errorType":"exception","errorClass":"ResponseError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/hf_space/StabilityAI_SD35Large.py","lineNumber":81,"sourceCode":"                    num_inference_steps,\n                ]\n            }\n            async with session.post(\n                f\"{cls.url}{cls.api_endpoint}\", json=data, proxy=proxy\n            ) as response:\n                response.raise_for_status()\n                event_id = (await response.json()).get(\"event_id\")\n                async with session.get(\n                    f\"{cls.url}{cls.api_endpoint}/{event_id}\"\n                ) as event_response:\n                    event_response.raise_for_status()\n                    event = None\n                    async for chunk in event_response.content:\n                        if chunk.startswith(b\"event: \"):\n                            event = chunk[7:].decode(errors=\"replace\").strip()\n                        if chunk.startswith(b\"data: \"):\n                            if event == \"error\":\n                                raise ResponseError(\n                                    f\"GPU token limit exceeded: {chunk.decode(errors='replace')}\"\n                                )\n                            if event in (\"complete\", \"generating\"):\n                                try:\n                                    data = json.loads(chunk[6:])\n                                    if data is None:\n                                        continue\n                                    url = data[0][\"url\"]\n                                except (json.JSONDecodeError, KeyError, TypeError) as e:\n                                    raise RuntimeError(\n                                        f\"Failed to parse image URL: {chunk.decode(errors='replace')}\",\n                                        e,\n                                    )\n                                if event == \"generating\":\n                                    yield ImagePreview(url, prompt)\n                                else:\n                                    yield ImageResponse(url, prompt)\n                                    break","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/hf_space/StabilityAI_SD35Large.py#L63-L99","documentation":"ResponseError raised while streaming the StabilityAI SD3.5 Large HF Space Gradio SSE feed: an 'event: error' frame was received, and the following 'data: ' line is surfaced as the error text. Despite the hardcoded 'GPU token limit exceeded' prefix, the actual cause is whatever the Space reported in the error event — most commonly exhausted ZeroGPU quota, but any Space-side error event takes this path.","triggerScenarios":"Joining the gradio_api queue with a ZeroGPU token whose GPU-time quota is exhausted (the Space emits event: error with a quota message); calling the Space anonymously when it requires a ZeroGPU-eligible account; or any Space-side exception surfacing as an error event over the SSE stream.","commonSituations":"Many image generations in a short window on HF ZeroGPU Spaces draining the free quota; using an unauthenticated session after HF tightened anonymous ZeroGPU access; expired zerogpu token obtained earlier in the session.","solutions":["Read the data line after the prefix — it states the actual cause (e.g. 'You have exceeded your GPU quota').","Wait for the quota window to reset (HF ZeroGPU grants quota per hour/week) before retrying.","Provide HF cookies or a valid zerogpu token/api_key so the request is billed to an account with remaining quota.","If the error text is unrelated to quota, treat it as a Space-side failure: retry later or switch to another SD3.5 provider."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    ...\nexcept ResponseError as e:\n    if 'GPU token limit exceeded' in str(e):\n        await asyncio.sleep(3600)  # wait out the ZeroGPU quota window, or switch provider\n        ...","preventionTips":["Track your HF ZeroGPU quota and pace generation requests.","Authenticate the Space session (cookies/zerogpu token) for higher quota tiers.","Have a second image provider configured to fail over when ZeroGPU runs dry."],"tags":["hf-space","zerogpu","quota","image-generation","gradio"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}