can1357/oh-my-pi · error · Error

No image API credentials found. Connect a Codex (ChatGPT) su

Error message

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.

What it means

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.

Source

Thrown at packages/coding-agent/src/tools/image-gen.ts:1751

							model,
							imageCount: inlineImages.length,
							imagePaths,
							images: inlineImages,
							responseText,
							promptFeedback: data.promptFeedback,
							usage: data.usageMetadata,
						},
					};
				} catch (error) {
					if (!(error instanceof ProviderHttpError) || requestSignal?.aborted) {
						throw error;
					}
					failures.push({ provider, error });
				}
			}

			if (!foundCredentials) {
				throw new Error(
					"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.",
				);
			}

			if (failures.length === 0 && unsupportedAspectRatioProvider) {
				assertImageAspectRatioSupported(unsupportedAspectRatioProvider, params.aspect_ratio);
			}

			if (failures.length === 0 && editUnsupportedProvider) {
				throw new Error(
					`${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.`,
				);
			}

			throw new AggregateError(
				failures.map(failure => failure.error),
				`Image generation failed for all credentialed providers: ${failures.map(failure => failure.provider).join(", ")}`,
			);

View on GitHub (pinned to 9690622007)

Solutions

  1. 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).
  2. Or run /login and connect xAI Grok OAuth or google-antigravity.
  3. Or use a Codex (ChatGPT) subscription / GPT Responses model with existing OpenAI credentials.
  4. Confirm the env var names exactly (GOOGLE_API_KEY vs GOOGLE_API_TOKEN etc.) and that the process can see them.
  5. If keys live in a .env file, ensure the CLI loads it or export them in the invoking shell.

Example fix

// before (no credentials)
$ omp -p "draw a cat"
// after
$ export GEMINI_API_KEY=AIza...
$ omp -p "draw a cat"
Defensive patterns

Strategy: validation

Validate before calling

const IMAGE_KEY_VARS = ['OPENAI_API_KEY','XAI_API_KEY','OPENROUTER_API_KEY','GEMINI_API_KEY','GOOGLE_API_KEY','DEEPINFRA_API_KEY'] as const;
const hasImageCreds = IMAGE_KEY_VARS.some(v => process.env[v]) || oauthConnected('xai') || oauthConnected('antigravity');
if (!hasImageCreds) throw new Error('Configure at least one image provider credential before calling image generation');

Try / catch

try {
  await imageGen(params);
} catch (err) {
  if (err instanceof Error && err.message.startsWith('No image API credentials found')) {
    printSetupInstructions(); // point user to /login or env var export
  } else throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/586f952662dc71a9. Report an issue: GitHub.