Edit an image
Submit a Magic Edit job — a source image plus a prompt, optionally masked and styled.
202 Accepted with a job id; poll
GET /images/edits/{id} for the result. The
image object takes exactly one of image_id, url, or base64 + mime_type.
Example: masked edit from a URL
Provide the source byurl, add an inpaint mask (its presence selects PRO mode),
and reuse a style model. The mask is a base64-encoded image marking the region
to edit.
image. Omit mask for a text-only (SIMPLE)
edit. resolution applies only to nano_banana_pro; omit it for the other
engines. num_images (1–4) defaults to 1.Authorizations
Organization API key as a bearer token: Authorization: Bearer samsa_sk_....
Headers
Body
POST /images/edits body (ADR §8, §10) — Magic Edit.
Supply a prompt and a source image; optionally a mask (auto-selects PRO
mode), your organization's trained models (style_id/object_ids/person_ids/
setting_ids, color_palette_id — any of these forces the nano_banana_pro
engine, mirroring the app), and an engine (a public-safe alias of the internal
edit model). num_images defaults to 1.
The source image: exactly one of image_id, url, or base64+mime_type.
Text prompt describing the edit. Runs the same validation as the app (rejects empty / malformed / policy-violating prompts with a 422).
1"Replace the sky with a dramatic sunset"
Optional inpaint mask. When present, the edit runs in PRO (mask-based) mode — supported only by the nano_banana_pro and gemini engines (or when trained models force nano_banana_pro).
Edit engine — one of nano_banana_pro (default), gemini, or kontext. Omit to use the default. Unknown engines return 422.
"nano_banana_pro"
A style model in your organization (forces nano_banana_pro).
object models in your organization to compose in.
person models in your organization to compose in.
setting models in your organization (maps to internal scenes).
A color palette in your organization (forces nano_banana_pro).
Output resolution — 1K, 2K, or 4K. Only the nano_banana_pro engine supports it (credits scale 1K:1x, 2K:2x, 4K:4x; omitted = 1K); omit for the other engines.
"1K"
Number of edited images to generate (1-4). Defaults to 1; each output is billed.
1 <= x <= 41
Encoding of the returned images. v1 supports png only.
png "png"
Optional https webhook notified once on terminal status (signed per the webhook signature scheme; see the webhooks docs).
"https://example.com/webhooks/samsa"
Response
Successful Response
202 body for POST /images/edits (ADR §7.1).
The image-edit job id — poll GET /images/edits/{id}.
Initial status: always pending at submit.
pending, processing, completed, failed, cancelled "pending"
Credits this job is expected to cost (base 5 x num_images x resolution multiplier for nano_banana_pro).
5

