{"record":{"id":"1cb762348058b403","repo":"can1357/oh-my-pi","slug":"image-generation-failed-for-all-credentialed-provi","errorCode":null,"errorMessage":"Image generation failed for all credentialed providers: ${failures.map(failure => failure.provider).join(\", \")}","messagePattern":"Image generation failed for all credentialed providers: (.+?)","errorType":"exception","errorClass":"AggregateError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/image-gen.ts","lineNumber":1766,"sourceCode":"\t\t\t}\n\n\t\t\tif (!foundCredentials) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"No image API credentials found. Connect a Codex (ChatGPT) subscription, use a GPT Responses/Codex model with OpenAI credentials, log in with google-antigravity or xAI Grok OAuth, or set OPENAI_API_KEY, XAI_API_KEY, OPENROUTER_API_KEY, GEMINI_API_KEY, GOOGLE_API_KEY, or DEEPINFRA_API_KEY.\",\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (failures.length === 0 && unsupportedAspectRatioProvider) {\n\t\t\t\tassertImageAspectRatioSupported(unsupportedAspectRatioProvider, params.aspect_ratio);\n\t\t\t}\n\n\t\t\tif (failures.length === 0 && editUnsupportedProvider) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`${editUnsupportedProvider} image generation is text-to-image only and cannot edit input images. Configure an edit-capable provider (openai, openai-codex, antigravity, xai, openrouter, gemini) or retry without input images.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tthrow new AggregateError(\n\t\t\t\tfailures.map(failure => failure.error),\n\t\t\t\t`Image generation failed for all credentialed providers: ${failures.map(failure => failure.provider).join(\", \")}`,\n\t\t\t);\n\t\t});\n\t},\n};\n\nexport async function getImageGenTools(\n\t_modelRegistry?: ModelRegistry,\n\t_activeModel?: Model,\n): Promise<Array<CustomTool<typeof imageGenSchema, ImageGenToolDetails>>> {\n\treturn [imageGenTool];\n}\n\nexport async function getImageGenToolsWithRegistry(\n\t_modelRegistry: ModelRegistry,\n\t_activeModel?: Model,\n): Promise<Array<CustomTool<typeof imageGenSchema, ImageGenToolDetails>>> {","sourceCodeStart":1748,"sourceCodeEnd":1784,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/image-gen.ts#L1748-L1784","documentation":"Final fallback after the tool attempted every credentialed image provider and each attempt failed. An AggregateError is thrown whose errors array holds each provider's underlying exception, with a message listing the providers that were tried. The individual causes must be inspected to know why each provider failed.","triggerScenarios":"All credentialed providers attempted and rejected — e.g. OpenAI 401 + Gemini 429 + OpenRouter 402 in one run — reaching image-gen.ts:1766; only possible when at least one credential existed (otherwise 2515 fires).","commonSituations":"Multiple keys expired or revoked at once; shared egress IP rate-limited across providers; transient multi-provider outage; all keys lacking image-model access; free-tier quotas exhausted everywhere.","solutions":["Inspect aggregate.errors — each element corresponds to a provider listed in the message and carries its HTTP status/detail.","Fix the underlying per-provider causes (keys, quotas, model ids) identified in the nested errors.","Retry after backoff if the nested errors are 429/5xx (transient).","Configure one healthy provider with a funded account and a known-good image model.","Reduce request complexity (size, count) if providers reject the parameters."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const credentialed = providers.filter(p => hasCredential(p));\nif (credentialed.length === 0) failFast('no image credentials');\nif (credentialed.every(p => !p.healthy)) warn('all credentialed image providers recently failing');","typeGuard":null,"tryCatchPattern":"try {\n  return await imageGen(params);\n} catch (err) {\n  if (err instanceof AggregateError) {\n    for (const cause of err.errors) logProviderCause(cause); // per-provider status/detail\n    if (err.errors.every(isTransient)) return retryWithBackoff(() => imageGen(params));\n  }\n  throw err;\n}","preventionTips":["Always inspect AggregateError.errors — the summary line only lists provider names","Maintain at least one provider with a funded, verified account","Classify nested errors (429/5xx = transient, 401/402 = config) before retrying","Monitor provider status pages for correlated outages"],"tags":["network","aggregate","image-generation","multi-provider","provider-error"],"backgroundTag":"all-providers-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}