Trasformare immagini (img2img)
Invia un job img2img — 1–14 immagini di riferimento più un prompt — e ottieni un id del job.
images sorgente con un prompt. La chiamata restituisce
202 Accepted con un id del job; interroga
GET /images/img2img/{id} per il
risultato. Ogni voce in images è un oggetto sorgente che prende esattamente uno
tra image_id, url o base64 + mime_type; l’ordine è preservato. Richiede lo
scope images.edit.
Esempio: una sorgente per modalità
Esempio: combinare più sorgenti
Passa più sorgenti — mescolare le modalità è consentito — e regola engine, rapporto e risoluzione:202 è l’handle del job asincrono:
images contiene 1–14 sorgenti; ognuna è esattamente una tra image_id, un
url https o base64 + mime_type. prompt è obbligatorio. engine è
nano_banana_pro (predefinito) o nano_banana_2; un engine sconosciuto
restituisce 422. aspect_ratio è validato rispetto all’elenco supportato
dall’engine (1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9,
21:9; nano_banana_2 inoltre 4:1, 1:4, 8:1, 1:8); se omesso, preserva la
forma della sorgente. resolution è 1K (predefinito), 2K o 4K.
num_outputs (1–4) è 1 per impostazione predefinita e ogni output viene
addebitato. output_format è solo png in v1.Credits
Ogni output costa5 credits a 1K, con scalatura in base alla risoluzione
(1K ×1, 2K ×2, 4K ×4) e moltiplicato per num_outputs. Vedi
Prezzi.
Errori
Autorizzazioni
Organization API key as a bearer token: Authorization: Bearer samsa_sk_....
Corpo
POST /images/img2img body (SAM-815 / S8.3 — ADR §8, §10).
Transform 1-14 source images with a prompt (the app's Edit-tab img2img
flow). Each source is exactly one of image_id (an image in your
organization's context), an https url, or base64+mime_type. engine
is a public-safe alias of the internal edit model (nano_banana_pro
default, nano_banana_2); num_outputs defaults to 1 (the app default
is 4). Each output is billed at 5 x resolution_multiplier credits
(1K:1x, 2K:2x, 4K:4x).
1-14 source images; each exactly one of image_id, an https url, or base64+mime_type. Order is preserved.
1 - 14 elementsText prompt describing the transformation. Runs the same validation as the app (rejects empty / malformed / policy-violating prompts with a 422).
1"Combine the products into one cohesive lifestyle scene"
Img2img engine — one of nano_banana_pro (default) or nano_banana_2. Omit to use the default. Unknown engines return 422.
"nano_banana_pro"
Optional aspect ratio for the generated image(s), validated against the engine's supported list (1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9; nano_banana_2 additionally 4:1, 1:4, 8:1, 1:8). Omitted = the engine preserves the source shape.
"1:1"
Output resolution — 1K (default), 2K, or 4K. Credits scale 1K:1x, 2K:2x, 4K:4x per output.
"1K"
Number of images to generate (1-4). Defaults to 1 (the app default is 4); 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"
Risposta
Successful Response
Shared 202 body for the transform-op submits (SAM-813 / S8 wave).
Every POST /images/<op> returns the async job handle
{id, status, estimated_credits}. The initial status is pending (the
job is queued), with ONE exception: background-removals and
vectorizations answer an owned-image_id cache hit (a ready result
already exists for that image) with status: "completed" and
estimated_credits: 0 — no new job is queued, the completed webhook
event is emitted immediately for a supplied webhook_url, and the result
is already available from the op's GET .../{id} endpoint. The other
transform ops (img2img, variations, resizes, upscales) always
start pending.
The job id — poll the op's GET .../{id} endpoint.
Initial status: pending (job queued — enter the polling flow), or completed with estimated_credits: 0 when background-removals / vectorizations serve an owned-image cache hit (the result is immediately available).
pending, processing, completed, failed, cancelled "pending"
Credits this job is expected to cost — 0 on a cache-hit completed response.
5

