openclaw - 💡(How to fix) Fix [Bug]: gpt-image-2 image generation does not use existing openai-codex OAuth and still requires OPENAI_API_KEY [1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#70984Fetched 2026-04-24 10:37:06
View on GitHub
Comments
1
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
closed ×1commented ×1

openai/gpt-image-2 image generation does not appear to reuse an existing openai-codex OAuth profile in my setup, even though the docs say it should.

This seems different from #70885.

  • #70885 is about missing image scope
  • my case is that OpenClaw appears to go down the direct OpenAI API-key path for image generation and errors before it even uses Codex OAuth

Root Cause

openai/gpt-image-2 image generation does not appear to reuse an existing openai-codex OAuth profile in my setup, even though the docs say it should.

This seems different from #70885.

  • #70885 is about missing image scope
  • my case is that OpenClaw appears to go down the direct OpenAI API-key path for image generation and errors before it even uses Codex OAuth

Code Example

openclaw infer image generate \
  --model openai/gpt-image-2 \
  --size 1024x1536 \
  --output /tmp/test.png \
  --prompt "simple test prompt" \
  --json

---

No API key found for provider "openai". You are authenticated with OpenAI Codex OAuth. Use openai-codex/gpt-5.4 (OAuth) or set OPENAI_API_KEY to use openai/gpt-5.4.
RAW_BUFFERClick to expand / collapse

Summary

openai/gpt-image-2 image generation does not appear to reuse an existing openai-codex OAuth profile in my setup, even though the docs say it should.

This seems different from #70885.

  • #70885 is about missing image scope
  • my case is that OpenClaw appears to go down the direct OpenAI API-key path for image generation and errors before it even uses Codex OAuth

Environment

  • OpenClaw: 2026.4.22
  • observed on: 2026-04-24
  • platform: macOS
  • default model: openai-codex/gpt-5.4
  • image generation model: openai/gpt-image-2
  • openai-codex OAuth profile is present and healthy
  • no OPENAI_API_KEY configured

Relevant config/auth state

  • agents.defaults.imageGenerationModel.primary = openai/gpt-image-2
  • openclaw infer model auth status shows openai-codex OAuth status = ok
  • Codex text model usage works normally

Repro

openclaw infer image generate \
  --model openai/gpt-image-2 \
  --size 1024x1536 \
  --output /tmp/test.png \
  --prompt "simple test prompt" \
  --json

Actual result

The OpenAI candidate fails with:

No API key found for provider "openai". You are authenticated with OpenAI Codex OAuth. Use openai-codex/gpt-5.4 (OAuth) or set OPENAI_API_KEY to use openai/gpt-5.4.

Then OpenClaw falls through to fallback providers.

Expected result

Based on the docs, openai/gpt-image-2 should reuse the configured openai-codex OAuth profile instead of requiring OPENAI_API_KEY.

Why I think this is a different bug from #70885

In my case, the failure does not look like "OAuth is used but missing image scope".

It looks like image generation is not actually being routed through the Codex OAuth-backed path at all, and instead still requires direct OpenAI provider auth (OPENAI_API_KEY).

Extra notes

  • openclaw infer image providers shows OpenAI available/configured/selected with default model gpt-image-2
  • docs currently say Codex OAuth should work for openai/gpt-image-2
  • so this may be one of:
    1. CLI openclaw infer image generate is not wired to the same OAuth-aware path described in the docs/tool docs
    2. a regression causes the OpenAI image generation provider to bypass the Codex OAuth route and require direct API-key auth

Docs reference

https://docs.openclaw.ai/tools/image-generation

The docs currently say that when an openai-codex OAuth profile is configured, OpenClaw routes image requests through that same OAuth profile for openai/gpt-image-2.

extent analysis

TL;DR

The issue may be resolved by verifying the configuration of the openclaw CLI to ensure it is properly utilizing the openai-codex OAuth profile for image generation with openai/gpt-image-2.

Guidance

  • Review the openclaw configuration to confirm that the openai-codex OAuth profile is correctly set up and recognized by the CLI.
  • Check the output of openclaw infer model auth status to ensure the openai-codex OAuth status is indeed ok.
  • Verify that the agents.defaults.imageGenerationModel.primary is correctly set to openai/gpt-image-2 and that this setting is being applied during the image generation process.
  • Consider testing the image generation with a different model to isolate if the issue is specific to openai/gpt-image-2 or a broader configuration problem.

Notes

The exact cause of the issue is unclear without further debugging, but it appears to be related to how the openclaw CLI handles authentication for image generation with openai/gpt-image-2. The documentation suggests that the openai-codex OAuth profile should be reused, but the error message indicates a direct API key is required.

Recommendation

Apply workaround: Verify and adjust the openclaw configuration as necessary to ensure proper utilization of the openai-codex OAuth profile for image generation, as the current setup seems to bypass this authentication method in favor of requiring a direct OpenAI API key.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Bug]: gpt-image-2 image generation does not use existing openai-codex OAuth and still requires OPENAI_API_KEY [1 comments, 1 participants]