Generate image
generate_imageCreate one or more AI images from a text prompt, save them to local disk, and return absolute file paths with metadata for use in downstream workflows.
Instructions
Generate one or more images with the OpenAI Images API (POST /v1/images/generations), save them to local disk, and return absolute file paths plus metadata. Image bytes are never returned. Requires OPENAI_API_KEY. The model defaults to IMG_MODEL (gpt-image-2.6-sunburst); set OPENAI_BASE_URL for OpenAI-compatible gateways.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"prompt": "<prompt>"
},
"name": "generate_image"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | The number of images to generate. Must be between 1 and 10. | |
| svg | No | Selects the model and reasoning effort used to author SVG output. Requires output_format=svg. SVG generation requires n=1 and does not support streaming, partial images, prompt rewriting, or output compression. | |
| size | No | The size of the image(s). Standard sizes are 1024x1024, 1536x1024 and 1024x1536; 'auto' lets the model choose. GPT Image 2.x models also accept arbitrary WIDTHxHEIGHT values (both divisible by 16, aspect ratio between 1:3 and 3:1, maximum 3840x2160). Defaults to auto. | |
| user | No | Deprecated: use safety_identifier instead. Kept for backward compatibility and used when safety_identifier is omitted. | |
| model | No | The GPT image model to use, for example gpt-image-2.6-sunburst or gpt-image-2.6-flare. Defaults to IMG_MODEL, or gpt-image-2.6-sunburst. | |
| prompt | Yes | A text description of the desired image(s). The maximum length is 32000 characters. | |
| quality | No | The quality of the image. 'auto' (default) selects the best quality for the model. GPT Image models support low, medium and high; gpt-image-2.5 and later also support xhigh and max. | |
| file_name | No | Optional base file name; path separators are not allowed. The actual image format determines the extension. When multiple outputs are produced, -1, -2, ... suffixes are appended. Existing files are never overwritten. | |
| background | No | Allows to set transparency for the background of the generated image(s). Must be one of transparent, opaque, or auto (default). When using transparent, set the output format to png or webp. | |
| complexity | No | Computation spent planning the image, independently of rendering quality. Uses the model's configured default when omitted. For SVG output, controls the reference image rather than the SVG author's reasoning. | |
| moderation | No | Content-moderation level for images generated by GPT Image models. 'low' applies less restrictive filtering; 'auto' is the default. | |
| output_dir | No | Absolute directory where the output file is saved. Defaults to IMG_OUTPUT_DIR, or ~/img-output. The directory is created automatically. | |
| frame_count | No | Number of frames for GIF output (2-16). Defaults to 9. Only valid with output_format=gif. | |
| output_format | No | The format in which the image(s) are saved. This parameter is only supported for GPT image models. Defaults to png. | |
| frame_duration_ms | No | Delay per GIF frame in milliseconds. Defaults to 200. Only valid with output_format=gif. | |
| safety_identifier | No | A stable identifier for an end user in your organization, used for safety monitoring and abuse detection. Hash a username or email address to avoid sending identifying information. Takes precedence over the deprecated user parameter. | |
| output_compression | No | The compression level (0-100%) for the generated images. Only supported for webp or jpeg output, and defaults to 100. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| size | No | ||
| model | Yes | ||
| usage | No | ||
| images | Yes | ||
| created | Yes | Unix timestamp (in seconds) when the image was created. | |
| quality | No | ||
| svg_usage | No | ||
| background | No | ||
| output_format | No |