Finish an image upload (verify the file, get a usable image_id)
curl --request POST \
--url https://api.samsa.ai/public/v1/images/uploads/{image_id}/complete \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.samsa.ai/public/v1/images/uploads/{image_id}/complete"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.samsa.ai/public/v1/images/uploads/{image_id}/complete', 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/uploads/{image_id}/complete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.samsa.ai/public/v1/images/uploads/{image_id}/complete"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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/uploads/{image_id}/complete")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.samsa.ai/public/v1/images/uploads/{image_id}/complete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"content_type": "image/png",
"filename": "christmas-card.png",
"height": 1536,
"image_id": "3f1c2b7e-8d4a-4c1e-9b2f-5a6d7e8f9a0b",
"size_bytes": 4718592,
"status": "completed",
"width": 2048
}{
"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"
}
}Bild-Uploads
Einen Bild-Upload abschließen
Schritt 3 des Bild-Uploads: Prüfe die hochgeladene Datei und mache ihre image_id nutzbar.
POST
/
images
/
uploads
/
{image_id}
/
complete
Finish an image upload (verify the file, get a usable image_id)
curl --request POST \
--url https://api.samsa.ai/public/v1/images/uploads/{image_id}/complete \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.samsa.ai/public/v1/images/uploads/{image_id}/complete"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.samsa.ai/public/v1/images/uploads/{image_id}/complete', 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/uploads/{image_id}/complete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.samsa.ai/public/v1/images/uploads/{image_id}/complete"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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/uploads/{image_id}/complete")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.samsa.ai/public/v1/images/uploads/{image_id}/complete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"content_type": "image/png",
"filename": "christmas-card.png",
"height": 1536,
"image_id": "3f1c2b7e-8d4a-4c1e-9b2f-5a6d7e8f9a0b",
"size_bytes": 4718592,
"status": "completed",
"width": 2048
}{
"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"
}
}Schritt drei des Bild-Uploads, nach dem
PUT
an die upload_url aus
POST /images/uploads/prepare. Rufe ihn
innerhalb einer Stunde auf. Samsa prüft die Datei — vorhanden, exakt size_bytes,
höchstens 10 MB, ein lesbares Bild des vorbereiteten content_type, höchstens 32
Megapixel — und gibt 200 OK mit der image_id, status: "completed" und der
gemessenen width und height zurück.
Ab dann nutzt du die image_id als Quelle eines Edits, einer Bildoperation oder
einer Image-to-Video-Generierung.
Complete ist idempotent: Ein erneuter Aufruf gibt dasselbe Ergebnis zurück. Eine
Datei, die eine Prüfung nicht besteht, liefert
422 und wird verworfen — PUT
eine gültige Datei an dieselbe upload_url, solange sie gültig ist, und rufe
complete erneut auf.
409 upload_in_progress heißt, dass gerade
ein anderer complete-Aufruf läuft: Wiederhole in ein paar Sekunden. Erfordert einen
der Scopes images.edit, images.transform oder videos.generate. Kostenlos.Autorisierungen
Organization API key (Authorization: Bearer samsa_sk_...) or OAuth 2.1 access token (Authorization: Bearer samsa_at_...).
Pfadparameter
Antwort
Successful Response
200 body for POST /images/uploads/{image_id}/complete — the usable image.
Use as the source image_id in edits, img2img, variations, resizes, upscales, background removals, vectorizations and image-to-video generations.
Always completed: the file is verified and the image can be used now. Thumbnails are built in the background.
Allowed value:
"completed"The filename given at prepare.
The verified MIME type of the bytes.
Size of the uploaded file in bytes.
Width in pixels, measured from the bytes.
Height in pixels, measured from the bytes.