xtekky/gpt4free · error · ResponseError
GPU token limit exceeded: {chunk.decode(errors='replace')}
Error message
GPU token limit exceeded: {chunk.decode(errors='replace')} What it means
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.
Source
Thrown at g4f/Provider/hf_space/StabilityAI_SD35Large.py:81
num_inference_steps,
]
}
async with session.post(
f"{cls.url}{cls.api_endpoint}", json=data, proxy=proxy
) as response:
response.raise_for_status()
event_id = (await response.json()).get("event_id")
async with session.get(
f"{cls.url}{cls.api_endpoint}/{event_id}"
) as event_response:
event_response.raise_for_status()
event = None
async for chunk in event_response.content:
if chunk.startswith(b"event: "):
event = chunk[7:].decode(errors="replace").strip()
if chunk.startswith(b"data: "):
if event == "error":
raise ResponseError(
f"GPU token limit exceeded: {chunk.decode(errors='replace')}"
)
if event in ("complete", "generating"):
try:
data = json.loads(chunk[6:])
if data is None:
continue
url = data[0]["url"]
except (json.JSONDecodeError, KeyError, TypeError) as e:
raise RuntimeError(
f"Failed to parse image URL: {chunk.decode(errors='replace')}",
e,
)
if event == "generating":
yield ImagePreview(url, prompt)
else:
yield ImageResponse(url, prompt)
breakView on GitHub (pinned to 973504e177)
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.
Defensive patterns
Strategy: retry
Try / catch
try:
...
except ResponseError as e:
if 'GPU token limit exceeded' in str(e):
await asyncio.sleep(3600) # wait out the ZeroGPU quota window, or switch provider
... Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to parse message: {chunk.decode(errors='replace')}
- Failed to parse image URL: {chunk.decode(errors='replace')}
- No media files provided for image generation.
- No coins left. Log in with a different account or wait a whi
- No response
AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14).
Data as JSON: /api/errors/28aff528866e7481.
Report an issue: GitHub.