go-openai icon indicating copy to clipboard operation
go-openai copied to clipboard

Fix for Edit Image content type requirement

Open Static-Flow opened this issue 7 months ago • 3 comments

Describe the change PR to fix #967 and #601 The OpenAI Edit Image endpoint /v1/images/edits only accepts specific image formats as seen in error responses like so: status: 400 Bad Request, message: Invalid file 'image': unsupported mimetype ('image/jpeg'). Supported file formats are 'image/png'. Even though the API docs say other types are supported https://platform.openai.com/docs/api-reference/images/createEdit:

For gpt-image-1, each image should be a png, webp, or jpg file less than 25MB.

This is not true as of 4-28-25 I think because it is still stuck on DALLE mode which only allows PNGs.

Describe your solution Pretty simple fix really, replaced the call to the default helper method which only does application/octet-stream with the code the helper method calls and set the content-type to image/png

Tests I ran a modified version of the image example which calls the edit image endpoint instead using my forked version and it worked successfully.

Static-Flow avatar Apr 28 '25 15:04 Static-Flow

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 85.46%. Comparing base (774fc9d) to head (2780acb). Report is 97 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #979       +/-   ##
===========================================
- Coverage   98.46%   85.46%   -13.00%     
===========================================
  Files          24       43       +19     
  Lines        1364     2270      +906     
===========================================
+ Hits         1343     1940      +597     
- Misses         15      308      +293     
- Partials        6       22       +16     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Apr 28 '25 15:04 codecov[bot]

@sashabaranov I'm not sure how to fix this codecov failing CI check. It says there's a 13% drop in testing coverage but nothing I changed materially impacted tests. It seems to think there's more changes than what my PR made, maybe due to BASE commit is 91 commits behind HEAD on master? Please advise, the edit image api's are currently broken without this fix.

Static-Flow avatar Apr 29 '25 15:04 Static-Flow

@Static-Flow on the coverage note, could you try rebasing your branch on the latest master branch?

sashabaranov avatar May 03 '25 20:05 sashabaranov