xtekky/gpt4free · error · MissingAuthError

Response {response.status}: OpenAI Bot detected

Error message

Response {response.status}: OpenAI Bot detected

What it means

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.

Source

Thrown at g4f/requests/raise_for_status.py:75

                    message = f"{error}: {message}"
            except json.JSONDecodeError:
                message = await response.text()
        else:
            message = (await response.text()).strip()
            is_html = content_type.startswith(
                "text/html"
            ) or message.lower().startswith("<!DOCTYPE".lower())
    if message is None or is_html:
        if response.status == 520:
            message = "Unknown error (Cloudflare)"
    if response.status in (429, 402):
        raise RateLimitError(f"Response {response.status}: {message}")
    if response.status == 401:
        raise MissingAuthError(f"Response {response.status}: {message}")
    if response.status == 403 and is_cloudflare(message):
        raise CloudflareError(f"Response {response.status}: Cloudflare detected")
    elif response.status == 403 and (is_openai(message) or is_lmarena(message)):
        raise MissingAuthError(f"Response {response.status}: OpenAI Bot detected")
    elif response.status == 502:
        raise ResponseStatusError(f"Response {response.status}: Bad Gateway")
    elif response.status == 504:
        raise RateLimitError(f"Response {response.status}: Gateway Timeout ")
    elif response.status == 400 and "API key not valid" in message:
        raise MissingAuthError(f"Response {response.status}: Invalid API key")
    else:
        raise ResponseStatusError(
            f"Response {response.status}: {'HTML content' if is_html else message}"
        )


def raise_for_status(
    response: Union[Response, StreamResponse, ClientResponse, RequestsResponse],
    message: str = None,
):
    if hasattr(response, "status"):
        return raise_for_status_async(response, message)

View on GitHub (pinned to 973504e177)

Solutions

  1. Switch to a different provider/model that does not sit behind that bot gate.
  2. Update g4f to pick up revised provider handling for the changed challenge.
  3. Use an official API-key-based provider instead of a scraped web UI.
  4. Retry from a residential/different IP if the block is IP-scoped.
Defensive patterns

Strategy: fallback

Type guard

from g4f.errors import MissingAuthError
def is_bot_gate(err: BaseException) -> bool:
    return isinstance(err, MissingAuthError) and 'Bot detected' in str(err)

Try / catch

from g4f.errors import MissingAuthError
try:
    result = await client.chat.completions.async_create(...)
except MissingAuthError as e:
    if 'Bot detected' in str(e):
        result = await run_alternative_provider(...)  # gate, not credentials
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of xtekky/gpt4free@973504e177 (2026-08-14). Data as JSON: /api/errors/99194b26585887a3. Report an issue: GitHub.