Grok Imagine Image 2.0 Segment Map
The middle node nobody explains
- image
- url
- all_urls_json
- task_id
- raw_json
- credits_consumed
- credits_left
What it is
The least self-explanatory node in the Grok Imagine folder, and the one that makes the segment-edit workflow work. KIE Next / Image / xAI / Grok Imagine. You hand it a previous KIE task ID; it hands back a segment map - the same image with its contents analysed into indexed regions. Then Grok Imagine Image 2.0 Segment Edit takes that task ID plus the indices you picked, and changes only those parts.
If you're used to ComfyUI masking, the shape will feel familiar: this is the "make a mask" step, except you don't paint anything. The model decides the regions, numbers them, and you choose numbers.
The trade is obvious once you say it out loud. A painted mask is exact and free. A segment map is approximate, costs a call, and - crucially - only gives you regions the model already understood as objects. For "change the sky", "swap the shirt", "replace the background", that's plenty. For "retouch this eyelash", you want your local mask workflow instead.
How it works, and why the node looks bare
Note the schema: no required inputs at all. The only real widget is an optional task_id string, plus timeout_seconds, callback_url, and an expert_override_json. That's not an oversight - the pack generates these nodes from KIE's published API documentation, and the segment-map page publishes a request example without a parameter table. So the node gives you the fields the example implies and keeps a raw JSON escape hatch for anything the docs didn't name.
Practically: it submits a task referencing your source task ID, polls until completion, downloads the result and returns it as an IMAGE. As with everything in this pack, no local compute is involved.
Inputs
- task_id - the handle to the image you want mapped. Per KIE's docs for the sibling Segment Edit node, valid sources are a task from
grok-imagine-image-2-0/text-to-image, or a task from this segment-map model when you pass it an image. Both of those are nodes in this same folder, and both emittask_idas an output - wire it straight across. - expert_override_json - merges raw keys into the request. Leave it
{}unless the provider adds a field before the pack's catalog catches up. - timeout_seconds, callback_url - the usual. Default 1200 seconds is fine; leave the callback empty for normal ComfyUI use.
Outputs
image is the segment map - the artefact you want to look at before spending your next call, because it's the only way to know which index is which region. There's no index legend in the response schema, so reading the map visually is the workflow: run this, open the result, note the numbers you care about, feed those into Segment Edit's mask_indexs. url and all_urls_json give the hosted copies; task_id is what Segment Edit actually consumes; raw_json is the provider response; credits_consumed and credits_left show the damage.
A chain that works
- Grok Imagine Image 2.0 Text To Image → gives you a still and a
task_id. - This node → feed it that
task_id, get a numbered segment map. - Grok Imagine Image 2.0 Segment Edit → feed it the map's
task_id(or the original's) plusmask_indexslike[1, 2]and a prompt, get only those regions changed.
Keep the intermediate map saved. If the edit goes somewhere unexpected, the map is how you find out you picked index 3 when you meant 2.
Install
Manager → KIE.ai Nodes Next; manually, clone it into ComfyUI/custom_nodes and install its requirements into ComfyUI's Python (requests, Pillow, numpy, PyYAML - no model downloads):
cd ComfyUI/custom_nodes
git clone https://github.com/felipederosilva/ComfyUI-KIE-Nodes-Next
python -m pip install -r ComfyUI-KIE-Nodes-Next/requirements.txt
Restart, then save your KIE.ai key once in Settings → KIE.ai Nodes Next → Connection. The pack syncs its node library from KIE's live docs on first launch and roughly daily after that; a missing node means the catalog hasn't caught up, not a broken installation.
Gotchas
- Bare schema ≠ no parameters. Everything interesting is implied or in the override. If a call fails with a validation error,
raw_jsonfrom the failing task is your diagnostic. - It's another paid call, and it may feel like a tax. Segment mapping costs a credit for information you'd get free by painting a mask locally.
- Task IDs don't travel. This only accepts KIE-generated tasks - not the task IDs of other services, and not your own local generations.
- No key gives
No KIE API key configured.- Settings, not the graph. - Numbers are per-map, not universal. Any new generation means a fresh map and fresh indices; don't reuse yesterday's
mask_indexsblindly.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| task_idopt | STRING | task_grok_imagine_1765180586443 | — |
| timeout_secondsopt | INT | 120030–7200 | — |
| callback_urlopt | STRING | Optional KIE callback URL. Leave empty for normal ComfyUI use. | |
| expert_override_jsonopt | STRING | {} | Expert-only payload overrides for APIs whose documentation has no request schema yet. |
Outputs (7)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| url | STRING | — |
| all_urls_json | STRING | — |
| task_id | STRING | — |
| raw_json | STRING | — |
| credits_consumed | FLOAT | — |
| credits_left | FLOAT | — |