Repository navigation
feat(image): accept reference images in the Image Generator - #10755
Open
myxamediyar wants to merge 2 commits into
Open
myxamediyar wants to merge 2 commits into
myxamediyar wants to merge 2 commits into
Conversation
The Image Generator now takes optional reference images for models whose provider API accepts them: OpenAI sends them to image edits, Gemini as inline parts after the prompt, and 88 fal models to their image-input sibling endpoint, now recorded in the fal image catalog. Higgsfield models take none. Each reference passes the start frame's file access, model-safe and provenance checks, and is read under a 14 MB total with its type taken from its bytes. The block's settings follow the endpoint the run calls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
myxamediyar
marked this pull request as ready for review
December 4, 2026 01:02
Contributor
There was a problem hiding this comment.
1 issue found across 14 files
Confidence score: 3/5
apps/sim/lib/internal/image/schema.tsrejects file IDs and URLs inreferenceImages, so advanced-mode requests can fail with a 400 before reference resolution runs. Accept string references in the schema.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/lib/internal/image/schema.ts">
<violation number="1" location="apps/sim/lib/internal/image/schema.ts:45">
P1: This schema rejects non-file references. `referenceImages` is `z.array(userFileSchema)`, but advanced mode passes file IDs or URLs as strings, so `executeImageTool` returns 400 before resolution can run. Accept string references here, or confirm where they are resolved before this parse.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
Comment on lines
+45
to
+47
| referenceImages: z | ||
| .array(userFileSchema) | ||
| .max(MAX_REFERENCE_IMAGES, `Attach at most ${MAX_REFERENCE_IMAGES} reference images`) |
Contributor
There was a problem hiding this comment.
P1: This schema rejects non-file references. referenceImages is z.array(userFileSchema), but advanced mode passes file IDs or URLs as strings, so executeImageTool returns 400 before resolution can run. Accept string references here, or confirm where they are resolved before this parse.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At apps/sim/lib/internal/image/schema.ts, line 45:
<comment>This schema rejects non-file references. `referenceImages` is `z.array(userFileSchema)`, but advanced mode passes file IDs or URLs as strings, so `executeImageTool` returns 400 before resolution can run. Accept string references here, or confirm where they are resolved before this parse.</comment>
<file context>
@@ -40,6 +42,10 @@ export const imageGenerationInputSchema = z
enableSafetyChecker: booleanInputSchema.optional(),
enableWebSearch: booleanInputSchema.optional(),
thinkingLevel: z.string().optional(),
+ referenceImages: z
+ .array(userFileSchema)
+ .max(MAX_REFERENCE_IMAGES, `Attach at most ${MAX_REFERENCE_IMAGES} reference images`)
</file context>
Suggested change
| referenceImages: z | |
| .array(userFileSchema) | |
| .max(MAX_REFERENCE_IMAGES, `Attach at most ${MAX_REFERENCE_IMAGES} reference images`) | |
| referenceImages: z | |
| .array(z.union([userFileSchema, z.string().trim().min(1)])) | |
| .max(MAX_REFERENCE_IMAGES, `Attach at most ${MAX_REFERENCE_IMAGES} reference images`) |
…or-reference-images # Conflicts: # apps/sim/tools/generated/tool-metadata.ts
This branch was successfully deployed
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
The Image Generator block took a text prompt only. It now also takes reference images, for models whose provider API accepts them.
undefined, so it can't reach the tool through the executor's merge with the raw inputs. A value left over from the other endpoint is dropped too, such as a size ofautothat only FLUX.2 [pro] edits take./v1/images/editsasimages: [{ image_url: <data URL> }], up to 16, with the same settings as generation. The JSON edits schema takesmoderationand thegpt-image-2sizes.inlineDataparts after the prompt: up to 14 on Nano Banana 2.1, Nano Banana Pro and Nano Banana 2, and 3 on Nano Banana and Nano Banana 2 Lite.imageinfal-image-models.json(/edit,/image-to-image,/remixor/redux). Each entry records the endpoint, the image field, the most images it takes, and that endpoint's own settings. An endpoint with an image to edit plus a separate reference list (Ideogram 4.5 edit, Luma Uni-1 edit) gets the first image as the one to edit and the rest as references.image_reference_urlonly guides prompt enhancement and takes a public URL, so the field stays hidden.image_generatetakes an optionalreferenceImages(file[]). Tool metadata is regenerated.validate-fal-image-models.tsalso checks every image-input variant, with one image and with its maximum, against fal's published schema.Type of Change
Testing
validate-fal-image-models.tsagainst fal's live schemas: all 140 runs with reference images pass across the 88 variants. The 21 failing runs are existing prompt-only endpoints whose schemas fal no longer publishes (404), unrelated to this change.request.test.tscases: the rejections above, and the OpenAI edits and Gemini inline-part request shapes, which no schema check covers.operations.test.tscases: a file the caller cannot read, a file not cleared to reach a model, non-image bytes, references over 14 MB, and invalid provenance are each refused without calling the provider. A readable reference reaches OpenAI with the type read from its bytes.field-analysis.test.tscases, through the serializer and the executor's params merge:bun run generate,lint,type-check,check:audits,test, andcheck-block-registry.ts origin/stagingall pass.Before merge: run one real generation with reference images per provider. fal documents no maximum queue request size, and references reach it as data URIs, the same way the Video block's start frame does. If fal rejects bodies near the 14 MB cap, references should go to fal storage instead.
Reviewers: please check the reference field's visibility and the settings dropdowns when you switch models or toggle basic/advanced mode with a reference attached.
Known gaps, left for follow-ups:
modelvalue for LLM attachments. The server still rejects more than 14 MB in total, and the field's placeholder states the total.Checklist
🤖 Generated with Claude Code