Skip to content

Support multi-image edits for gpt-image-2 - #115

Merged
adambalogh merged 1 commit into
mainfrom
claude/image-studio-multi-image-vukxqf
Jul 1, 2026
Merged

adambalogh merged 1 commit into
mainfrom
claude/image-studio-multi-image-vukxqf

Conversation

@adambalogh

Copy link
Copy Markdown
Contributor

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/edits endpoint that takes reference images as multipart file uploads rather than a JSON image field.

What changed

  • model_registry.py — Added ModelConfig.image_edit_endpoint. Reference delivery is now a single per-model choice:
    • unset → references ride inline in the JSON image field of /images/generations (ByteDance Seedream/Seedance, unchanged);
    • set (a path) → references are uploaded as repeated multipart image[] files to that endpoint.
    • gpt-image-2 now sets image_supports_reference=True + image_edit_endpoint="/images/edits".
  • image_generation.py — generate_images picks the delivery path from config. Text-to-image (no references) still uses /images/generations exactly as before. Only inline data: 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.
  • Tests — added coverage for the multipart upload shape, the no-reference generations path, and the non-inline fallback. All 30 image tests pass; make lint clean.

Notes

  • Multi-image support is now: gpt-image-2 ✅, ByteDance Seedream/Seedance ✅. xAI grok-2-image and Z.ai glm-image do not support reference images and are unaffected.
  • Pairs with the chat-app change that forwards all attached images and tells the Studio agent which models can composite.

🤖 Generated with Claude Code

https://claude.ai/code/session_01224b8BAcBisBUCX2EzrbG8


Generated by Claude Code

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 ModelConfig with image_edit_endpoint and enabled reference-image support for gpt-image-2 via /images/edits.
  • Updated generate_images to choose between JSON inline references vs multipart image[] 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.

@adambalogh
adambalogh merged commit d011dce into main Jul 1, 2026
9 checks passed
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