Skip to main content
Glama

Edit Image

edit_image

Edit or compose images from 1–8 input images and a text prompt; add an optional PNG mask to control the edit region. Saves the result to disk and returns a job ID for asynchronous completion.

Instructions

Edit or compose images with OpenAI's image model family (models: "gpt-image-2.5-sunburst" (default), "gpt-image-2.5-flare", "gpt-image-2"). Give 1–8 input images plus a text prompt; optionally include a PNG mask whose transparent regions mark what to change (mask applies to the first image). Great for: swap backgrounds, retouch products, combine multiple reference images into one composition, maintain a character across scenes. These models always process inputs at high fidelity (no input_fidelity knob needed). The edited image is saved to disk and returned inline. Image work is slow, so this call hands off immediately: the first response carries a job_id — poll get_image_job until it reports state "completed". Set GPT_IMAGE_2_ASYNC_AFTER_MS to wait inline instead (below your host's tool-call timeout).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nNoHow many images to generate (1–10). Each counts toward rate limits and cost.
maskNoOptional PNG mask — fully transparent pixels mark the editable region. Must match the first input image's dimensions and be <4MB. Accepts the same source types as `images`.
sizeNoOutput dimensions. "auto" (default), one of the presets "1024x1024", "1536x1024", "1024x1536", or a custom "WxH" where both edges are multiples of 16, max edge ≤ 3840px, aspect ratio within 1:3–3:1, and total pixels 655,360–8,294,400. Outputs above 2K are beta.auto
userNoOptional end-user identifier forwarded to OpenAI for abuse monitoring. Pass a stable hashed user ID, not PII.
modelNoModel to use. One of "gpt-image-2.5-sunburst", "gpt-image-2.5-flare", "gpt-image-2"; defaults to "gpt-image-2.5-sunburst". The 2.5 variants accept the same parameters. Cost/token estimates assume gpt-image-2 pricing.
imagesYesInput images. Each entry can be: an absolute file path, a relative path (resolved from CWD), a file:// URL, an http(s):// URL, or a data:image/...;base64,... URL. PNG/WEBP/JPG, up to 50MB each.
promptYesImage description. gpt-image-2 handles very detailed prompts; use ALL CAPS or quote literal text you want rendered verbatim.
qualityNoEdit quality — same levels as generate.auto
backgroundNoBackground behavior. "opaque" forces a filled background; "transparent" asks for alpha (PNG) — verified working for the gpt-image-2 family, and the origin still decides, so check applied.background; "auto" lets the model pick.auto
output_dirNoAbsolute or relative directory where generated images should be written. Defaults to $GPT_IMAGE_2_OUTPUT_DIR or a per-project subfolder under the OS config dir. The directory is created if missing.
output_formatNoFile format. "png" (default, lossless), "jpeg" (smaller, lossy), "webp" (best compression). When omitted on continue_edit_session, the session's current format is kept.
filename_prefixNoShort label appended to the generated filename so you can find it later (e.g. "hero-banner"). Letters/digits/hyphens only; auto-sanitized.
output_compressionNoCompression level 0–100 for jpeg/webp outputs. Ignored for png. Defaults to 100 (minimal compression).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
toolNo
modelNo
notesNo
routeNo
stateNo
usageNo
imagesNoWritten image files — present once the job completed successfully.
job_idNoPresent on background hand-off — pass to get_image_job.
promptNo
appliedNo
poll_hintNo
requestedNo
started_atNo
async_after_msNo
prompt_previewNo
cost_usd_estimatedNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed6 schema fields changedv0.5.5
    • changedInput schema / properties / background / description
      Previous value: -"Background behavior. \"opaque\" forces a filled background; \"auto\" lets the model pick. gpt-image-2 does NOT support transparent backgrounds — use a different model for that."New value: +"Background behavior. \"opaque\" forces a filled background; \"transparent\" asks for alpha (PNG) — verified working for the gpt-image-2 family, and the origin still decides, so check applied.background; \"auto\" lets the model pick."
    • changedInput schema / properties / background / enum
      Previous value: -[
      -  "auto",
      -  "opaque"
      -]New value: +[
      +  "auto",
      +  "opaque",
      +  "transparent"
      +]
    • changedInput schema / properties / model / description
      Previous value: -"Model to use. One of \"gpt-image-2\", \"gpt-image-2.5-flare\", \"gpt-image-2.5-sunburst\"; defaults to \"gpt-image-2\". The 2.5 variants accept the same parameters. Cost/token estimates assume gpt-image-2 pricing."New value: +"Model to use. One of \"gpt-image-2.5-sunburst\", \"gpt-image-2.5-flare\", \"gpt-image-2\"; defaults to \"gpt-image-2.5-sunburst\". The 2.5 variants accept the same parameters. Cost/token estimates assume gpt-image-2 pricing."
    • changedInput schema / properties / model / enum
      Previous value: -[
      -  "gpt-image-2",
      -  "gpt-image-2.5-flare",
      -  "gpt-image-2.5-sunburst"
      -]New value: +[
      +  "gpt-image-2.5-sunburst",
      +  "gpt-image-2.5-flare",
      +  "gpt-image-2"
      +]
    • addedOutput schema / properties / images / description
      Added value: +"Written image files — present once the job completed successfully."
    • changedOutput schema / properties / usage / anyOf
      Previous value: -[
      -  {
      -    "additionalProperties": false,
      -    "properties": {
      -      "input_tokens": {
      -        "type": "number"
      -      },
      -      "input_tokens_details": {
      -        "additionalProperties": false,
      -        "properties": {
      -          "image_tokens": {
      -            "type": "number"
      -          },
      -          "text_tokens": {
      -            "type": "number"
      -          }
      -        },
      -        "type": "object"
      -      },
      -      "output_tokens": {
      -        "type": "number"
      -      },
      -      "output_tokens_details": {
      -        "additionalProperties": false,
      -        "properties": {
      -          "image_tokens": {
      -            "type": "number"
      -          },
      -          "text_tokens": {
      -            "type": "number"
      -          }
      -        },
      -        "type": "object"
      -      },
      -      "total_tokens": {
      -        "type": "number"
      -      }
      -    },
      -    "required": [
      -      "input_tokens",
      -      "output_tokens",
      -      "total_tokens"
      -    ],
      -    "type": "object"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "additionalProperties": false,
      +    "properties": {
      +      "input_tokens": {
      +        "type": "number"
      +      },
      +      "input_tokens_details": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "image_tokens": {
      +            "type": "number"
      +          },
      +          "text_tokens": {
      +            "type": "number"
      +          }
      +        },
      +        "type": "object"
      +      },
      +      "output_tokens": {
      +        "type": "number"
      +      },
      +      "output_tokens_details": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "image_tokens": {
      +            "type": "number"
      +          },
      +          "text_tokens": {
      +            "type": "number"
      +          }
      +        },
      +        "type": "object"
      +      },
      +      "total_tokens": {
      +        "type": "number"
      +      }
      +    },
      +    "type": "object"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
  2. First observedv0.3.0

