can1357/oh-my-pi · error · Error
No xAI credentials. Run /login → xAI Grok OAuth (SuperGrok o
Error message
No xAI credentials. Run /login → xAI Grok OAuth (SuperGrok or X Premium+) or set XAI_API_KEY.
What it means
Thrown when resolveXAIHttpCredentials cannot find any xAI credentials in the model registry: neither an xAI Grok OAuth login (SuperGrok / X Premium+) nor an XAI_API_KEY environment variable. The xAI image endpoint requires authenticated HTTP calls, so without credentials the provider is skipped/aborted.
Source
Thrown at packages/coding-agent/src/tools/image-gen.ts:1478
details: {
provider,
model,
imageCount: parsed.images.length,
imagePaths,
images: parsed.images,
responseText,
usage: parsed.usage,
},
};
}
if (provider === "xai") {
if (!ctx.modelRegistry) {
throw new Error("Missing modelRegistry for xAI image generation");
}
const xaiCreds = await resolveXAIHttpCredentials(ctx.modelRegistry, resolvedModel);
if (!xaiCreds) {
throw new Error(
"No xAI credentials. Run /login → xAI Grok OAuth (SuperGrok or X Premium+) or set XAI_API_KEY.",
);
}
const prompt = assemblePrompt(params);
const aspectRatio = params.aspect_ratio ?? "1:1";
const xaiResolution = resolveXAIResolution(params.image_size);
const isEdit = resolvedImages.length > 0;
if (isEdit && resolvedImages.length > XAI_MAX_EDIT_IMAGES) {
throw new Error(
`xAI image edits accept up to ${XAI_MAX_EDIT_IMAGES} reference images; got ${resolvedImages.length}.`,
);
}
const xaiBaseBody: XAIImageRequestBase = {
model: resolvedModel,
prompt,View on GitHub (pinned to 9690622007)
Solutions
- Run /login in the agent and choose xAI Grok OAuth (SuperGrok or X Premium+).
- Export XAI_API_KEY with a valid xAI API key: export XAI_API_KEY=xai-...
- Verify the key is set in the environment the CLI actually sees (echo $XAI_API_KEY in the same shell/CI job).
- Pick a different credentialed provider (OPENAI_API_KEY, GEMINI_API_KEY, etc.) if xAI access is unavailable.
Example fix
// before $ omp -p "generate an image" // after $ export XAI_API_KEY=xai-... $ omp -p "generate an image"
Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.XAI_API_KEY) {
console.error('xAI not configured: run /login (xAI Grok OAuth) or set XAI_API_KEY');
process.exit(1);
} Try / catch
try {
await imageGen({ provider: 'xai', ...params });
} catch (err) {
if (err instanceof Error && err.message.includes('No xAI credentials')) {
console.error('Set XAI_API_KEY or complete xAI OAuth via /login before retrying.');
} else throw err;
} Prevention
- Run /login once per machine and confirm OAuth state persists
- Export XAI_API_KEY in CI secrets and shell profiles the CLI actually loads
- Probe credentials at app startup, not at first image request
- Use the exact env var name XAI_API_KEY (no variants)
When it happens
Trigger: Running image generation (or edit) routed to provider=xai with no xAI OAuth session and XAI_API_KEY unset or empty in the environment, at image-gen.ts:1478.
Common situations: Fresh machine without /login; CI environment lacking XAI_API_KEY; user logged into xAI via a different config dir; XAI_API_KEY typo'd (e.g. XAI_KEY) or scoped to a shell profile not loaded by the CLI.
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
- No image API credentials found. Connect a Codex (ChatGPT) su
- credentials ${usernameKey} and ${passwordKey} must be config
- Missing modelRegistry for xAI image generation
- No API key available for ${model.provider}/${model.id}. Conf
- No Codex OAuth credentials found. Login with 'omp /login ope
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/ad97cab51492c50d.
Report an issue: GitHub.