Grok Imagine Edit 1-5 Images (xAI)
Five Reference Images and One Sentence
- image_1
- image_2
- image_3
- image_4
- image_5
- image
- prompt
- info
Why you'd reach for it
Instruction editing is where the ecosystem went in 2026 - instead of scaffolding a character together out of IP-Adapter, PuLID and ControlNet, you hand a model pictures plus a sentence and it does the compositing. This node is that move against xAI's API: up to five source images, one prompt, and you get back a single edited result as a plain IMAGE batch.
The "five" is the reason to pick it over the pile of two-image editing nodes. Person from image 1, garment from image 2, background from image 3, in one request, referenced in the prompt by number. On grok-imagine-image-2.0 that's the supported count; the older models cap at three.
It's also the cheapest form of consistency there is. The author's own tooltip notes that image-2.0 preserves identity, style and layout across repeated edits, which means you can chain Edit nodes for step-by-step work - fix the pose, then the lighting, then the detail - instead of trying to describe the whole final image and hoping. That chained-editing habit is the one thing from the local side of the ecosystem that transfers straight over here.
What's on the node
image_1 is required and it anchors everything: the result keeps its aspect ratio unless you tell it otherwise, and you refer to it in the prompt as "image 1". image_2 through image_5 are optional and stack the same way. Each connected source is billed $0.01 as an input, on top of the output image - so a five-source 2k/medium edit is real money, and the console tells you the estimate before the request goes out.
The prompt is where the work happens. Be concrete and name the sources: "the woman from image 1 wearing the dress from image 2, standing, full body". Say what to keep - "preserve her face and hair" - say what to remove, and add camera or lens language only if it matters. Vague prompts are how you pay twice.
Then the three dials, and they do not overlap:
aspect_ratiodefaults tosource, which means the parameter isn't sent at all and image 1's ratio survives. Pick any explicit ratio and the result is re-framed - the model fills the new frame rather than stretching your image into it. That's usually what you want for a crop-to-vertical edit, and rarely what you want by accident.resolutionis size:source(not sent, currently 1k),1k(~1 MP) or2k(~4 MP, +$0.02).qualityis the detail tier and defaults tomediumhere - the deliberate opposite of the Generate node, because edits are exactly the job that benefits from more compute per image (skin, fabric, small text).auto,lowanddefaultare there if you want them.
n (1–10) gets you several variants of the same edit and multiplies the bill. upload_format and upload_max_side (512–4096) control what actually gets uploaded: PNG is lossless, and the side limit downscales big sources before they go over the wire - worth lowering on a slow connection, worth raising when the whole point of the edit is fine texture.
Outputs
image is the edited batch - feed it back into image_1 of another Edit node for a second pass, or into Grok Image Save to get name_000000.png in a folder you picked. prompt is the passthrough text, so connect it to a save node's prompt_text and your sidecar .txt writes itself. info gives you the truth of the run: model used, real pixel size, how many sources were billed, moderation flag, and estimated vs. actual cost.
Install
ComfyUI Manager, search Grok Imagine, or:
cd ComfyUI/custom_nodes
git clone https://github.com/Slartibart23/comfyui-grok-imagine-video
..\..\python_embeded\python.exe -m pip install -r comfyui-grok-imagine-video\requirements.txt
Restart, then Ctrl+F5 once. The key comes from the api_key widget, XAI_API_KEY, or grok_api_key.txt in the ComfyUI root / portable root / pack folder - in that order. The same file is shared with the author's comfyui-grok-prompt-forge pack, so you only set it up once.
Where people get burned
The bill. Five inputs plus n: 4 at 2k/medium is not a rounding error, and the estimate prints in the console before dispatch - read it. Moderation is the second one: an edit that comes back subtly wrong is often an edit the API filtered, and info carries the respect_moderation flag, while fail_on_moderation will stop the queue instead of handing you the filtered image. Third: connecting sources you never reference in the prompt. The model isn't psychic about which of your five pictures was supposed to matter, and you paid $0.01 for it anyway.
Inputs (20)
| Name | Type | Default | Description |
|---|---|---|---|
| image_1 | IMAGE | Main source image (required). The result keeps its aspect ratio unless aspect_ratio overrides it. Refer to it as 'image 1' in the prompt. Billed $0.01 as input. | |
| prompt | STRING | What to change. Be concrete and name the sources: 'the woman from image 1 wearing the dress from image 2, standing, full body'. Say what to keep ('preserve her face and hair'), what to remove, and the camera/lens if it matters. image-2.0 preserves identity, style and layout across repeated edits - chain Edit nodes for step-by-step work. | |
| model | COMBO | grok-imagine-image-2.0 | Image model used for editing. grok-imagine-image-2.0 recommended (#2 on the Arena image-edit board, up to 5 sources). Older models accept 3 sources at most. |
| aspect_ratio | COMBO | source | 'source' = keep the ratio of image_1 (parameter not sent). Any other value re-frames the result; the model fills the new frame instead of stretching. Pixel size = ratio x resolution. |
| resolution | COMBO | source | IMAGE SIZE of the result. source = parameter not sent (API default, currently 1k). 1k = about 1 megapixel, 2k = about 4 megapixels (+$0.02 per image). Independent of quality. The real pixel size is shown on 'info'. |
| quality | COMBO | medium | DETAIL / COMPUTE TIER, NOT image size (see resolution). image-2.0 only. low: fastest, cheapest. medium: more compute per image - finer detail in skin, fabric, small text; recommended for edits and final renders. auto: the API decides (currently low for generation, medium for editing) and bills what it served. default: parameter not sent (= auto). Prices per image: 1k/low $0.04, 2k/low $0.06, 1k/medium $0.06, 2k/medium $0.08. Older models ignore this - keep 'default' there. |
| seed | INT | 00–18446744073709550000 | Cache-breaker only (not sent). randomize = new request each run. |
| image_2opt | IMAGE | Source image #2 (optional). Refer to it in the prompt as 'image 2' / 'the second image'. Each connected image is billed $0.01 as input. Up to 5 in total; combine e.g. a person + a garment + a background. | |
| image_3opt | IMAGE | Source image #3 (optional). Refer to it in the prompt as 'image 3' / 'the third image'. Each connected image is billed $0.01 as input. Up to 5 in total; combine e.g. a person + a garment + a background. | |
| image_4opt | IMAGE | Source image #4 (optional). Refer to it in the prompt as 'image 4' / 'the fourth image'. Each connected image is billed $0.01 as input. Up to 5 in total; combine e.g. a person + a garment + a background. | |
| image_5opt | IMAGE | Source image #5 (optional). Refer to it in the prompt as 'image 5' / 'the fifth image'. Each connected image is billed $0.01 as input. Up to 5 in total; combine e.g. a person + a garment + a background. | |
| nopt | INT | 11–10 | How many images to generate in one request (1-10). Every image is billed; the console prints the estimated total before the request. |
| upload_formatopt | COMBO | png | How source images are encoded for upload. png = lossless (best for preserving identity, text and fine detail). jpg = smaller/faster upload at quality 95, tiny loss. |
| upload_max_sideopt | INT | 2048512–4096 | Source images are downscaled so their longer side is at most this many pixels before upload. 2048 keeps full 2k detail; 4096 sends originals up to 4k (slower upload, API limit 20 MiB per image). |
| fail_on_moderationopt | BOOLEAN | false | If the API flags a result as not passing content moderation (respect_moderation=false), stop the queue with an error instead of silently passing the filtered image on. The request is billed either way; 'info' always shows the flag. |
| custom_modelopt | STRING | Type any model ID here to override the dropdown (e.g. a brand-new release). Leave empty to use the dropdown. See console.x.ai or GET /v1/models for valid IDs. | |
| api_keyopt | STRING | Your xAI API key. NOT recommended here — it is saved inside exported workflows. Prefer the XAI_API_KEY environment variable or the key file. | |
| api_key_fileopt | STRING | grok_api_key.txt | Text file containing only the key. Searched in the ComfyUI root, the portable root and this pack's folder (or give an absolute path). The same file serves the Prompt Forge pack. |
| base_urlopt | STRING | https://api.x.ai/v1 | API base URL. Leave at https://api.x.ai/v1 unless you use a proxy. |
| timeout_secondsopt | INT | 30030–1200 | Seconds to wait for one HTTP response before giving up. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | The edited result(s) as an IMAGE batch (n images). Feed it back into image_1 of another Edit node for multi-turn refinement. |
| prompt | STRING | The editing prompt exactly as sent, for Save nodes or captions. |
| info | STRING | Facts about this request: model used, true pixel size, number of source images, requested resolution/quality, moderation flag, estimated and real billed cost in USD. |