Skip to main content
POST
Generate images from a prompt (and optional trained models)
Invia un prompt per generare da una a quattro immagini. La chiamata restituisce 202 Accepted con un id del job; interroga GET /images/generations/{id} per il risultato. Combina i modelli addestrati della tua organizzazione passando i loro id o i loro nomi — style_id, object_ids, person_ids, setting_ids — più un color_palette_id. Ogni riferimento accetta un nome o un id che si risolve a un modello o a una palette visibile a te.

Esempio: comporre più modelli addestrati

Passa un modello style, uno o più modelli person e setting e una color palette insieme in un’unica richiesta. Ogni riferimento a un modello — tramite id o nome — deve risolversi a un modello completed visibile a te.
object_ids, person_ids e setting_ids sono array; style_id e color_palette_id accettano un singolo valore (un nome o un id). num_outputs (1–4) ha come valore predefinito 1 e ogni output viene addebitato. Ometti engine per usare il predefinito nano_banana_pro. aspect_ratio accetta 1:1 (predefinito), 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, 1:4, 4:1, 1:8 e 8:1; un rapporto non supportato restituisce 422 prima che vengano addebitati credits.

Autorizzazioni

Authorization
string
header
obbligatorio

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

Corpo

application/json

POST /images/generations body (ADR §8, §10).

Trained-model refs (style_id, object_ids, person_ids, setting_ids) and the color_palette_id color-palette ref combine on the Gemini path — each accepts a NAME or its UUID id, resolved within your visible set (a model/palette you own, including private ones, or a non-private one shared within your organization); setting_ids maps to the internal scene_ids (ADR §8.2). engine is a public-safe subset of the image engines (ADR §8.3). Note num_outputs defaults to 1 for API ergonomics — the internal app default is 4.

prompt
string
obbligatorio

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

Minimum string length: 1
Esempio:

"A minimalist product shot of a ceramic mug on linen, soft daylight"

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. Must be completed.

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.

engine
string | null

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

Esempio:

"nano_banana_pro"

num_outputs
integer
predefinito:1

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

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

1

aspect_ratio
string
predefinito:1:1

Aspect ratio for the generated image(s). One of 1:1 (default), 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9, 1:4, 4:1, 1:8, 8:1. Unsupported ratios return 422 before any credits are charged.

Esempio:

"1:1"

resolution
string
predefinito:1K

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

Esempio:

"1K"

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/generations (ADR §7.1).

id
string<uuid>
obbligatorio

The image job id — poll GET /images/generations/{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_outputs x resolution multiplier).

Esempio:

5