{"record":{"id":"455d7cd833307752","repo":"xtekky/gpt4free","slug":"create-images-failed-error","errorCode":null,"errorMessage":"Create images failed: {error}","messagePattern":"Create images failed: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/bing/create_images.py","lineNumber":103,"sourceCode":"        RuntimeError: If image creation fails or times out.\n    \"\"\"\n    if not has_requirements:\n        raise MissingRequirementsError('Install \"beautifulsoup4\" package')\n    url_encoded_prompt = quote(prompt)\n    payload = f\"q={url_encoded_prompt}&rt=4&FORM=GENCRE\"\n    url = f\"{BING_URL}/images/create?q={url_encoded_prompt}&rt=4&FORM=GENCRE\"\n    async with session.post(\n        url, allow_redirects=False, data=payload, timeout=timeout\n    ) as response:\n        response.raise_for_status()\n        text = (await response.text()).lower()\n        if \"0 coins available\" in text:\n            raise RateLimitError(\n                \"No coins left. Log in with a different account or wait a while\"\n            )\n        for error in ERRORS:\n            if error in text:\n                raise RuntimeError(f\"Create images failed: {error}\")\n    if response.status != 302:\n        url = f\"{BING_URL}/images/create?q={url_encoded_prompt}&rt=3&FORM=GENCRE\"\n        async with session.post(\n            url, allow_redirects=False, timeout=timeout\n        ) as response:\n            if response.status != 302:\n                raise RuntimeError(f\"Create images failed. Code: {response.status}\")\n\n    redirect_url = response.headers[\"Location\"].replace(\"&nfy=1\", \"\")\n    redirect_url = f\"{BING_URL}{redirect_url}\"\n    request_id = redirect_url.split(\"id=\")[-1]\n    async with session.get(redirect_url) as response:\n        response.raise_for_status()\n\n    polling_url = (\n        f\"{BING_URL}/images/create/async/results/{request_id}?q={url_encoded_prompt}\"\n    )\n    start_time = time.time()","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/bing/create_images.py#L85-L121","documentation":"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.","triggerScenarios":"Submitting a prompt that triggers a Bing-side failure page: blocked content, unsafe prompt classification, or regional/service notice in the response text.","commonSituations":"Prompts with policy-sensitive terms, service outage pages matching an ERRORS entry, region-locked features.","solutions":["Rephrase the prompt to avoid the flagged content indicated in the error string","Catch RuntimeError and fall back to another image provider for rejected prompts","Retry later if the matched error text indicates a temporary service condition"],"exampleFix":"# before\nimages = create_images(session, prompt, cookies)\n\n# after\ntry:\n    images = create_images(session, prompt, cookies)\nexcept RuntimeError as e:\n    if 'Create images failed' in str(e):\n        images = fallback_image_provider(prompt)\n    else:\n        raise","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    images = create_images(session, prompt, cookies)\nexcept RuntimeError as e:\n    if str(e).startswith('Create images failed:'):\n        images = fallback_image_provider(prompt)\n    else:\n        raise","preventionTips":["Keep an alternative image provider wired for policy-rejected prompts","Sanitize prompts of obvious policy-triggering terms before submission"],"tags":["content-policy","bing","image-generation","g4f"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}