Repository navigation
Support multi-image edits for gpt-image-2 - #115
Merged
Merged
Conversation
Route gpt-image-2 reference turns to OpenAI's /images/edits endpoint as multipart image[] file uploads, enabling image-to-image editing and multi-image compositing (e.g. "add this logo to this photo"). ByteDance Seedream/Seedance keep carrying references inline in the JSON image field of /images/generations — the delivery path is a single per-model choice (ModelConfig.image_edit_endpoint). Only inline data: references are uploaded; a plain-URL reference is skipped rather than dereferenced in the enclave (SSRF), and if nothing is uploadable the request falls back to a plain text-to-image generation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01224b8BAcBisBUCX2EzrbG8
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds provider-specific support for image-to-image editing and multi-image compositing for OpenAI gpt-image-2 by routing reference-image requests to a dedicated multipart /images/edits endpoint, while keeping existing /images/generations JSON behavior unchanged for text-to-image and for providers that carry references inline.
Changes:
- Extended
ModelConfigwithimage_edit_endpointand enabled reference-image support forgpt-image-2via/images/edits. - Updated
generate_imagesto choose between JSON inline references vs multipartimage[]uploads based on model config, with safe fallback when references aren’t uploadable. - Added tests covering multipart edit uploads, no-reference generations routing, and non-inline reference fallback behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
tee_gateway/test/test_image_generation.py |
Adds test coverage for multipart /images/edits uploads and fallback/generations routing for gpt-image-2. |
tee_gateway/model_registry.py |
Introduces image_edit_endpoint in ModelConfig and configures gpt-image-2 to support reference edits via /images/edits. |
tee_gateway/image_generation.py |
Implements multipart upload path for edit-capable models and preserves JSON generations behavior otherwise. |
CLAUDE.md |
Updates documentation to reflect the new per-model reference delivery paths (inline JSON vs multipart edits endpoint). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Enables image-to-image editing and multi-image compositing (e.g. "add this logo to this photo") for OpenAI
gpt-image-2, which — unlike ByteDance — does editing on a separate/images/editsendpoint that takes reference images as multipart file uploads rather than a JSONimagefield.What changed
model_registry.py— AddedModelConfig.image_edit_endpoint. Reference delivery is now a single per-model choice:imagefield of/images/generations(ByteDance Seedream/Seedance, unchanged);image[]files to that endpoint.gpt-image-2now setsimage_supports_reference=True+image_edit_endpoint="/images/edits".image_generation.py—generate_imagespicks the delivery path from config. Text-to-image (no references) still uses/images/generationsexactly as before. Only inlinedata:references are uploaded; a plain-URL reference is skipped rather than dereferenced inside the enclave (SSRF), and if nothing is uploadable the request falls back to a plain text-to-image generation instead of failing. Up to 10 references per request.make lintclean.Notes
🤖 Generated with Claude Code
https://claude.ai/code/session_01224b8BAcBisBUCX2EzrbG8
Generated by Claude Code