generate_image
Generate images from text prompts, save them to the generated-assets directory, and return previews. Use for new images without a reference; for edits, use edit_image.
Instructions
Generate one or more brand-new images from a text prompt using OpenAI's image model, save them as files in the project's generated-assets directory, and return a small preview of each. Use this when no existing image needs to guide the result. If you need the new image to match the look of images you already have (a brand board, an earlier asset, a photo to modify), use edit_image instead and pass those files as references. Write prompts as a full description: subject, style, composition, lighting, colour palette, and any text that must appear. SIZE: pass a preset name or explicit WIDTHxHEIGHT. Presets: 'square' (1024x1024), 'landscape' (1536x1024), 'portrait' (1024x1536), 'hero' (1920x1088), 'banner' (1536x512), 'auto' (model picks). Explicit sizes are rounded to the nearest multiple of 16 (minimum 256); the aspect ratio must be between 1:3 and 3:1 and neither side may exceed 3840. The result text reports the size actually produced, so check it if the exact pixel size matters. BACKGROUND: 'transparent' produces an alpha channel and requires output_format 'png' or 'webp' (never 'jpeg'); use it for logos, icons and cut-out illustrations. QUALITY: 'low' is fast and cheap (good for drafts and iteration), 'high' is slow (can take over a minute) and detailed; 'auto' lets the model choose. RETURNS: for each image, a text block with the absolute file path, final width x height, model, quality and the path of a .json sidecar holding the prompt and settings, followed by a small JPEG preview (longest side 512px) so you can inspect the result. The full-resolution file is already on disk; reference it by the returned path (for example as a site asset).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | How many variations to generate (1-4). | |
| size | No | Preset name (square, landscape, portrait, hero, banner, auto) or WIDTHxHEIGHT. | square |
| prompt | Yes | Full description of the image to create. | |
| quality | No | auto, low (fast draft), medium, or high (slow, detailed). | auto |
| filename | No | Optional file name without extension. Defaults to a slug of the prompt plus a timestamp. Never overwrites: a taken name gets -2, -3, ... | |
| background | No | auto, opaque, or transparent (transparent requires png or webp). | auto |
| output_format | No | File format: png, jpeg, or webp. | png |