Repository navigation
Add OpenAI gpt-image-2 image generation support - #114
Merged
Merged
Conversation
Expose OpenAI's gpt-image-2 model through the endpoint-based image generation flow so it can be surfaced in the image studio. - Register GPT_IMAGE_2 in model_registry with image_generation=True and a flat per-image price. gpt-image models always return base64 and reject the response_format field, so it's omitted; size/quality are pinned for predictable billing. Image-to-image editing uses a separate OpenAI endpoint, so reference images aren't forwarded (text-to-image only). - Map the "openai" provider to the existing openai_http_client in image_generation, reusing the chat client (base URL ends in /v1, so the request lands on OpenAI's /v1/images/generations). - Add tests for the OpenAI payload shape and per-image billing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Soor3BDk2mqheoiWFssi9N
adambalogh
marked this pull request as ready for review
June 30, 2026 15:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for OpenAI's
gpt-image-2model for image generation via the/images/generationsendpoint, alongside existing providers (xAI, ByteDance, Z.ai).Changes
model_registry.py: Register
GPT_IMAGE_2model config with:1024x1024) and quality (medium) for predictable billingresponse_formatomitted (gpt-image always returns base64)/v1)image_generation.py:
"openai": "openai_http_client"to_IMAGE_CLIENT_ATTRSmappingtest_image_generation.py:
GPT_IMAGE = "gpt-image-2"constanttest_openai_gpt_image_omits_response_format_and_pins_size_quality()test verifying:response_formatfield is omitted from request payloadb64_json) is correctly converted to inlinedata:URIGPT_IMAGEin billing test coverageCLAUDE.md: Update documentation to list
gpt-image-2under OpenAI's supported models and note it uses the/images/generationsendpoint flowImplementation Details
The gpt-image model integrates seamlessly with the existing endpoint-based image generation flow. Unlike DALL·E (which uses the chat path), gpt-image is served through a dedicated
/images/generationsendpoint and always returns base64-encoded images, rejecting theresponse_formatparameter. The implementation pins size and quality to ensure predictable per-image billing costs.https://claude.ai/code/session_01Soor3BDk2mqheoiWFssi9N