Skip to main content
POST
Remove an image's background (transparent PNG)
Entferne den Hintergrund aus einem Quell-image und erzeuge ein transparentes PNG. Der Aufruf gibt 202 Accepted mit einer Job-id zurück; frage GET /images/background-removals/{id} nach dem Ergebnis ab. Das image nimmt genau eines von image_id, url oder base64 + mime_type. Es gibt keinen Modell-Parameter — v1 verwendet das Standard-Hintergrundentfernungsmodell. Erfordert den images.transform-Scope.

Beispiel: eine Quelle pro Modus

Der normale (abgerechnete) Pfad gibt einen pending-Job zurück:
202 Accepted
Kosten = 1 Credit bei einem Miss; 0 bei einem Cache-Treffer. Wenn die Quelle eine image_id ist, die du besitzt, und bereits ein hintergrundentferntes Ergebnis dafür existiert, gibt die Einreichung sofort 202 mit status: "completed" und estimated_credits: 0 zurück — es wird kein neuer Job eingereiht und das Concurrency-Limit deiner Organisation wird nicht belegt. Jeder andere Fall (eine https-url/base64-Quelle oder eine besessene image_id ohne fertiges Ergebnis) ist der normale abgerechnete Pfad oben.
202 Accepted (Cache-Treffer)

Fehler

Autorisierungen

Authorization
string
header
erforderlich

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

Body

application/json

POST /images/background-removals body (SAM-820 / S8.8 — ADR §7, §8, §10).

Remove the background from ONE source image, producing a transparent PNG. The source is exactly one of image_id (an image in your organization's context), an https url, or base64+mime_type. There is NO model parameter — v1 uses the default background-removal model.

Cost = 1 credit on a miss; 0 on a cache HIT. When the source is an image_id you own and a background-removed result already exists for it, the submit returns 202 with status: "completed" and estimated_credits: 0 immediately (no new job is queued and the org's concurrency cap is not consumed). Every other case (an https url/base64 source, or an owned image_id with no ready result) is the normal charged path: 202 with status: "pending" and estimated_credits: 1.

image
PublicImageEditSource · object
erforderlich

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

webhook_url
string | null

Optional https webhook notified once on terminal status (signed per the webhook signature scheme; see the webhooks docs). On a cache hit the completed event fires immediately.

Beispiel:

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

id
string<uuid>
erforderlich

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

status
enum<string>
erforderlich

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

Verfügbare Optionen:
pending,
processing,
completed,
failed,
cancelled
Beispiel:

"pending"

estimated_credits
integer
erforderlich

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

Beispiel:

5