openclaw - 💡(How to fix) Fix Bug: Codex OAuth image generation fails — hardcoded gpt-5.4 model AND baseUrl drops /codex path [1 comments, 2 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#71580Fetched 2026-04-26 05:11:11
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
subscribed ×2closed ×1commented ×1mentioned ×1

Codex OAuth image generation fails on OpenClaw 2026.4.23 for two reasons:

  1. Hardcoded gpt-5.4 model — the Codex API no longer accepts gpt-5.4, returns HTTP 500
  2. baseUrl override drops /codex path — when openclaw onboard/openclaw doctor sets baseUrl: "https://chatgpt.com/backend-api", image generation sends requests to /backend-api/responses instead of /backend-api/codex/responses, causing HTTP 403

Both bugs must be fixed for Codex OAuth image generation to work.

Error Message

Codex image generation: response error statusCode=500 {"error":{"message":"An error occurred while processing your request..."},"request_id":"..."}

Why this is a code bug, not a user error

Root Cause

In src/image-generation/provider.ts (bundled as dist/image-generation-provider-dj3H3v8Q.js), generateOpenAICodexImage hardcodes:

body: {
    model: "gpt-5.4",  // ← hardcoded, Codex API now requires gpt-5.5
    input: [{ role: "user", content }],
    instructions: OPENAI_CODEX_IMAGE_INSTRUCTIONS,
    tools: [{ type: "function", name: "generate_image", ... }],
    tool_choice: { type: "function", name: "generate_image" }
}

Fix Action

Workaround

Remove baseUrl from the openai-codex provider config:

"openai-codex": {}

Or ensure it includes /codex:

"openai-codex": {
  "baseUrl": "https://chatgpt.com/backend-api/codex"
}

⚠️ The second option may break chat if the chat code expects the shorter URL. Needs testing.


Code Example

body: {
    model: "gpt-5.4",  // ← hardcoded, Codex API now requires gpt-5.5
    input: [{ role: "user", content }],
    instructions: OPENAI_CODEX_IMAGE_INSTRUCTIONS,
    tools: [{ type: "function", name: "generate_image", ... }],
    tool_choice: { type: "function", name: "generate_image" }
}

---

image auth selected: provider=openai-codex mode=oauth transport=codex-responses requestedModel=gpt-image-2 responsesModel=gpt-5.4 timeoutMs=120000
Codex image generation: response error statusCode=500

---

{"error":{"message":"An error occurred while processing your request..."},"request_id":"..."}

---

FILE="$(npm root -g)/openclaw/dist/image-generation-provider-dj3H3v8Q.js"

# Fix the model in the request body
sed -i 's/model: "gpt-5.4"/model: "gpt-5.5"/' "$FILE"

# Fix the log message
sed -i 's/responsesModel=gpt-5.4/responsesModel=gpt-5.5/' "$FILE"

openclaw gateway restart

---

// ~/.openclaw/openclaw.json → models.providers
"openai-codex": {
  "baseUrl": "https://chatgpt.com/backend-api"
}

---

defaultBaseUrl: "https://chatgpt.com/backend-api/codex"

---

"openai-codex": {}

---

"openai-codex": {
  "baseUrl": "https://chatgpt.com/backend-api/codex"
}
RAW_BUFFERClick to expand / collapse

Summary

Codex OAuth image generation fails on OpenClaw 2026.4.23 for two reasons:

  1. Hardcoded gpt-5.4 model — the Codex API no longer accepts gpt-5.4, returns HTTP 500
  2. baseUrl override drops /codex path — when openclaw onboard/openclaw doctor sets baseUrl: "https://chatgpt.com/backend-api", image generation sends requests to /backend-api/responses instead of /backend-api/codex/responses, causing HTTP 403

Both bugs must be fixed for Codex OAuth image generation to work.

Bug 1: Hardcoded gpt-5.4 model (HTTP 500)

Reproduction

  1. Install OpenClaw 2026.4.23
  2. Configure imageGenerationModel.primary: "openai/gpt-image-2" with Codex OAuth
  3. Run image_generate with any prompt
  4. Receive HTTP 500 from chatgpt.com/backend-api/codex/responses

Root Cause

In src/image-generation/provider.ts (bundled as dist/image-generation-provider-dj3H3v8Q.js), generateOpenAICodexImage hardcodes:

body: {
    model: "gpt-5.4",  // ← hardcoded, Codex API now requires gpt-5.5
    input: [{ role: "user", content }],
    instructions: OPENAI_CODEX_IMAGE_INSTRUCTIONS,
    tools: [{ type: "function", name: "generate_image", ... }],
    tool_choice: { type: "function", name: "generate_image" }
}

Log Evidence

image auth selected: provider=openai-codex mode=oauth transport=codex-responses requestedModel=gpt-image-2 responsesModel=gpt-5.4 timeoutMs=120000
Codex image generation: response error statusCode=500

Response from Codex API

{"error":{"message":"An error occurred while processing your request..."},"request_id":"..."}

HTTP 500 with x-envoy-upstream-service-time: 159.

Workaround

FILE="$(npm root -g)/openclaw/dist/image-generation-provider-dj3H3v8Q.js"

# Fix the model in the request body
sed -i 's/model: "gpt-5.4"/model: "gpt-5.5"/' "$FILE"

# Fix the log message
sed -i 's/responsesModel=gpt-5.4/responsesModel=gpt-5.5/' "$FILE"

openclaw gateway restart

⚠️ Overwritten by npm update -g openclaw. Re-apply after updating.


Bug 2: baseUrl override drops /codex path (HTTP 403)

The problem

openclaw onboard / openclaw doctor sets the openai-codex provider config to:

// ~/.openclaw/openclaw.json → models.providers
"openai-codex": {
  "baseUrl": "https://chatgpt.com/backend-api"
}

This is correct for chat (Codex Responses API), because the chat code builds the full path itself.

However, image generation uses resolveProviderHttpRequestConfig() with:

defaultBaseUrl: "https://chatgpt.com/backend-api/codex"

When a baseUrl is configured in models.providers["openai-codex"], the code uses that URL instead of the default, producing:

SourceURL + /responsesResult
Config baseUrlhttps://chatgpt.com/backend-api/responses403 Forbidden
Code defaulthttps://chatgpt.com/backend-api/codex/responses✅ Works

Why this is a code bug, not a user error

  1. openclaw onboard sets this baseUrl — users don't type it manually
  2. The config is correct for chat but silently breaks image generation
  3. The image generation code should handle the missing /codex suffix

Suggested fix

The code should detect when baseUrl is https://chatgpt.com/backend-api (without /codex) and append /codex for image generation, either:

  • Always append /codex if the baseUrl ends with /backend-api but not /backend-api/codex
  • Or use the capability: "image" parameter to override the baseUrl for image generation specifically

Workaround

Remove baseUrl from the openai-codex provider config:

"openai-codex": {}

Or ensure it includes /codex:

"openai-codex": {
  "baseUrl": "https://chatgpt.com/backend-api/codex"
}

⚠️ The second option may break chat if the chat code expects the shorter URL. Needs testing.


Environment

  • OpenClaw: 2026.4.23
  • Auth: OpenAI Codex OAuth (ChatGPT Plus subscription)
  • Config: imageGenerationModel.primary: "openai/gpt-image-2", no OPENAI_API_KEY
  • OS: CachyOS Linux 6.19.12-1-cachyos (x64)

Related

  • Issue #71312 — same gpt-5.4 root cause (closed)
  • PR #71405 — fix: gpt-5.4 → gpt-5.5
  • PR #71407 — use gpt-image-2 model on gpt-5.5 endpoint
  • PR #71408 — canonical fix: read model from config (merged by @steipete)
  • Issue #71513 — original report (closed, this issue supersedes it with both bugs)

extent analysis

TL;DR

Update the hardcoded gpt-5.4 model to gpt-5.5 and ensure the baseUrl includes the /codex path for image generation.

Guidance

  • Fix the hardcoded model in src/image-generation/provider.ts by changing model: "gpt-5.4" to model: "gpt-5.5".
  • Update the baseUrl in the openai-codex provider config to include /codex, e.g., "baseUrl": "https://chatgpt.com/backend-api/codex".
  • Alternatively, remove the baseUrl from the config to use the default value.
  • Verify the fixes by running image_generate with a prompt and checking for successful image generation.

Example

# Fix the model in the request body
sed -i 's/model: "gpt-5.4"/model: "gpt-5.5"/' "$(npm root -g)/openclaw/dist/image-generation-provider-dj3H3v8Q.js"`

# Fix the baseUrl in the config
echo '{"openai-codex": {"baseUrl": "https://chatgpt.com/backend-api/codex"}}' > ~/.openclaw/openclaw.json

Notes

These fixes may be overwritten by npm update -g openclaw, so re-apply them after updating. Additionally, the second workaround for the baseUrl issue may break chat functionality, so testing is necessary.

Recommendation

Apply the workarounds to update the hardcoded model and fix the baseUrl issue, as these changes are necessary for Codex OAuth image generation to work.

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