Generate an image
generate_imageGenerate images from text prompts, save them to disk, and receive file paths with inline previews for review.
Instructions
Generate one or more images from a text prompt using OpenAI's GPT Image models, save them to disk, and return the file paths plus an inline preview.
Prompt style: these models follow long, specific prose well. Describe subject, composition, lighting, medium/style, colour palette and mood. Any text that should appear inside the image must be given verbatim in quotes.
Cost control: use quality "low" (or gpt-image-1-mini) while iterating on composition, then re-render the winner at quality "high".
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | How many variations to generate. dall-e-3 supports only 1. | |
| size | No | Image dimensions as "WIDTHxHEIGHT", or "auto". Common: 1024x1024 (square), 1536x1024 (landscape), 1024x1536 (portrait). gpt-image-2 also accepts larger sizes such as 2048x2048 and 3840x2160 (edges must be multiples of 16, aspect ratio under 3:1). | |
| model | No | Image model id. Omit or pass "auto" to use the best available model (tries gpt-image-2, then falls back if this API key lacks access). Pass an explicit id to control cost/quality: gpt-image-2, gpt-image-1.5, gpt-image-1, gpt-image-1-mini, dall-e-3. Any newer model id is also accepted and passed through unchanged. | |
| style | No | dall-e-3 only. Ignored by gpt-image models. | |
| prompt | Yes | What to draw. Be specific and descriptive; long prompts work well. | |
| quality | No | Render quality. "low" is fast and cheap for drafts, "high" is for final output. Defaults to the model default ("auto"). | |
| filename | No | Base filename without extension. Defaults to a timestamp plus a slug of the prompt. With n > 1 an index is appended. | |
| background | No | Use "transparent" for logos, icons, stickers and cut-outs. Requires output_format png or webp. Not supported by dall-e-3. | |
| moderation | No | Content-filter strictness for gpt-image models. Defaults to "auto". | |
| output_dir | No | Directory to write the images into. Pass an absolute path (e.g. the current project's assets folder) when the images belong to a project. Defaults to /root/Pictures/claude-images. | |
| output_format | No | File format. png (default) for graphics/transparency, jpeg/webp for photos. | |
| return_preview | No | Return a downscaled copy of each image inline so you can actually look at the result and iterate. Set false to save tokens when the image is not going to be reviewed. | |
| output_compression | No | Compression level 0-100 for jpeg/webp output. |