Skip to main content
POST
Edit an image with a prompt (Magic Edit)
Invia un’immagine sorgente e un prompt che descrive la modifica. La chiamata restituisce 202 Accepted con un id del job; interroga GET /images/edits/{id} per il risultato. L’oggetto image accetta esattamente uno tra image_id, url, oppure base64 + mime_type.

Esempio: modifica con mask da un URL

Fornisci la sorgente tramite url, aggiungi un mask di inpaint (la sua presenza seleziona la modalità PRO) e riutilizza un modello style. Il mask è un’immagine codificata in base64 che segna la regione da modificare.
Invia esattamente una modalità sorgente in image. Ometti mask per una modifica solo testuale (SIMPLE). resolution si applica solo a nano_banana_pro; omettila per gli altri engine. num_images (1–4) ha come valore predefinito 1.

Autorizzazioni

Authorization
string
header
obbligatorio

Organization API key as a bearer token: Authorization: Bearer samsa_sk_....

Corpo

application/json

POST /images/edits body (ADR §8, §10) — Magic Edit.

Supply a prompt and a source image; optionally a mask (auto-selects PRO mode), trained models you own (including your own private models) or shared within your organization (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.

image
PublicImageEditSource · object
obbligatorio

The source image: exactly one of image_id, url, or base64+mime_type.

prompt
string
obbligatorio

Text prompt describing the edit. Runs the same validation as the app (rejects empty / malformed / policy-violating prompts with a 422).

Minimum string length: 1
Esempio:

"Replace the sky with a dramatic sunset"

mask
PublicImageEditMask · object | null

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).

engine
string | null

Edit engine — one of nano_banana_pro (default), gemini, or kontext. Omit to use the default. Unknown engines return 422.

Esempio:

"nano_banana_pro"

style_id

A style model NAME or its UUID id (from list_models), resolved within your visible set — a model you own (including your own private models) or a non-private one shared with your organization. A name matching more than one visible model is rejected — pass the id. Forces the nano_banana_pro engine.

object_ids
(string<uuid> | string)[]

object models to compose in — each a model NAME or its UUID id (from list_models), resolved within your visible set (a model you own, including private, or a non-private one your organization shares). A name matching more than one visible model is rejected — pass the id.

person_ids
(string<uuid> | string)[]

person models to compose in — each a model NAME or its UUID id (from list_models), resolved within your visible set (a model you own, including private, or a non-private one your organization shares). A name matching more than one visible model is rejected — pass the id.

setting_ids
(string<uuid> | string)[]

setting models to compose in — each a model NAME or its UUID id (from list_models), resolved within your visible set (a model you own, including private, or a non-private one your organization shares). A name matching more than one visible model is rejected — pass the id. Maps to internal scenes.

color_palette_id

A color palette NAME or its UUID id, resolved within your visible set — a palette you created (including private ones) or a non-private palette shared with your organization. A name matching more than one visible palette is rejected — pass the id. Forces the nano_banana_pro engine.

resolution
string | null

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.

Esempio:

"1K"

num_images
integer
predefinito:1

Number of edited images to generate (1-4). Defaults to 1; each output is billed.

Intervallo richiesto: 1 <= x <= 4
Esempio:

1

output_format
enum<string>
predefinito:png

Encoding of the returned images. v1 supports png only.

Opzioni disponibili:
png
Esempio:

"png"

webhook_url
string | null

Optional https webhook notified once on terminal status (signed per the webhook signature scheme; see the webhooks docs).

Esempio:

"https://example.com/webhooks/samsa"

Risposta

Successful Response

202 body for POST /images/edits (ADR §7.1).

id
string<uuid>
obbligatorio

The image-edit job id — poll GET /images/edits/{id}.

status
enum<string>
obbligatorio

Initial status: always pending at submit.

Opzioni disponibili:
pending,
processing,
completed,
failed,
cancelled
Esempio:

"pending"

estimated_credits
integer
obbligatorio

Credits this job is expected to cost (base 5 x num_images x resolution multiplier for nano_banana_pro).

Esempio:

5