-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. 🚀 New features to boost your workflow:
|
Please expedite the merging of this pull request; it is urgently needed. |
@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. |
There was a problem hiding this 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. |
@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 Please let me know if you were referring to something different! |
@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. |
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
https://platform.openai.com/docs/guides/image-generation?image-generation-model=gpt-image-1
https://platform.openai.com/docs/api-reference/images
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 thegpt-image-1
model and the new parameters. The request completed successfully, and the image was generated as expected.