{"record":{"id":"653f9fdebe16f1cd","repo":"xtekky/gpt4free","slug":"item","errorCode":null,"errorMessage":"{item}","messagePattern":"\\{item\\}","errorType":"exception","errorClass":"MissingAuthError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/Pollinations.py","lineNumber":510,"sourceCode":"                    responses.add(\n                        Exception(\n                            f\"Unexpected content type: {response.headers.get('content-type')}\"\n                        )\n                    )\n\n            tasks: list[asyncio.Task] = []\n            for i in range(int(n)):\n                tasks.append(asyncio.create_task(get_image(responses, i, seed)))\n            while finished < n or len(responses) > 0:\n                while len(responses) > 0:\n                    item = responses.pop()\n                    if isinstance(item, Exception):\n                        if finished < 2:\n                            yield Reasoning(status=\"\")\n                            for task in tasks:\n                                task.cancel()\n                            if cls.login_url in str(item):\n                                raise MissingAuthError(item)\n                            raise item\n                        else:\n                            finished += 1\n                            yield Reasoning(\n                                label=f\"Image {finished}/{n} failed after {time.time() - start:.2f}s: {item}\"\n                            )\n                    else:\n                        finished += 1\n                        yield Reasoning(\n                            label=f\"Image {finished}/{n} generated in {time.time() - start:.2f}s\"\n                        )\n                        yield item\n                await asyncio.sleep(1)\n            yield Reasoning(status=\"\")\n            await asyncio.gather(*tasks)\n\n    @classmethod\n    async def _generate_text(","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/Pollinations.py#L492-L528","documentation":"In Pollinations' multi-image generation, when fewer than 2 images have finished and a task returns an Exception, the whole batch is cancelled and the exception is re-raised (as MissingAuthError if its text mentions the provider login_url, otherwise verbatim). The '{item}' message is the underlying failure text — often 'Unexpected content type: ...' from the fetcher or a 401/login-required error.","triggerScenarios":"Requesting n>=1 images where the first or second concurrent fetch fails (non-image content type returned, auth required for the model, or a fetch exception); because finished < 2, partial success is not tolerated and the error propagates.","commonSituations":"Using premium/queued Pollinations models that now require a token (item contains the login URL); upstream returning an error page (content-type text/html) instead of image bytes; requesting more images than the anonymous tier allows; transient seed-specific failures.","solutions":["If the message contains a login/auth URL, obtain a Pollinations token/API key and configure auth instead of anonymous access.","Switch to an openly available model (e.g. 'flux') and fewer images per request.","Retry once — single-image transient failures often clear.","Update g4f; Pollinations tier rules change frequently."],"exampleFix":"# before\nimg = await Pollinations.create_async_generator(model='gptimage', prompt=p, n=4)\n\n# after\nimg = await Pollinations.create_async_generator(model='flux', prompt=p)  # anonymous-friendly model, n=1","handlingStrategy":"try-catch","validationCode":"# anonymous-safe request shape: open model, small n\nfrom g4f.Provider.Pollinations import Pollinations\n\ndef pollinations_request_safe(model: str, n: int) -> bool:\n    return model in Pollinations.get_models() and model == 'flux' and n <= 2","typeGuard":"def is_missing_auth(exc: Exception) -> bool:\n    \"\"\"True when the failure is auth, not a transient fetch error.\"\"\"\n    from g4f.errors import MissingAuthError\n    return isinstance(exc, MissingAuthError)","tryCatchPattern":"from g4f.errors import MissingAuthError\ntry:\n    imgs = [c async for c in Pollinations.create_async_generator(model, prompt, n=n)]\nexcept MissingAuthError:\n    imgs = [c async for c in Pollinations.create_async_generator('flux', prompt)]  # fallback model\nexcept Exception:\n    await asyncio.sleep(3)\n    imgs = [c async for c in Pollinations.create_async_generator(model, prompt)]  # one retry","preventionTips":["Use openly available models anonymously","Configure a Pollinations token for premium models","Keep n small (first failures abort the whole batch)","Distinguish MissingAuthError (needs token) from transient errors (retry)"],"tags":["pollinations","image-generation","auth","batch","missing-auth"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}