Generate image
generate_imageGenerate image files from text prompts using Gemini or OpenAI models, save them to disk, and return absolute paths and model metadata.
Instructions
Generate one or more images from a text prompt using Gemini or OpenAI image models and save them to disk. Returns the absolute saved file path(s) plus provider/model metadata. Strongly prefer passing an absolute output_path inside the current project so the file lands where you can use it. Each image costs real API credits.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | Number of images, 1-4 (default 1). Gemini generates sequentially, so n>1 is slower there. | |
| model | No | Override the model. Gemini: gemini-3.1-flash-image (default), gemini-3.1-flash-lite-image, gemini-3-pro-image, gemini-2.5-flash-image. OpenAI: gpt-image-2 (default, best quality), gpt-image-1.5, gpt-image-1, gpt-image-1-mini. IMPORTANT: gpt-image-2 cannot do transparent backgrounds; pass gpt-image-1.5 when background transparent is needed. | |
| prompt | Yes | What to generate. Be specific: subject, style, composition, colors, any text to render. | |
| quality | No | OpenAI only, ignored by Gemini. Use low for cheap drafts. | |
| provider | No | Override the default provider. Call list_capabilities to see what is configured. | |
| background | No | OpenAI only, ignored by Gemini. transparent yields alpha PNG/WebP, ideal for logos and icons. Requires gpt-image-1.5 or older: gpt-image-2 does not support it, so transparent calls on gpt-image-2 auto-switch to gpt-image-1.5 (noted in the result). Prefer passing model gpt-image-1.5 explicitly when you need transparency. | |
| image_size | No | Gemini 3.x models only (ignored by OpenAI; gemini-2.5-flash-image is fixed at 1024px). Default 1K. | |
| output_path | No | Absolute path strongly recommended. Either a full file path (.png/.jpg/.webp) or a directory (a slugified filename is derived from the prompt). If omitted: $IMAGE_GEN_MCP_OUTPUT_DIR, then $CLAUDE_PROJECT_DIR, then the server cwd. The server may be restricted to specific directories; call list_capabilities to see allowedDirs. | |
| aspect_ratio | No | Gemini and OpenAI gpt-image-2 honor the ratio exactly. Older OpenAI models approximate: landscape -> 1536x1024, portrait -> 1024x1536, 1:1 -> 1024x1024. | |
| return_image | No | Default false. When true, also returns the FIRST image as an inline MCP image block so you can see it without a Read. Large images can exceed the MCP output token limit; for 2K/4K prefer Read on the saved path. |