Generate image
generate_imageGenerate images from text prompts using OpenAI image models, saving them to disk as file paths or returning inline base64 data to control payload size.
Instructions
Generate an image from a text prompt using an OpenAI image model. By default returns the local file path(s) the image was saved to rather than inline image data; set returnAs to 'base64' for inline data instead
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | Number of images to generate (1-10; dall-e-3 only supports 1) | |
| size | No | Image dimensions. Depends on the model: GPT image models accept 1024x1024, 1536x1024, 1024x1536, or auto; dall-e-2 accepts 256x256, 512x512, or 1024x1024; dall-e-3 accepts 1024x1024, 1792x1024, or 1024x1792 | |
| model | Yes | OpenAI model to use for image generation | |
| prompt | Yes | Description of the image to generate | |
| returnAs | No | How to return generated images. 'path' (default) saves each image to disk and returns its file path, avoiding the large inline payloads that can exceed an MCP client's tool result size limit. 'base64' returns the image data inline instead, which is more likely to hit that limit for anything but small images | path |
| outputPath | No | File path to save the image to when returnAs is 'path'. Ignored when returnAs is 'base64'. If n > 1, a 1-based index is inserted before the file extension for each image. Defaults to a temp file if omitted |