openclaw - ✅(Solved) Fix [Bug]: OpenAI gpt-image-2 image edits abort in OpenClaw for some multi-ref requests that succeed via direct Images API [1 pull requests, 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#70642Fetched 2026-04-24 05:55:15
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
closed ×1commented ×1cross-referenced ×1referenced ×1

image_generate with openai/gpt-image-2 can abort on complex reference-image edit requests even though the same request succeeds against OpenAI's official Images API.

The failing OpenClaw path appears to submit /v1/images/edits as JSON with data URLs, while the official working path uses multipart form-data file uploads.

Root Cause

image_generate with openai/gpt-image-2 can abort on complex reference-image edit requests even though the same request succeeds against OpenAI's official Images API.

The failing OpenClaw path appears to submit /v1/images/edits as JSON with data URLs, while the official working path uses multipart form-data file uploads.

Fix Action

Fixed

PR fix notes

PR #70657: fix(openai): send image edits as multipart uploads

Description (problem / solution / changelog)

Summary

  • send OpenAI image edit requests as multipart form-data uploads instead of JSON data URLs
  • preserve multi-image edit support by attaching each reference as image[]
  • update OpenAI provider tests to assert multipart edit submission for both OpenAI and Azure URLs

Testing

  • ./node_modules/.bin/vitest run --config test/vitest/vitest.extension-provider-openai.config.ts extensions/openai/image-generation-provider.test.ts extensions/openai/index.test.ts

Closes #70642.

Changed files

  • extensions/openai/image-generation-provider.test.ts (added, +528/-0)
  • extensions/openai/image-generation-provider.ts (added, +247/-0)
  • extensions/openai/index.test.ts (added, +628/-0)
  • src/media-understanding/shared.ts (added, +539/-0)
  • src/plugin-sdk/provider-http.ts (added, +44/-0)
RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug

Summary

image_generate with openai/gpt-image-2 can abort on complex reference-image edit requests even though the same request succeeds against OpenAI's official Images API.

The failing OpenClaw path appears to submit /v1/images/edits as JSON with data URLs, while the official working path uses multipart form-data file uploads.

Reproduction

OpenClaw failures observed

Using image_generate with model=openai/gpt-image-2:

  1. Cindy 2 refs + size=1024x1536 + count=2This operation was aborted
  2. Cindy 2 refs + aspectRatio=2:3 + count=1This operation was aborted
  3. Cindy 3 refs + size=1024x1536 + count=2This operation was aborted

OpenClaw requests that do work

  • text-only + size/count
  • single-ref + size/count
  • simple-object multi-ref + size/count
  • Cindy 2 refs + size=1024x1536 + count=1

Direct API control test

Using the same OPENAI_API_KEY, the same Cindy-style edit succeeds when sent directly to OpenAI:

  • endpoint: POST /v1/images/edits
  • model: gpt-image-2
  • refs: 2 images
  • n=2
  • size=1024x1536
  • result: HTTP 200, 2 images returned

So this does not look like a gpt-image-2 product limitation.

Likely cause

Current OpenClaw OpenAI image edit provider sends edits as JSON:

  • url: /v1/images/edits
  • body contains images: [{ image_url: data:... }]

But the official Images API edit flow expects multipart form-data uploads for source images, and direct multipart requests succeed in cases where the OpenClaw JSON submission aborts.

Relevant local implementation:

  • extensions/openai/image-generation-provider.ts

Expected behavior

OpenClaw image_generate should support the same successful multi-reference edit combinations that the official OpenAI Images API supports, including:

  • multiple reference images
  • n > 1
  • explicit size

Actual behavior

Certain complex OpenAI edit requests abort in OpenClaw while succeeding via direct OpenAI API calls.

Environment

  • OpenClaw: 2026.4.21 (2979405)
  • Provider: bundled OpenAI image generation provider
  • Model: openai/gpt-image-2

Notes

I locally verified that the direct API success case uses multipart form-data file uploads, while OpenClaw currently posts JSON for image edits. That transport mismatch looks like the first thing to check.

extent analysis

TL;DR

The most likely fix is to modify the OpenClaw OpenAI image edit provider to send edits as multipart form-data uploads instead of JSON.

Guidance

  • Verify that the issue is indeed caused by the transport mismatch by checking the request format sent by OpenClaw and comparing it to the successful direct API call.
  • Update the image-generation-provider.ts file to send multipart form-data uploads for image edits, similar to the official OpenAI Images API.
  • Test the updated provider with the same complex edit requests that previously aborted to ensure they now succeed.
  • Consider adding error handling and logging to help diagnose any future issues with the image edit provider.

Example

// Example of sending a multipart form-data upload in Node.js
const formData = new FormData();
formData.append('image', imageBuffer, 'image.png');
fetch('/v1/images/edits', {
  method: 'POST',
  body: formData,
});

Notes

The fix assumes that the issue is solely caused by the transport mismatch and that the OpenClaw implementation can be updated to send multipart form-data uploads. Additional testing and verification may be necessary to ensure the updated provider works correctly for all use cases.

Recommendation

Apply workaround: Update the OpenClaw OpenAI image edit provider to send multipart form-data uploads. This change should allow OpenClaw to support the same successful multi-reference edit combinations as the official OpenAI Images API.

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…

FAQ

Expected behavior

OpenClaw image_generate should support the same successful multi-reference edit combinations that the official OpenAI Images API supports, including:

  • multiple reference images
  • n > 1
  • explicit size

Still need to ship something?

×6

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

Back to top recommendations

TRENDING