Generate Image
generate_imageGenerate images from text prompts or edit existing images using Gemini models. Supports multi-turn editing, custom aspect ratios, and resolutions up to 4K.
Instructions
Generate or edit images using Google Gemini. Provide just a prompt for text-to-image generation. Add image file paths to edit or use reference images (up to 14 on gemini-3-pro). Returns the saved file path, model used, token counts, and estimated cost.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | Text description of the image to generate, or editing instruction when images are provided | |
| images | No | File paths to input/reference images for editing (max 14). Omit for text-to-image generation | |
| model | No | Gemini model ID. Defaults to gemini-2.5-flash-image. Options: gemini-2.5-flash-image, gemini-3-pro-image-preview, gemini-3.1-flash-image-preview | |
| aspectRatio | No | Image aspect ratio. Defaults to config value or 1:1 | |
| resolution | No | Image resolution. Defaults to config value or 1K. 2K/4K only on gemini-3-pro and gemini-3.1-flash. gemini-2.5-flash is 1K only. | |
| outputDir | No | Directory to save the image. Defaults to config file outputDir, OUTPUT_DIR env var, or ~/gemini-images | |
| filename | No | Base name for the saved file (e.g. 'hero-banner'). Extension added automatically. Duplicates get a version suffix (hero-banner-v2). Omit for auto-generated name. | |
| subfolder | No | Subfolder within the output directory (e.g. 'landing-page'). Created automatically. | |
| sessionId | No | Continue a multi-turn editing session. Pass the sessionId from a previous response to refine the image iteratively. The server preserves conversation history. | |
| seed | No | Seed for reproducible generation. Same seed + prompt + model = same image. | |
| useSearchGrounding | No | Enable Google Search grounding for real-world accuracy. Available on gemini-3.1-flash-image-preview. |