grok_image_edit
Edit specific regions of a Grok Image 2.0 generation by providing a task_id, an edit prompt, and mask indices from grok_segment_map. Preserves unselected areas and returns a new image for further iterative refinement.
Instructions
Edit ONLY selected regions of a Grok Imagine Image 2.0 generation (4 credits). Pass the source task_id, an edit prompt describing the desired end state of the masked region(s), and mask_indexs — the region indices from grok_segment_map (run it first, free, and pick regions by NAME; do not guess indices). Everything outside the masks is preserved. Returns a new full image; the result task_id can itself be segmented/edited again for iterative refinement at 4 cr per round. Downloads to kie/assets/raw/.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | What the masked region(s) should become, plus what to preserve (e.g. "change the background to a sunset beach, keep the apple unchanged") | |
| task_id | Yes | Source task ID — a Grok Image 2.0 generation (or a previous grok_image_edit result) | |
| filename | No | Output filename. Auto-generated if omitted. | |
| mask_indexs | Yes | Region indices to edit, from grok_segment_map (e.g. [1] or [0, 2]). Field name matches kie's API spelling. | |
| download_dir | No | Absolute directory to save the file(s) into (created if missing). Defaults to the server's kie/assets/raw/. Must be absolute — the MCP server's working directory is not the caller's. |