openai / openai/openai-python

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

Open
#3,256 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
31.6k
Forks
5.7k
Avg merge
1d 6h
Merged PRs (30d)
96

Description

Confirm this is an issue with the Python library and not an underlying OpenAI API
  • This is an issue with the Python library
Describe the bug

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

As indicated in following doc, /images/edits supports image_url as input (JSON).
But when passing url to client.images.edit(), rather than file object, API throws 400 error.

I am afraid /images/edits doesn't support image_url as image input. Doc is wrong.

https://developers.openai.com/api/reference/resources/images/methods/edit#(resource)%20images%20%3E%20(method)%20edit%20%3E%20(params)%200.non_streaming%20%3E%20(param)%20images%20%3E%20(schema)

To Reproduce

result = client.images.edit(
model="gpt-image-1.5",
images={
image_url: "https://yavuzceliker.github.io/sample-images/image-1021.jpg"},
prompt=prompt
)

Code snippets

OS

Windows 11

Python version

v3.11.4

Library version

2.26.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at client.images.edit() and reproduce the 400 error with the image_url example from the issue. Compare the library's request handling with the referenced /images/edits documentation and verify that the resulting behavior or documentation clearly matches the supported input format.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.