xtekky/gpt4free · error · RuntimeError

Create images failed: {error}

Error message

Create images failed: {error}

What it means

Raised as RuntimeError by Bing image creation when the submission response body contains one of the known ERRORS strings. Bing returned an HTML page whose text matches a known failure phrase (e.g. content policy or regional blocks), which the provider surfaces verbatim.

Source

Thrown at g4f/Provider/needs_auth/bing/create_images.py:103

        RuntimeError: If image creation fails or times out.
    """
    if not has_requirements:
        raise MissingRequirementsError('Install "beautifulsoup4" package')
    url_encoded_prompt = quote(prompt)
    payload = f"q={url_encoded_prompt}&rt=4&FORM=GENCRE"
    url = f"{BING_URL}/images/create?q={url_encoded_prompt}&rt=4&FORM=GENCRE"
    async with session.post(
        url, allow_redirects=False, data=payload, timeout=timeout
    ) as response:
        response.raise_for_status()
        text = (await response.text()).lower()
        if "0 coins available" in text:
            raise RateLimitError(
                "No coins left. Log in with a different account or wait a while"
            )
        for error in ERRORS:
            if error in text:
                raise RuntimeError(f"Create images failed: {error}")
    if response.status != 302:
        url = f"{BING_URL}/images/create?q={url_encoded_prompt}&rt=3&FORM=GENCRE"
        async with session.post(
            url, allow_redirects=False, timeout=timeout
        ) as response:
            if response.status != 302:
                raise RuntimeError(f"Create images failed. Code: {response.status}")

    redirect_url = response.headers["Location"].replace("&nfy=1", "")
    redirect_url = f"{BING_URL}{redirect_url}"
    request_id = redirect_url.split("id=")[-1]
    async with session.get(redirect_url) as response:
        response.raise_for_status()

    polling_url = (
        f"{BING_URL}/images/create/async/results/{request_id}?q={url_encoded_prompt}"
    )
    start_time = time.time()

View on GitHub (pinned to 973504e177)

Solutions

  1. Rephrase the prompt to avoid the flagged content indicated in the error string
  2. Catch RuntimeError and fall back to another image provider for rejected prompts
  3. Retry later if the matched error text indicates a temporary service condition

Example fix

# before
images = create_images(session, prompt, cookies)

# after
try:
    images = create_images(session, prompt, cookies)
except RuntimeError as e:
    if 'Create images failed' in str(e):
        images = fallback_image_provider(prompt)
    else:
        raise
Defensive patterns

Strategy: fallback

Try / catch

try:
    images = create_images(session, prompt, cookies)
except RuntimeError as e:
    if str(e).startswith('Create images failed:'):
        images = fallback_image_provider(prompt)
    else:
        raise

Prevention

When it happens

Trigger: Submitting a prompt that triggers a Bing-side failure page: blocked content, unsafe prompt classification, or regional/service notice in the response text.

Common situations: Prompts with policy-sensitive terms, service outage pages matching an ERRORS entry, region-locked features.

Related errors


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