OpenGen image editing pairs workspace-private uploaded assets with one canonical input schema across 25 image models. Upload your source image via POST /v1/assets to receive a ready assetKey, pass it inside input.references (plus optional input.mask on models such as GPT Image 2), check pricing with POST /v1/pricing/estimate, and submit once with a persisted Idempotency-Key so retries never double-bill.
operation: image-editReviewed 2026-12-02
AGENT PROMPT · PASTE INTO YOUR AGENT OR AUTO-READ
Walk me through an image-edit generation on OpenGen (https://opengen.dev):
1. Discover models supporting image-edit via GET https://opengen.dev/v1/models?operation=image-edit (or MCP find_models with operation="image-edit"; add inputRole="mask" if inpainting is needed).
2. Inspect the exact model via GET https://opengen.dev/v1/models/{provider}/{model}?operation=image-edit (or MCP get_model, e.g. id="openai/gpt-image-2", operation="image-edit") to check maximum reference counts, mask support, and published pricing.
3. Upload each private source image (and optional mask) using POST https://opengen.dev/v1/assets (or MCP upload_asset) and confirm state="ready" before referencing its assetKey.
4. Estimate spend via POST https://opengen.dev/v1/pricing/estimate (or MCP estimate_cost) and confirm the route and maxCostMicros cap with me.
5. Submit once with a persisted Idempotency-Key via POST https://opengen.dev/v1/generations (Prefer: wait=20) or MCP generate (waitMs=20000), then follow or refresh private output links via job_get without blind resubmission.
OpenGen image-edit transforms one or more workspace-private reference images using natural-language instructions and, on mask-capable variants, an explicit alpha mask. Source images always enter through OpenGen's private asset API so files stay scoped to your workspace rather than being published to public URLs.
Prerequisites
An OpenGen credential with read and generate scopes (OPENGEN_API_KEY, MCP OAuth on https://opengen.dev/mcp, or @opengen-dev/cli login).
A local PNG, JPEG, or WebP source image you own or have permission to edit (plus an optional PNG mask when using mask inpainting).
1. Inspect an image-edit model and its media limits
Reference limits, mask support, and transparent-background rules vary by exact variant. Check them before uploading or building a payload:
GPT Image 2 (openai/gpt-image-2, official route openai-undisclosed/openai-gpt-image-2 is live-verified for text-to-image at 1K, while image-edit remains documented with an active OpenAI adapter): up to 16 image references, supports optional mask, background: "transparent" with png/webp, and 1K–4K output.
Seedream 5.0 Pro (bytedance/seedream-5.0-pro): up to 10 image references, supports constrained transparent PNG editing (references.length === 1, background: "transparent", outputFormat: "png").
Nano Banana 2 (google/nano-banana-2): 0.5K–4K editing, up to 14 references, with thinkingLevel: "minimal" | "high".
# Filter models supporting image-edit (add &inputRole=mask for mask inpainting)
curl --fail-with-body \
"https://opengen.dev/v1/models?operation=image-edit&inputRole=mask"
# Inspect exact schema, routes, and published pricing for GPT Image 2
curl --fail-with-body \
"https://opengen.dev/v1/models/openai/gpt-image-2?operation=image-edit"
2. Upload your private source image (and optional mask)
Use POST /v1/assets to register your source image privately inside your workspace. Single-step multipart/form-data handles files up to 4 MiB (JSON base64 handles up to 3 MiB decoded; files up to 100 MiB use presigned single-PUT + POST /v1/assets/complete—see Owned Assets). Require state: "ready" before referencing assetKey.
Pass uploaded images in input.references as { "type": "image", "asset": { "assetKey": "..." } }. Image operations never use video-frame fields (firstFrame or lastFrame).
set -eu
umask 077
if [ -e edit-submission.key ]; then
echo "Existing edit-submission.key found; recover read-only via GET /v1/generations/lookup before replacing edit-request.json." >&2
exit 1
fi
rm -f edit-request.json
cat <<'JSON' > edit-request.json
{
"modelId": "openai/gpt-image-2",
"operation": "image-edit",
"input": {
"prompt": "Replace the tabletop background with warm honed travertine stone while keeping the ceramic mug and shadows identical.",
"references": [
{
"type": "image",
"asset": {
"assetKey": "inputs/YOUR_WORKSPACE/RETURNED_IMAGE_UUID.png"
}
}
],
"resolution": "1K",
"quality": "medium",
"outputFormat": "png"
},
"routeId": "openai-undisclosed/openai-gpt-image-2",
"billing": "byok"
}
JSON
chmod 600 edit-request.json
# Dry-run estimate only (review selectedRouteId and workspaceEligibility before submitting)
curl --fail-with-body \
-X POST "https://opengen.dev/v1/pricing/estimate" \
-H "Authorization: Bearer $OPENGEN_API_KEY" \
-H "Content-Type: application/json" \
--data @edit-request.json
Submit once after reviewing the estimate
Run this step only after reviewing the estimate output above and confirming selectedRouteId, workspaceEligibility (policyAllowed: true, hasActiveBillingHold: false, executableCandidateCount > 0, blockers: []), and your BYOK billing payer.
set -eu
umask 077
if [ -e edit-submission.key ]; then
echo "Existing edit-submission.key found; recover read-only via GET /v1/generations/lookup before creating a new submission." >&2
exit 1
fi
RAW_UUID="$(uuidgen)"
[ -n "$RAW_UUID" ] || { echo "uuidgen failed" >&2; exit 1; }
IDEMPOTENCY_KEY="edit-$(printf '%s' "$RAW_UUID" | tr '[:upper:]' '[:lower:]')"
(set -C; printf '%s\n' "$IDEMPOTENCY_KEY" > edit-submission.key)
curl --fail-with-body \
-X POST "https://opengen.dev/v1/generations" \
-H "Authorization: Bearer $OPENGEN_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $IDEMPOTENCY_KEY" \
-H "Prefer: wait=20" \
--data @edit-request.json > edit-receipt.json
Adding an optional inpainting mask
On mask-capable variants (openai/gpt-image-2, openai/gpt-image-2.5-*, openai/gpt-image-2.6-*), upload a second workspace-private PNG mask and attach it under input.mask alongside at least one image entry in input.references (using "billing": "byok" since managed image-edit quotes are currently comparison-only):
Poll GET /v1/generations/{id}/status?waitMs=25000 (or MCP job_get) until deliveryStatus is available, then download from the returned first-party /media/... capability URL. If a submission disconnects before returning a job ID, recover with GET /v1/generations/lookup?idempotencyKey=$IDEMPOTENCY_KEY.
When you no longer need the uploaded source image for future jobs, tombstone it with DELETE https://opengen.dev/v1/assets?key=<URL-encoded assetKey> (or MCP delete_asset). Accepted jobs keep their private input pins until finished.
Next steps
Need higher resolution without re-composing the scene? See Image Upscaling.
Ready to animate the edited still into video? See Image to Video.
Supported Models
Live catalog inventory for image-edit (24 documented variants). Click any model to compare exact regional routes, privacy disclosures, and source-linked tariffs, or inspect its canonical schema directly via the single-call model endpoint.