{"record":{"id":"586f952662dc71a9","repo":"can1357/oh-my-pi","slug":"no-image-api-credentials-found-connect-a-codex-c","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/image-gen.ts","lineNumber":1751,"sourceCode":"\t\t\t\t\t\t\tmodel,\n\t\t\t\t\t\t\timageCount: inlineImages.length,\n\t\t\t\t\t\t\timagePaths,\n\t\t\t\t\t\t\timages: inlineImages,\n\t\t\t\t\t\t\tresponseText,\n\t\t\t\t\t\t\tpromptFeedback: data.promptFeedback,\n\t\t\t\t\t\t\tusage: data.usageMetadata,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!(error instanceof ProviderHttpError) || requestSignal?.aborted) {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t}\n\t\t\t\t\tfailures.push({ provider, error });\n\t\t\t\t}\n\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);","sourceCodeStart":1733,"sourceCodeEnd":1769,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/image-gen.ts#L1733-L1769","documentation":"Before attempting any provider, the image-gen tool probes for credentials across all supported image providers (OpenAI/Codex, google-antigravity, xAI OAuth, OpenAI, xAI, OpenRouter, Gemini/Google, DeepInfra keys). If none are found it throws this error instead of attempting requests. It aggregates every supported auth path into one actionable message.","triggerScenarios":"Invoking the image generation tool in an environment with no OPENAI_API_KEY, XAI_API_KEY, OPENROUTER_API_KEY, GEMINI_API_KEY, GOOGLE_API_KEY, DEEPINFRA_API_KEY, no Codex (ChatGPT) subscription connection, and no google-antigravity or xAI OAuth login, at image-gen.ts:1751.","commonSituations":"Fresh install with no /login performed; CI runners without secrets exported; dotenv/.env not loaded by the CLI; keys present but under wrong variable names; shell profile not sourced in non-interactive contexts.","solutions":["Set at least one supported key env var, e.g. export OPENAI_API_KEY=sk-... (or GEMINI_API_KEY / OPENROUTER_API_KEY / XAI_API_KEY / DEEPINFRA_API_KEY).","Or run /login and connect xAI Grok OAuth or google-antigravity.","Or use a Codex (ChatGPT) subscription / GPT Responses model with existing OpenAI credentials.","Confirm the env var names exactly (GOOGLE_API_KEY vs GOOGLE_API_TOKEN etc.) and that the process can see them.","If keys live in a .env file, ensure the CLI loads it or export them in the invoking shell."],"exampleFix":"// before (no credentials)\n$ omp -p \"draw a cat\"\n// after\n$ export GEMINI_API_KEY=AIza...\n$ omp -p \"draw a cat\"","handlingStrategy":"validation","validationCode":"const IMAGE_KEY_VARS = ['OPENAI_API_KEY','XAI_API_KEY','OPENROUTER_API_KEY','GEMINI_API_KEY','GOOGLE_API_KEY','DEEPINFRA_API_KEY'] as const;\nconst hasImageCreds = IMAGE_KEY_VARS.some(v => process.env[v]) || oauthConnected('xai') || oauthConnected('antigravity');\nif (!hasImageCreds) throw new Error('Configure at least one image provider credential before calling image generation');","typeGuard":null,"tryCatchPattern":"try {\n  await imageGen(params);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('No image API credentials found')) {\n    printSetupInstructions(); // point user to /login or env var export\n  } else throw err;\n}","preventionTips":["Check credential presence at CLI startup and show setup guidance early","Keep env vars in a sourced .env so non-interactive runs see them","Prefer one documented primary provider plus its key in CI secrets","Use exact variable names from the error message"],"tags":["authentication","credentials","configuration","image-generation","env-var"],"backgroundTag":"missing-api-key","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}