image_generate
Create images from prompts or edit local images via the Gemini API, saving results to a directory. Refine earlier outputs step by step with previous_id instead of starting over.
Instructions
Create a new image from a prompt, or edit local images, with Nano Banana through the Gemini API, and save the result in GEMINI_PRO_OUTPUT_DIR. Pass previous_id to refine an earlier result step by step ("make the sky darker") without starting over.
COSTS MONEY: about $0.034 (1K), $0.05 (2K) or $0.11 (4K) per image with Nano Banana 2.1; Nano Banana Pro ("gemini-3-pro-image") is $0.13-0.24. No free tier. Confirm with the user before calling.
Args: prompt: What to draw, or how to change the input images, e.g. "Turn this sketch into a clean flat app icon on a white background". model: "gemini-nano-banana-2.1" (default), "gemini-3.1-flash-lite-image" (cheapest, 1K only) or "gemini-3-pro-image" (best, for hard tasks). aspect_ratio: "1:1" (default), "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9" or "21:9". image_size: "1K" (default), "2K" or "4K". input_images: Local image paths to edit or to use as references. previous_id: The id of an earlier image_generate result to refine. file_name: Optional file name; default is the date plus prompt words.
Returns: The saved image path and an id to pass as previous_id for further edits.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | No | gemini-nano-banana-2.1 | |
| prompt | Yes | ||
| file_name | No | ||
| image_size | No | 1K | |
| previous_id | No | ||
| aspect_ratio | No | 1:1 | |
| input_images | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |