grok_image_edit
Edit images by prompt in two modes: change only named regions from a prior generation, or apply whole-image instructions to any uploaded image. Returns new image; task IDs chain for refinement.
Instructions
Edit an image with Grok Imagine Image 2.0 (4 credits). TWO MODES: (1) Region mode — pass task_id (a prior Grok 2.0 generation) + mask_indexs from grok_segment_map (run it first, free, pick regions by NAME): only those regions change. (2) Whole-image mode (NEW Aug 2026) — pass image_urls (ANY uploaded/external image, e.g. from upload_file) + aspect_ratio + prompt: instruction-based edit of the full image, no segmentation. Returns a new full image; result task_ids chain back into segment/edit for iterative refinement. Downloads to kie/assets/raw/.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | Region mode: what the masked region(s) should become plus what to preserve. Whole-image mode: the edit instruction for the full image. | |
| task_id | No | Region mode: source task ID — a Grok Image 2.0 generation (or a previous grok_image_edit result). Mutually exclusive with image_urls. | |
| filename | No | Output filename. Auto-generated if omitted. | |
| image_urls | No | Whole-image mode: 1-5 public URL(s) of the image(s) to edit — any image, not just Grok generations (upload local files with upload_file first). Mutually exclusive with task_id. | |
| mask_indexs | No | Region mode only: region indices from grok_segment_map (e.g. [1] or [0, 2]). Field name matches kie's API spelling. | |
| aspect_ratio | No | Whole-image mode: required output aspect ratio (auto keeps the input's shape). | |
| 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. |