Ein Bild resizen
Reiche einen Resize-Job ein — ein Quellbild auf ein neues Seitenverhältnis (serverseitiges Outpainting).
image auf ein neues aspect_ratio. Resize ist ein
serverseitiges Outpainting: Das Backend rendert die Komposition und Maske aus
deiner Quelle im Zielverhältnis und füllt die neu freigelegte Leinwand mit einer
stilangepassten Erweiterung. Der Aufruf gibt 202 Accepted mit einer Job-id
zurück; frage GET /images/resizes/{id}
nach dem Ergebnis ab. Das image nimmt genau eines von image_id, url oder
base64 + mime_type. Erfordert den images.transform-Scope.
Beispiel: eine Quelle pro Modus
202-Antwort ist das asynchrone Job-Handle:
aspect_ratio ist erforderlich und eines von 21:9, 16:9, 3:2, 4:3,
5:4, 1:1, 4:5, 3:4, 2:3, 9:16. resolution (1K Standard, 2K, 4K)
ist Provider-Metadata, die die Credits skaliert — die Leinwand wird immer mit einer
maximalen Kante von 1024px gerendert. num_outputs (1–4) ist standardmäßig 1
und jedes Ergebnis (output) wird abgerechnet. prompt ist optionale Anleitung für
den neu generierten Bereich (validiert, wenn nicht leer). placement positioniert
die Quelle auf der Zielleinwand: gravity ist eines von center (Standard),
top, bottom, left, right, top_left, top_right, bottom_left,
bottom_right; scale liegt in (0, 1] (Standard 1.0 = maximaler
Contain-Fit).aspect_ratio + placement (nahezu)
keinen neuen zu generierenden Bereich lassen — z. B. wenn die Quelle bei
scale = 1 bereits dem Zielverhältnis entspricht — und kein prompt angegeben
ist, überspringt der Job das Modell, gibt die abgeflachte Komposition zurück und
erstattet die ungenutzten Outputs. Er completes dennoch.Credits
Jedes Ergebnis (output) kostet5 Credits bei 1K und skaliert mit der Auflösung
(1K ×1, 2K ×2, 4K ×4), multipliziert mit num_outputs. Siehe
Preise.
Fehler
Autorisierungen
Organization API key as a bearer token: Authorization: Bearer samsa_sk_....
Body
POST /images/resizes body (SAM-818 / S8.6 — ADR §8, §10).
Resize = server-side outpaint: the backend renders the composition + mask from
your source at the target aspect_ratio and fills the newly exposed canvas
with a style-matched extension. The source is exactly one of image_id (an
image in your organization's context), an https url, or base64+mime_type.
aspect_ratio is REQUIRED (validated against the resize engine's supported
list). num_outputs defaults to 1; each output is billed at
5 x resolution_multiplier credits (1K:1x, 2K:2x, 4K:4x).
Empty-mask no-op: when the requested aspect_ratio + placement leave (almost)
no new area to generate (e.g. the source already matches the target ratio at
scale=1) and no prompt is given, the job SKIPS the model, returns the
flattened composition, and REFUNDS the unused outputs — it still completes.
The source image: exactly one of image_id, an https url, or base64+mime_type. The source raster must be at most 33,554,432 pixels (32 MP, width x height) — a larger source returns 422 with param: image before any rendering. The composition canvas is at most 1024px per edge, so higher-resolution sources gain no output detail.
Target aspect ratio (REQUIRED) — one of: 21:9, 16:9, 3:2, 4:3, 5:4, 1:1, 4:5, 3:4, 2:3, 9:16.
"16:9"
Provider resolution tier — 1K (default), 2K, or 4K. The canvas is always rendered at a 1024px max edge (per S8.5); the tier is provider metadata that scales credits 1K:1x, 2K:2x, 4K:4x per output.
"1K"
Number of images to generate (1-4). Defaults to 1; each output is billed.
1 <= x <= 41
Optional instruction for the newly generated area. When non-empty it runs the app's prompt validation (rejects empty / malformed / policy-violating prompts with a 422).
"extend the beach and the ocean horizon naturally"
Optional placement of the source on the target canvas (gravity + scale). Defaults to centered, maximum contain-fit.
Optional https webhook notified once on terminal status (signed per the webhook signature scheme; see the webhooks docs).
"https://example.com/webhooks/samsa"
Antwort
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

