Skip to content

feat(image-gen): support reference images in image_generate - #21854

Closed
NekoPii wants to merge 1 commit into
NousResearch:mainfrom
NekoPii:feat/image-generate-input-images
Closed

feat(image-gen): support reference images in image_generate#21854
NekoPii wants to merge 1 commit into
NousResearch:mainfrom
NekoPii:feat/image-generate-input-images

Conversation

@NekoPii

@NekoPii NekoPii commented May 8, 2026

Copy link
Copy Markdown

Summary

  • Expose optional input_images and background parameters on the image_generate tool.
  • Pass reference-image inputs through to image generation providers.
  • Add openai-codex provider support for local paths, HTTP(S) URLs, and data:image/... URLs as input_image items for Codex image generation.
  • Document optional provider kwargs and add focused tests.

Test Plan

  • uv run pytest tests/tools/test_image_generation.py tests/tools/test_image_generation_plugin_dispatch.py tests/tools/test_image_generation_input_images.py -q -o addopts=''

Expose optional input_images/background parameters on the image_generate tool and pass them through to image generation providers. Teach the openai-codex image provider to attach local paths, HTTP(S) URLs, and data URLs as input_image items for Codex image generation. Add focused tests and update provider docs.
Copilot AI review requested due to automatic review settings May 8, 2026 12:15

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 extends the image_generate tool and image-gen provider interface to support optional reference images (input_images) and an output background preference (background), and wires these through to plugin-based backends (notably openai-codex) with accompanying documentation and tests.

Changes:

  • Exposed input_images and background in the image_generate tool schema and dispatch path, with explicit errors for the legacy in-tree FAL backend.
  • Added openai-codex provider support for local paths, HTTP(S) URLs, and data:image/... URLs as reference input_image items.
  • Updated provider documentation/ABC guidance and added focused tests for schema + forwarding + Codex request construction.

Reviewed changes

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

Show a summary per file
File Description
website/docs/developer-guide/image-gen-provider-plugin.md Documents optional provider kwargs (input_images, background) and reference-image behavior expectations.
tools/image_generation_tool.py Adds new tool parameters + schema fields and forwards them to plugin providers; legacy FAL path now errors on unsupported params.
tests/tools/test_image_generation.py Updates schema expectations to include new agent-facing parameters.
tests/tools/test_image_generation_input_images.py Adds tests for schema exposure, plugin forwarding, and Codex input-image/background wiring.
plugins/image_gen/openai-codex/init.py Implements reference-image normalization + local/data/remote handling and sends background preference to Codex Responses API.
agent/image_gen_provider.py Updates provider ABC docstring to describe current optional kwargs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 618 to 625
def image_generate_tool(
prompt: str,
aspect_ratio: str = DEFAULT_ASPECT_RATIO,
input_images: Optional[list[str]] = None,
background: Optional[str] = None,
num_inference_steps: Optional[int] = None,
guidance_scale: Optional[float] = None,
num_images: Optional[int] = None,
Comment on lines 389 to 415
@@ -324,6 +408,8 @@ def generate(
prompt=prompt,
size=size,
quality=meta["quality"],
input_images=input_images,
background=background,
)
except Exception as exc:
logger.debug("Codex image generation failed", exc_info=True)
@alt-glitch alt-glitch added type/feature New feature or request comp/plugins Plugin system and bundled plugins tool/vision Vision analysis and image generation P3 Low — cosmetic, nice to have labels May 11, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Overlaps significantly with #18805 (forward reference images to providers) and #15308 (multi-reference input support). Same feature — please coordinate.

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Closing as a duplicate — Codex OAuth image-to-image / reference-image input is now on main via #57017 (merge commit 019950560).

That PR wires source/reference images through the Codex Responses input_image path on the unified image_generate surface, with magic-byte validation, a 25MB cap, the agent.file_safety read guard, and a 16-image clamp. Your PR tackled the same feature — thank you for the contribution and for helping surface how much demand there was for this. Credit to everyone in the cluster who pushed on it.

If you spot a gap in the merged implementation, please open a follow-up. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have tool/vision Vision analysis and image generation type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants