Edit image
edit_imageEdit or extend local images with OpenAI's Images API using a text prompt and optional mask or markup, then save outputs to disk and return file paths and metadata.
Instructions
Edit or extend one or more local images with the OpenAI Images API (POST /v1/images/edits), optionally using a mask or markup, then save the results to local disk and return absolute file paths plus metadata. Source images must be local absolute paths (PNG, JPEG or WebP, under 50 MB each, up to 16). Requires OPENAI_API_KEY. Image bytes are never returned.
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": {
"image": "<image>",
"prompt": "<prompt>"
},
"name": "edit_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 author model and reasoning effort for output_format=svg. SVG output requires n=1 and cannot use streaming, partial images, or output compression. | |
| mask | No | Local absolute path to a PNG mask under 4 MB. Fully transparent areas (alpha zero) indicate where the first image should be edited. Must have the same dimensions as the first image. Cannot be combined with markup. | |
| 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. | |
| image | Yes | The image(s) to edit: one absolute local path, or an array of up to 16 absolute local paths. Each image must be PNG, JPEG or WebP and under 50 MB. | |
| 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. | |
| markup | No | Local absolute path to a transparent PNG overlaid on the first image to guide the edit. Must match the image's dimensions and contain transparent pixels. Cannot be combined with mask. Supported by GPT Image 2.5 and later. | |
| 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. | |
| 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. | |
| input_fidelity | No | How much effort the model spends matching the style and features, especially faces, of input images. Supported on gpt-image-1.5; omit for gpt-image-2. Defaults to low on supported models. | |
| 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 |