Skip to main content
Glama

Edit image

edit_image

Edit 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

NameRequiredDescriptionDefault
nNoThe number of images to generate. Must be between 1 and 10.
svgNoSelects the author model and reasoning effort for output_format=svg. SVG output requires n=1 and cannot use streaming, partial images, or output compression.
maskNoLocal 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.
sizeNoThe 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.
userNoDeprecated: use safety_identifier instead. Kept for backward compatibility and used when safety_identifier is omitted.
imageYesThe 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.
modelNoThe 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.
markupNoLocal 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.
promptYesA text description of the desired image(s). The maximum length is 32000 characters.
qualityNoThe 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_nameNoOptional 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.
backgroundNoAllows 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.
complexityNoComputation 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_dirNoAbsolute directory where the output file is saved. Defaults to IMG_OUTPUT_DIR, or ~/img-output. The directory is created automatically.
frame_countNoNumber of frames for GIF output (2-16). Defaults to 9. Only valid with output_format=gif.
output_formatNoThe format in which the image(s) are saved. This parameter is only supported for GPT image models. Defaults to png.
input_fidelityNoHow 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_msNoDelay per GIF frame in milliseconds. Defaults to 200. Only valid with output_format=gif.
safety_identifierNoA 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_compressionNoThe compression level (0-100%) for the generated images. Only supported for webp or jpeg output, and defaults to 100.

Output Schema

NameRequiredDescriptionDefault
sizeNo
modelYes
usageNo
imagesYes
createdYesUnix timestamp (in seconds) when the image was created.
qualityNo
svg_usageNo
backgroundNo
output_formatNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.0.1

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond the annotations (readOnlyHint=false, openWorldHint=true, idempotentHint=false), the description discloses the real side effects: results are written to local disk, absolute paths plus metadata are returned, and image bytes are never returned. It also surfaces the auth requirement (OPENAI_API_KEY) and the mask/markup combination constraint, though it omits cost, latency, or rate-limit expectations for a network-dependent, non-idempotent tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Four sentences, front-loaded with purpose, then constraints, auth, and output behavior in a logical order with no filler. The constraint sentence largely duplicates schema content, which is the only minor inefficiency.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists, so return-value detail is not required, yet the description still tells the agent that paths and metadata come back and that bytes do not. For a 20-parameter, network-dependent mutation tool it covers auth, input validity, and write behavior; only guidance about multi-output naming or model choice trade-offs is left to the schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so every one of the 20 parameters is already self-documenting. The description only restates the image format/size/count constraints already present in the schema and adds no new parameter-level meaning such as default model resolution or output_format interaction, so the baseline of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Edit or extend one or more local images') and names the exact upstream operation (POST /v1/images/edits), plus the side effect of saving results to disk. This clearly separates it from siblings like generate_image (creation from a prompt) and the pure-transform tools (crop_image, resize_image, convert_image).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives clear preconditions for use: source images must be local absolute paths in PNG/JPEG/WebP, under 50 MB each, up to 16, and OPENAI_API_KEY must be set. It does not explicitly name an alternative tool or state when not to use this, so it stops short of a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.