xtekky/gpt4free · error · RuntimeError

Prompt is been blocked

Error message

Prompt is been blocked

What it means

Raised by create_images() after the Bing Image Creator polling loop finishes and the returned page body parses as JSON containing errorMessage == "Pending". Bing reports this status when the image generation request was accepted but the prompt was flagged/blocked and never completed. The library surfaces it as a RuntimeError, meaning the request cannot succeed by retrying the same prompt.

Source

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

    start_time = time.time()
    while True:
        if time.time() - start_time > timeout:
            raise RuntimeError(f"Timeout error after {timeout} sec")
        async with session.get(polling_url) as response:
            if response.status != 200:
                raise RuntimeError(f"Polling images faild. Code: {response.status}")
            text = await response.text()
            if not text or "GenerativeImagesStatusPage" in text:
                await asyncio.sleep(1)
            else:
                break
    error = None
    try:
        error = json.loads(text).get("errorMessage")
    except Exception:
        pass
    if error == "Pending":
        raise RuntimeError("Prompt is been blocked")
    elif error:
        raise RuntimeError(error)
    return read_images(text)


def read_images(html_content: str) -> List[str]:
    """
    Extracts image URLs from the HTML content.

    Args:
        html_content (str): HTML content containing image URLs.

    Returns:
        List[str]: A list of image URLs.
    """
    soup = BeautifulSoup(html_content, "html.parser")
    tags = soup.find_all("img", class_="mimg")
    if not tags:

View on GitHub (pinned to 973504e177)

Solutions

  1. Rephrase the prompt to remove flagged terms (names of real people, violence, sexual wording)
  2. Try a different image provider (e.g. g4f image models not routed through Bing)
  3. Check the full prompt including negative prompt fields for moderated keywords
  4. Retry later — Bing moderation is sometimes transient

Example fix

// before
images = create_images(client, "realistic photo of [celebrity name]")
// after
images = create_images(client, "realistic portrait of a person in a studio")
Defensive patterns

Strategy: try-catch

Try / catch

try:
    images = await create_images(client, prompt)
except RuntimeError as e:
    if "Prompt is been blocked" in str(e):
        # moderation: do not retry same prompt unchanged
        images = await create_images(client, sanitize(prompt))
    else:
        raise

Prevention

When it happens

Trigger: Calling g4f image generation with the Bing provider where the polling URL (/images/create/async/results/{request_id}) returns a JSON body with errorMessage "Pending" after theGenerativeImagesStatusPage polling loop breaks.

Common situations: Prompts containing content that trips Bing's content moderation (violence, celebrities, nsfw-adjacent terms, certain brand names); also occurs when Bing A/B flags harmless prompts (photo-realistic person descriptions) or regional policy differences.

Related errors


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