curl --request POST \
--url https://api.samsa.ai/public/v1/images/img2img \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"images": [
{
"image_id": "123e4567-e89b-12d3-a456-426614174000"
}
],
"prompt": "Place the product on a marble kitchen counter"
}
'import requests
url = "https://api.samsa.ai/public/v1/images/img2img"
payload = {
"images": [{ "image_id": "123e4567-e89b-12d3-a456-426614174000" }],
"prompt": "Place the product on a marble kitchen counter"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
images: [{image_id: '123e4567-e89b-12d3-a456-426614174000'}],
prompt: 'Place the product on a marble kitchen counter'
})
};
fetch('https://api.samsa.ai/public/v1/images/img2img', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.samsa.ai/public/v1/images/img2img",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'images' => [
[
'image_id' => '123e4567-e89b-12d3-a456-426614174000'
]
],
'prompt' => 'Place the product on a marble kitchen counter'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.samsa.ai/public/v1/images/img2img"
payload := strings.NewReader("{\n \"images\": [\n {\n \"image_id\": \"123e4567-e89b-12d3-a456-426614174000\"\n }\n ],\n \"prompt\": \"Place the product on a marble kitchen counter\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.samsa.ai/public/v1/images/img2img")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"images\": [\n {\n \"image_id\": \"123e4567-e89b-12d3-a456-426614174000\"\n }\n ],\n \"prompt\": \"Place the product on a marble kitchen counter\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.samsa.ai/public/v1/images/img2img")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"images\": [\n {\n \"image_id\": \"123e4567-e89b-12d3-a456-426614174000\"\n }\n ],\n \"prompt\": \"Place the product on a marble kitchen counter\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "pending",
"estimated_credits": 5
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The provided API key is invalid, expired, or revoked.",
"request_id": "8f14e45fceea167a5a36dedd4bea2543",
"param": "aspect_ratio"
}
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The provided API key is invalid, expired, or revoked.",
"request_id": "8f14e45fceea167a5a36dedd4bea2543",
"param": "aspect_ratio"
}
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The provided API key is invalid, expired, or revoked.",
"request_id": "8f14e45fceea167a5a36dedd4bea2543",
"param": "aspect_ratio"
}
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The provided API key is invalid, expired, or revoked.",
"request_id": "8f14e45fceea167a5a36dedd4bea2543",
"param": "aspect_ratio"
}
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The provided API key is invalid, expired, or revoked.",
"request_id": "8f14e45fceea167a5a36dedd4bea2543",
"param": "aspect_ratio"
}
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The provided API key is invalid, expired, or revoked.",
"request_id": "8f14e45fceea167a5a36dedd4bea2543",
"param": "aspect_ratio"
}
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The provided API key is invalid, expired, or revoked.",
"request_id": "8f14e45fceea167a5a36dedd4bea2543",
"param": "aspect_ratio"
}
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The provided API key is invalid, expired, or revoked.",
"request_id": "8f14e45fceea167a5a36dedd4bea2543",
"param": "aspect_ratio"
}
}Bilder transformieren (img2img)
Reiche einen img2img-Job ein — 1–14 Referenzbilder plus einen Prompt — und erhalte eine Job-id zurück.
curl --request POST \
--url https://api.samsa.ai/public/v1/images/img2img \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"images": [
{
"image_id": "123e4567-e89b-12d3-a456-426614174000"
}
],
"prompt": "Place the product on a marble kitchen counter"
}
'import requests
url = "https://api.samsa.ai/public/v1/images/img2img"
payload = {
"images": [{ "image_id": "123e4567-e89b-12d3-a456-426614174000" }],
"prompt": "Place the product on a marble kitchen counter"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
images: [{image_id: '123e4567-e89b-12d3-a456-426614174000'}],
prompt: 'Place the product on a marble kitchen counter'
})
};
fetch('https://api.samsa.ai/public/v1/images/img2img', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.samsa.ai/public/v1/images/img2img",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'images' => [
[
'image_id' => '123e4567-e89b-12d3-a456-426614174000'
]
],
'prompt' => 'Place the product on a marble kitchen counter'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.samsa.ai/public/v1/images/img2img"
payload := strings.NewReader("{\n \"images\": [\n {\n \"image_id\": \"123e4567-e89b-12d3-a456-426614174000\"\n }\n ],\n \"prompt\": \"Place the product on a marble kitchen counter\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.samsa.ai/public/v1/images/img2img")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"images\": [\n {\n \"image_id\": \"123e4567-e89b-12d3-a456-426614174000\"\n }\n ],\n \"prompt\": \"Place the product on a marble kitchen counter\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.samsa.ai/public/v1/images/img2img")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"images\": [\n {\n \"image_id\": \"123e4567-e89b-12d3-a456-426614174000\"\n }\n ],\n \"prompt\": \"Place the product on a marble kitchen counter\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "pending",
"estimated_credits": 5
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The provided API key is invalid, expired, or revoked.",
"request_id": "8f14e45fceea167a5a36dedd4bea2543",
"param": "aspect_ratio"
}
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The provided API key is invalid, expired, or revoked.",
"request_id": "8f14e45fceea167a5a36dedd4bea2543",
"param": "aspect_ratio"
}
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The provided API key is invalid, expired, or revoked.",
"request_id": "8f14e45fceea167a5a36dedd4bea2543",
"param": "aspect_ratio"
}
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The provided API key is invalid, expired, or revoked.",
"request_id": "8f14e45fceea167a5a36dedd4bea2543",
"param": "aspect_ratio"
}
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The provided API key is invalid, expired, or revoked.",
"request_id": "8f14e45fceea167a5a36dedd4bea2543",
"param": "aspect_ratio"
}
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The provided API key is invalid, expired, or revoked.",
"request_id": "8f14e45fceea167a5a36dedd4bea2543",
"param": "aspect_ratio"
}
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The provided API key is invalid, expired, or revoked.",
"request_id": "8f14e45fceea167a5a36dedd4bea2543",
"param": "aspect_ratio"
}
}{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The provided API key is invalid, expired, or revoked.",
"request_id": "8f14e45fceea167a5a36dedd4bea2543",
"param": "aspect_ratio"
}
}images mit einem prompt. Der Aufruf gibt
202 Accepted mit einer Job-id zurück; frage
GET /images/img2img/{id} nach dem
Ergebnis ab. Jeder Eintrag in images ist ein Quellobjekt, das genau eines von
image_id, url oder base64 + mime_type nimmt; die Reihenfolge bleibt
erhalten. Erfordert den images.edit-Scope.
Beispiel: eine Quelle pro Modus
curl -X POST https://api.samsa.ai/public/v1/images/img2img \
-H "Authorization: Bearer $SAMSA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"images": [{ "image_id": "123e4567-e89b-12d3-a456-426614174000" }],
"prompt": "Place the product on a marble kitchen counter"
}'
curl -X POST https://api.samsa.ai/public/v1/images/img2img \
-H "Authorization: Bearer $SAMSA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"images": [{ "url": "https://cdn.example.com/photo.png" }],
"prompt": "Turn this sketch into a photorealistic render",
"resolution": "2K"
}'
curl -X POST https://api.samsa.ai/public/v1/images/img2img \
-H "Authorization: Bearer $SAMSA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"images": [{ "base64": "iVBORw0KGgoAAAANSUhEUg...", "mime_type": "image/png" }],
"prompt": "Apply a warm sunset color grade",
"num_outputs": 2
}'
Beispiel: mehrere Quellen mischen
Übergib mehrere Quellen — Modi zu mischen ist erlaubt — und stelle Engine, Seitenverhältnis und Auflösung ein:{
"images": [
{ "image_id": "123e4567-e89b-12d3-a456-426614174000" },
{ "url": "https://cdn.example.com/reference.jpg" },
{ "base64": "iVBORw0KGgoAAAANSUhEUg...", "mime_type": "image/webp" }
],
"prompt": "Blend the subject into the reference scene",
"engine": "nano_banana_2",
"aspect_ratio": "16:9",
"resolution": "4K",
"webhook_url": "https://example.com/webhooks/samsa"
}
202-Antwort ist das asynchrone Job-Handle:
{
"id": "b3f1c2d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
"status": "pending",
"estimated_credits": 20
}
images enthält 1–14 Quellen; jede ist genau eines von image_id, einer
https-url oder base64 + mime_type. prompt ist erforderlich. engine ist
nano_banana_pro (Standard) oder nano_banana_2; eine unbekannte Engine liefert
422. aspect_ratio wird gegen die unterstützte Liste der Engine validiert
(1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9;
nano_banana_2 zusätzlich 4:1, 1:4, 8:1, 1:8); weggelassen bleibt die
Quellform erhalten. resolution ist 1K (Standard), 2K oder 4K.
num_outputs (1–4) ist standardmäßig 1 und jedes Ergebnis (output) wird
abgerechnet. output_format ist in v1 nur png.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
| Status | Code | Wann |
|---|---|---|
402 | insufficient_credits / insufficient_team_credits / insufficient_unallocated_credits | Der Stand, den dieses Credential ausgeben kann, liegt unter den Job-Kosten. Organisationen mit mindestens einem aktiven Team erhalten statt insufficient_credits die team-bezogenen Codes (ausgenommen vom Team-Budgeting befreite System-Organisationen). Ein operativer Fehler in der Abbuchung selbst kann dennoch das generische insufficient_credits liefern, unabhängig vom Regime. |
402 | subscription_inactive | Die Organisation hat kein nutzbares Abonnement. |
403 | missing_scope | Dem Schlüssel fehlt der images.edit-Scope. |
404 | not_found | Eine Quell-image_id ist unbekannt oder gehört nicht dem Key-Ersteller — auch ein Bild, das ein anderes Mitglied deiner Organisation erstellt hat, ist ein 404. |
422 | validation_error | Null/mehrere Quellmodi, ungültiger Prompt, unbekannte Engine oder nicht unterstütztes Seitenverhältnis. |
429 | rate_limited / too_many_active_jobs | Pro-Schlüssel-Ratenfenster oder pro-Organisation-Concurrency-Limit überschritten. |
Autorisierungen
Organization API key as a bearer token: Authorization: Bearer samsa_sk_....
Body
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 elementsShow child attributes
Show child attributes
Text 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"
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