TDQS

A4.7/5.0
Behavior5/5

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

The description goes well beyond the annotations by disclosing that the call hands off immediately, that the first response carries a job_id, that the caller should poll get_image_job until state 'completed', and that GPT_IMAGE_2_ASYNC_AFTER_MS can make it wait inline. It also notes that inputs are always processed at high fidelity and that outputs are saved to disk and returned inline. These are nontrivial behaviors not captured by readOnlyHint, openWorldHint, idempotentHint, or destructiveHint.

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

Conciseness5/5

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

The description is a single, well-organized paragraph that front-loads the core action, then covers inputs, use cases, and behavior. Every sentence adds useful information, and the async-handoff detail is placed exactly where it is needed. There is no redundancy with the schema or annotations.

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

Completeness5/5

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

Given the tool's complexity (13 parameters, async behavior, optional mask, output writing), the description covers all the essential workflow knowledge an agent needs: inputs, mask semantics, model family, job_id polling, disk output, and the inline-wait alternative. The comprehensive input schema handles parameter-level details, and the output schema handles return values, so nothing required for correct invocation is missing.

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

Parameters4/5

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

The schema already covers 100% of the 13 parameters with detailed descriptions, so the baseline is 3. The description adds cross-cutting semantic value by explaining that the PNG mask's transparent regions mark the editable region, that the mask applies to the first image, and that 1–8 input images can be combined with a text prompt. This contextual mapping of parameters to the editing workflow elevates the score above baseline.

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?

The description starts with a specific verb-resource pair ('Edit or compose images') and immediately names the model family, inputs, and typical use cases. It clearly differentiates itself from sibling tools like generate_image (edit vs. generate) and get_image_job (the tool's async counterpart). An agent can tell exactly what this tool does without opening the schema.

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?

The description provides strong context by listing concrete use cases and explicitly instructing the agent to poll get_image_job after receiving a job_id. It does not explicitly state when to use generate_image or continue_edit_session instead, but the phrase 'Edit or compose' plus the extensive job-handling guidance makes the boundary clear enough. No exclusions or when-not-to-use caveats are given, 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.