{"record":{"id":"99194b26585887a3","repo":"xtekky/gpt4free","slug":"response-response-status-openai-bot-detected","errorCode":null,"errorMessage":"Response {response.status}: OpenAI Bot detected","messagePattern":"Response (.+?): OpenAI Bot detected","errorType":"exception","errorClass":"MissingAuthError","httpStatus":403,"severity":"error","filePath":"g4f/requests/raise_for_status.py","lineNumber":75,"sourceCode":"                    message = f\"{error}: {message}\"\n            except json.JSONDecodeError:\n                message = await response.text()\n        else:\n            message = (await response.text()).strip()\n            is_html = content_type.startswith(\n                \"text/html\"\n            ) or message.lower().startswith(\"<!DOCTYPE\".lower())\n    if message is None or is_html:\n        if response.status == 520:\n            message = \"Unknown error (Cloudflare)\"\n    if response.status in (429, 402):\n        raise RateLimitError(f\"Response {response.status}: {message}\")\n    if response.status == 401:\n        raise MissingAuthError(f\"Response {response.status}: {message}\")\n    if response.status == 403 and is_cloudflare(message):\n        raise CloudflareError(f\"Response {response.status}: Cloudflare detected\")\n    elif response.status == 403 and (is_openai(message) or is_lmarena(message)):\n        raise MissingAuthError(f\"Response {response.status}: OpenAI Bot detected\")\n    elif response.status == 502:\n        raise ResponseStatusError(f\"Response {response.status}: Bad Gateway\")\n    elif response.status == 504:\n        raise RateLimitError(f\"Response {response.status}: Gateway Timeout \")\n    elif response.status == 400 and \"API key not valid\" in message:\n        raise MissingAuthError(f\"Response {response.status}: Invalid API key\")\n    else:\n        raise ResponseStatusError(\n            f\"Response {response.status}: {'HTML content' if is_html else message}\"\n        )\n\n\ndef raise_for_status(\n    response: Union[Response, StreamResponse, ClientResponse, RequestsResponse],\n    message: str = None,\n):\n    if hasattr(response, \"status\"):\n        return raise_for_status_async(response, message)","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/requests/raise_for_status.py#L57-L93","documentation":"Raised on 403 when the body matches is_openai ('Unable to load site' or 'challenge-error-text') or is_lmarena ('recaptcha validation failed'). Despite the 'OpenAI Bot detected' wording, it is a MissingAuthError: the provider's bot/captcha gate rejected g4f's automated request as an unauthorized bot.","triggerScenarios":"Calling g4f providers that proxy chat.lmsys.org/lmarena or OpenAI's web chat; the site serves its 'Unable to load site' challenge or fails reCAPTCHA validation with 403.","commonSituations":"LMArena tightens reCAPTCHA; OpenAI web-chat bot detection flags datacenter IPs; provider cookie/token expired so the gate page is returned instead of the API.","solutions":["Switch to a different provider/model that does not sit behind that bot gate.","Update g4f to pick up revised provider handling for the changed challenge.","Use an official API-key-based provider instead of a scraped web UI.","Retry from a residential/different IP if the block is IP-scoped."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":"from g4f.errors import MissingAuthError\ndef is_bot_gate(err: BaseException) -> bool:\n    return isinstance(err, MissingAuthError) and 'Bot detected' in str(err)","tryCatchPattern":"from g4f.errors import MissingAuthError\ntry:\n    result = await client.chat.completions.async_create(...)\nexcept MissingAuthError as e:\n    if 'Bot detected' in str(e):\n        result = await run_alternative_provider(...)  # gate, not credentials\n    else:\n        raise","preventionTips":["Treat 'OpenAI Bot detected' as a provider-availability issue, not a key issue","Keep a fallback provider list and rotate on bot-gate errors","Use browser-based providers for gated sites","Update g4f when challenge handling changes"],"tags":["http-403","bot-detection","recaptcha","openai","async"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}