Skip to content

feat: add support for image generation using gpt-image-1 #971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

PChaparro
Copy link

@PChaparro PChaparro commented Apr 23, 2025

Describe the change

This PR adds support for the new gpt-image-1 model from OpenAI, along with several missing constants and optional fields related to image generation.

Provide OpenAI documentation link

Describe your solution

  • Added constant for the new gpt-image-1 model.

  • Included image sizes specific to the model: 1536x1024 (landscape), 1024x1536 (portrait).

  • Added quality levels: low, medium, high.

  • Added background options: transparent, opaque.

  • Added moderation level: low.

  • Added output formats: png, jpeg, webp.

  • Updated the Request and Response structs to include optional fields from the OpenAI API response that were previously missing.

  • Updated README file to include GPT Image 1.

Tests

I tested the changes locally by modifying examples/images/main.go to generate an image using the gpt-image-1 model and the new parameters. The request completed successfully, and the image was generated as expected.

Copy link

codecov bot commented Apr 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.44%. Comparing base (774fc9d) to head (4519cda).
Report is 97 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #971       +/-   ##
===========================================
- Coverage   98.46%   85.44%   -13.02%     
===========================================
  Files          24       43       +19     
  Lines        1364     2268      +904     
===========================================
+ Hits         1343     1938      +595     
- Misses         15      308      +293     
- Partials        6       22       +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@goodenough227
Copy link
Contributor

Please expedite the merging of this pull request; it is urgently needed.

@sashabaranov sashabaranov requested a review from Copilot April 28, 2025 12:45
@sashabaranov
Copy link
Owner

@goodenough227 @PChaparro Sorry, I'm not even looking at PRs that do not pass the CI. Seems like this one needs to exclude example from coverage testing, or just drop the example from the dir.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for the new gpt-image-1 model by introducing additional constants, optional request/response fields, and an updated documentation example for image generation.

  • Added new constants for image sizes, quality levels, background options, moderation levels, and output formats for gpt-image-1.
  • Updated the ImageRequest and ImageResponse structs to include additional optional fields.
  • Revised the examples and README to demonstrate usage of gpt-image-1.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
image.go Added new constants and updated API structs to support gpt-image-1.
examples/images/main.go Modified example to call the gpt-image-1 model with updated parameters.
README.md Updated documentation and code snippet to include GPT Image 1 support.

@sashabaranov
Copy link
Owner

@PChaparro thank you for a fast follow-up! Could you please also add README example as an integration test, so it would be easier to verify these new features?

@PChaparro
Copy link
Author

@PChaparro thank you for a fast follow-up! Could you please also add README example as an integration test, so it would be easier to verify these new features?

Hi @sashabaranov! Thanks for the suggestion.

There’s already an example for image generation using gpt-image-1 in the README, under the "Other examples" section.

Please let me know if you were referring to something different!

@sashabaranov
Copy link
Owner

@PChaparro sounds good! Please note there are a couple of suggested changes from Copilot above that seem legit

@PChaparro
Copy link
Author

@PChaparro sounds good! Please note there are a couple of suggested changes from Copilot above that seem legit

Thanks, @sashabaranov!

I reviewed both Copilot suggestions — one of them was valid and has already been implemented. The other one seemed to be a misunderstanding, so I left it as is.

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.

3 participants