Skip to main content
Glama

Edit Image

edit_image

Edit or compose images from 1–8 inputs using a text prompt, with optional mask-based region editing for tasks like background swaps, product retouching, and multi-image compositions.

Instructions

Edit or compose images with OpenAI's gpt-image-2 model family (models: "gpt-image-2" (default), "gpt-image-2.5-flare", "gpt-image-2.5-sunburst"). 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. Calls that exceed ~20s (slow proxy routes, large inputs) automatically move to a background job: the first response then carries a job_id — poll get_image_job until it reports state "completed".

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", "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.
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; "auto" lets the model pick. gpt-image-2 does NOT support transparent backgrounds — use a different model for that.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
imagesNo
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. First observedv0.3.0

TDQS

A4.3/5.0
Behavior4/5

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

Annotations declare readOnlyHint=false, destructiveHint=false, and idempotentHint=false, which already signal a mutating, non-idempotent operation. The description adds valuable behavior beyond these: background job auto-migration for slow calls, inline return plus file saving, high-fidelity processing with no input_fidelity option, and lack of transparent background support. This contextualizes side effects (file writes) and asynchronous behavior, though it does not discuss potential file overwrites or concurrency implications.

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?

The description is moderately long but efficiently packed. It front-loads purpose and use cases, proceeds to key technical behaviors (mask, fidelity), and ends with the background-job fallback. Every sentence carries operational or decision-relevant information; there is no filler. A tight, organized structure that earns its length.

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?

For a tool with 13 parameters, 2 required, and an output schema, the description covers the essential operational aspects: input types and limits, mask semantics, background constraints, model variants, output handling, and the async job pattern. It does not delve into session integration (e.g., how edit_image relates to continue_edit_session) but that is arguably beyond its direct invocation scope. Given the richness of schema and annotations, the description is adequately complete for correct invocation.

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?

Schema coverage is 100%, so every parameter is already described. The description adds meaning beyond the schema: it clarifies that the mask applies to the first input image, explains that models always process at high fidelity (explaining absent input_fidelity), explicitly ties 'n' to rate limits/cost (already hinted in schema), and notes transparency limitations tied to the background parameter. This extra context lifts the value beyond the schema baseline of 3.

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 ('Edit or compose') and a clear resource (images with gpt-image-2 family), lists concrete use cases (swap backgrounds, retouch products, combine reference images), and names at least one constraint (mask applies to first image). It clearly distinguishes from the sibling generate_image by focusing on editing/composition, and the mention of model family and background behavior signals its scope.

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?

Provides explicit use-case guidance ('Great for: swap backgrounds, retouch products...') and notes a limitation ('use a different model for transparent backgrounds'). However, it does not explicitly contrast with generate_image or the session-based siblings (start_edit_session, etc.), nor does it state when NOT to use it beyond the transparency note. Clear context but lacks a direct alternative-routing statement.

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