Generate image (Nano Banana)
generate_imageCreate an image from a text prompt using Google Gemini models, with automatic model selection, aspect ratio and size control, and optional saving to disk.
Instructions
Generate an image from a text prompt using Google's Gemini image models (the Nano Banana family). By default, automatically picks Nano Banana 2 (fast) or Nano Banana Pro (deeper reasoning) based on the prompt's complexity — pass an explicit model to override. Returns the image inline and optionally saves it to disk.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | No | Model id or alias. "auto" (default) smart-selects between Nano Banana 2 and Nano Banana Pro based on prompt complexity. Known aliases: nb2/nano-banana-2 (gemini-3.1-flash-image), pro/nano-banana-pro (gemini-3-pro-image), legacy/nano-banana (gemini-2.5-flash-image, not auto-selected). Any other Gemini image-capable model id is accepted and passed through as-is. | |
| prompt | Yes | Description of the image to generate. Be specific: subject, setting, style, lighting, camera angle, and any exact text that must appear in the image. | |
| image_size | No | "4K" only on Nano Banana 2 / Nano Banana Pro. Defaults to 1K. | |
| output_path | No | File path or directory to save the image to. Relative paths resolve against NANOBANANA_OUTPUT_DIR (or the system temp dir if unset), not the current working directory. | |
| aspect_ratio | No | Aspect ratio of the output image. Defaults to the model's default (usually 1:1) when omitted. | |
| save_to_file | No | Also write the generated image(s) to disk (and make them browsable via the generated-image:// resource). Defaults to true when NANOBANANA_OUTPUT_DIR is set, false otherwise. | |
| thinking_level | No | "high" improves complex prompts at the cost of latency. Only affects Nano Banana 2 (ignored otherwise). | |
| person_generation | No | Controls generation of people in the image. | |
| use_search_grounding | No | Ground the image in real-time Google Search results (e.g. current weather, sports scores, recent events). Not supported on the legacy model. |