Skip to main content
POST
Transform reference images with a prompt (img2img)
Transforme 1 à 14 images sources avec un prompt. L’appel renvoie 202 Accepted avec un id de job ; interroge GET /images/img2img/{id} pour le résultat. Chaque entrée de images est un objet source prenant exactement un de image_id, url ou base64 + mime_type ; l’ordre est préservé. Requiert le scope images.edit.

Exemple : une source par mode

Exemple : mélanger plusieurs sources

Passe plusieurs sources — mélanger les modes est autorisé — et règle le moteur, le ratio et la résolution :
Body
La réponse 202 est le handle de job asynchrone :
202 Accepted
images contient 1 à 14 sources ; chacune est exactement un de image_id, d’une url https ou de base64 + mime_type. prompt est requis. engine est nano_banana_pro (défaut) ou nano_banana_2 ; un moteur inconnu renvoie 422. aspect_ratio est validé par rapport à la liste supportée du moteur (1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9 ; nano_banana_2 aussi 4:1, 1:4, 8:1, 1:8) ; omis, il préserve la forme de la source. resolution est 1K (défaut), 2K ou 4K. num_outputs (1 à 4) vaut 1 par défaut et chaque sortie (output) est facturée. output_format est png uniquement en v1.

Credits

Chaque sortie (output) coûte 5 credits en 1K, en fonction de la résolution (1K ×1, 2K ×2, 4K ×4) et multiplié par num_outputs. Voir Tarifs.

Erreurs

Autorisations

Authorization
string
header
requis

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

Corps

application/json

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

images
PublicImageEditSource · object[]
requis

1-14 source images; each exactly one of image_id, an https url, or base64+mime_type. Order is preserved.

Required array length: 1 - 14 elements
prompt
string
requis

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

Minimum string length: 1
Exemple:

"Combine the products into one cohesive lifestyle scene"

engine
string | null

Img2img engine — one of nano_banana_pro (default) or nano_banana_2. Omit to use the default. Unknown engines return 422.

Exemple:

"nano_banana_pro"

aspect_ratio
string | null

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.

Exemple:

"1:1"

resolution
string
défaut:1K

Output resolution — 1K (default), 2K, or 4K. Credits scale 1K:1x, 2K:2x, 4K:4x per output.

Exemple:

"1K"

num_outputs
integer
défaut:1

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

Plage requise: 1 <= x <= 4
Exemple:

1

output_format
enum<string>
défaut:png

Encoding of the returned images. v1 supports png only.

Options disponibles:
png
Exemple:

"png"

webhook_url
string | null

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

Exemple:

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

Réponse

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.

id
string<uuid>
requis

The job id — poll the op's GET .../{id} endpoint.

status
enum<string>
requis

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

Options disponibles:
pending,
processing,
completed,
failed,
cancelled
Exemple:

"pending"

estimated_credits
integer
requis

Credits this job is expected to cost — 0 on a cache-hit completed response.

Exemple:

5