Skip to content

feat(images): support ImageInputReferenceParam in images.edit()#3259

Open
JiwaniZakir wants to merge 1 commit into
openai:mainfrom
JiwaniZakir:fix/issue-3256
Open

feat(images): support ImageInputReferenceParam in images.edit()#3259
JiwaniZakir wants to merge 1 commit into
openai:mainfrom
JiwaniZakir:fix/issue-3256

Conversation

@JiwaniZakir
Copy link
Copy Markdown

The images.edit() endpoint only accepted file uploads for the image parameter, but the API also supports passing an image reference (file_id or image_url) via ImageInputReferenceParam. Callers passing a reference dict would get a multipart/form-data encoding error instead of a JSON request.

Added ImageInputReferenceParam to the accepted union type for the image parameter in both Images and AsyncImages, and added detection logic so that reference inputs bypass multipart encoding and are sent as JSON instead.

To verify, call client.images.edit(image={"image_url": "https://..."}, prompt="...") and confirm it sends a JSON body rather than failing with a multipart error.

Fixes #3256

Allow passing an ImageInputReferenceParam (with file_id or image_url) as
the image argument to images.edit(), in addition to file uploads. When a
URL/reference input is detected, skip multipart encoding and send JSON
instead. Closes openai#3256
@JiwaniZakir JiwaniZakir requested a review from a team as a code owner May 18, 2026 03:06
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4029d39731

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = not_given,
) -> ImagesResponse | Stream[ImageEditStreamEvent]:
is_url_input = is_mapping(image) or (is_list(image) and len(image) > 0 and is_mapping(image[0]))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Send image references under the JSON images field

When image is a reference dict/list this branch switches the request to application/json, but the body constructed below still uses the multipart-only image key. The image edit JSON API expects images as an array of {image_url|file_id} references, so client.images.edit(image={"image_url": ...}, ...) posts the wrong payload and the new reference-input path is rejected instead of working. Please translate reference inputs to the images field, wrapping a single reference in an array, when taking this JSON path.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

client.images.edit() method failed to pass image_url as image input

1 participant