Generate an image with OpenAI
openai_generate_imageGenerate images from text prompts and save them to disk. Specify size, quality, background, and format to get files saved locally with paths returned.
Instructions
Create one or more images from a text prompt and write them to disk.
Images are never returned inline — the tool saves each file and reports its absolute path, so the agent's context stays small.
Args:
prompt (string, required): what the image should show
model (string): image model ID, defaults to OPENAI_DEFAULT_IMAGE_MODEL
n (number): 1-4 images (default 1)
size ('auto'|'1024x1024'|'1536x1024'|'1024x1536'|'512x512'|'256x256'): default 'auto'
quality ('auto'|'low'|'medium'|'high'): default 'auto'
background ('auto'|'transparent'|'opaque'): default 'auto'; 'transparent' needs png or webp
output_format ('png'|'jpeg'|'webp'): default 'png'
output_dir (string): absolute target directory, defaults to OPENAI_MCP_OUTPUT_DIR
response_format ('markdown'|'json'): default 'markdown'
Returns (JSON format): { "model": string, "count": number, "images": [ { "index": number, "path": string, "bytes": number } ], "revised_prompt": string | null // prompt rewrite the model applied, when reported }
Examples:
Use when: "Draw a logo of a blue fox" -> prompt="minimalist blue fox logo, flat vector"
Use when: you need a transparent sticker -> background="transparent", output_format="png"
Don't use when: you want to modify an existing picture (use openai_edit_image)
Error Handling:
"Error: Access to ... is not permitted" means output_dir is outside OPENAI_MCP_ALLOWED_DIRS
"Error: OpenAI rejected the request as invalid" often means size or quality is unsupported by that model
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | How many images to generate | |
| size | No | Output resolution | auto |
| model | No | Image model ID. Defaults to OPENAI_DEFAULT_IMAGE_MODEL. | |
| prompt | Yes | Description of the image to create | |
| quality | No | Rendering quality; higher costs more and takes longer | auto |
| background | No | Background handling; "transparent" requires png or webp output | auto |
| output_dir | No | Absolute directory to write the images into. Defaults to OPENAI_MCP_OUTPUT_DIR. Must be inside an allowed directory. | |
| output_format | No | File format of the generated image | png |
| response_format | No | Output format: 'markdown' or 'json' | markdown |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| count | Yes | ||
| model | Yes | ||
| images | Yes | ||
| revised_prompt | Yes |