{"record":{"id":"5b26f93edfebb6d5","repo":"xtekky/gpt4free","slug":"message-model","errorCode":null,"errorMessage":"{message}: {model}","messagePattern":"\\{message\\}: \\{model\\}","errorType":"exception","errorClass":"RateLimitError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/gemini_utils.py","lineNumber":265,"sourceCode":"    if not isinstance(value, list):\n        return None\n    if value and value[0] == \"wrb.fr\":\n        code = get_nested_value(value, [5, 2, 0, 1, 0])\n        if isinstance(code, int):\n            return code\n    for item in value:\n        code = extract_gemini_error_code(item)\n        if code is not None:\n            return code\n    return None\n\n\ndef raise_gemini_error(code: int, model: str) -> None:\n    message = GEMINI_ERROR_MESSAGES.get(\n        code, f\"Gemini rejected the request with error code {code}\"\n    )\n    if code in (1037, 1060):\n        raise RateLimitError(f\"{message}: {model}\")\n    raise ResponseError(f\"{message}: {model}\")\n","sourceCodeStart":247,"sourceCodeEnd":267,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/gemini_utils.py#L247-L267","documentation":"Raised by raise_gemini_error() after mapping a Gemini error code (extracted from the response) through GEMINI_ERROR_MESSAGES. Codes 1037 and 1060 raise RateLimitError; every other code raises ResponseError. The message combines the human-readable code description with the model name, so the caller knows which model and which failure class is involved.","triggerScenarios":"Calling a Gemini-based provider and receiving a response containing a structured error code (via extract_gemini_error_code) — e.g. quota/recursion (1037, 1060) or safety/policy rejection codes — triggering raise_gemini_error.","commonSituations":"Hitting Gemini free-tier quota limits, safety filters rejecting the prompt, model deprecation, or invalid model names routed through the Gemini API surface.","solutions":["Match the message text against the code table in GEMINI_ERROR_MESSAGES to identify the exact code","For 1037/1060 (RateLimitError): back off and retry after the quota window resets","For other codes: fix the underlying cause (prompt content for safety codes, model name for not-found codes)","Switch model or provider if the code indicates a permanent rejection"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"from g4f.errors import RateLimitError, ResponseError\ntry:\n    result = await provider.create_async(model, messages)\nexcept RateLimitError as e:\n    # codes 1037/1060: quota window\n    await asyncio.sleep(60)\n    result = await provider.create_async(model, messages)\nexcept ResponseError as e:\n    # non-rate code: inspect message, do not blind-retry\n    raise","preventionTips":["Catch RateLimitError and ResponseError separately — only the former benefits from retry","Throttle Gemini calls below the quota of your tier","Parse the error message text to map back to the numeric Gemini code"],"tags":["gemini","rate-limit","api-error","provider"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}