curl --request POST \
--url https://api.samsa.ai/public/v1/models \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Acme Brand Style",
"category": "style",
"images": [
{
"url": "https://cdn.example.com/ref-0.png",
"base64": "<string>",
"mime_type": "image/png"
}
],
"instruction": "Use for hero banners and social posts.",
"webhook_url": "https://example.com/webhooks/samsa"
}
'import requests
url = "https://api.samsa.ai/public/v1/models"
payload = {
"name": "Acme Brand Style",
"category": "style",
"images": [
{
"url": "https://cdn.example.com/ref-0.png",
"base64": "<string>",
"mime_type": "image/png"
}
],
"instruction": "Use for hero banners and social posts.",
"webhook_url": "https://example.com/webhooks/samsa"
}
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({
name: 'Acme Brand Style',
category: 'style',
images: [
{
url: 'https://cdn.example.com/ref-0.png',
base64: '<string>',
mime_type: 'image/png'
}
],
instruction: 'Use for hero banners and social posts.',
webhook_url: 'https://example.com/webhooks/samsa'
})
};
fetch('https://api.samsa.ai/public/v1/models', 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/models",
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([
'name' => 'Acme Brand Style',
'category' => 'style',
'images' => [
[
'url' => 'https://cdn.example.com/ref-0.png',
'base64' => '<string>',
'mime_type' => 'image/png'
]
],
'instruction' => 'Use for hero banners and social posts.',
'webhook_url' => 'https://example.com/webhooks/samsa'
]),
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/models"
payload := strings.NewReader("{\n \"name\": \"Acme Brand Style\",\n \"category\": \"style\",\n \"images\": [\n {\n \"url\": \"https://cdn.example.com/ref-0.png\",\n \"base64\": \"<string>\",\n \"mime_type\": \"image/png\"\n }\n ],\n \"instruction\": \"Use for hero banners and social posts.\",\n \"webhook_url\": \"https://example.com/webhooks/samsa\"\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/models")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Acme Brand Style\",\n \"category\": \"style\",\n \"images\": [\n {\n \"url\": \"https://cdn.example.com/ref-0.png\",\n \"base64\": \"<string>\",\n \"mime_type\": \"image/png\"\n }\n ],\n \"instruction\": \"Use for hero banners and social posts.\",\n \"webhook_url\": \"https://example.com/webhooks/samsa\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.samsa.ai/public/v1/models")
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 \"name\": \"Acme Brand Style\",\n \"category\": \"style\",\n \"images\": [\n {\n \"url\": \"https://cdn.example.com/ref-0.png\",\n \"base64\": \"<string>\",\n \"mime_type\": \"image/png\"\n }\n ],\n \"instruction\": \"Use for hero banners and social posts.\",\n \"webhook_url\": \"https://example.com/webhooks/samsa\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "pending",
"estimated_credits": 0
}{
"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"
}
}Créer un modèle
Crée un modèle à partir de 1 à 10 images de référence fournies en URLs ou en base64 inline.
curl --request POST \
--url https://api.samsa.ai/public/v1/models \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Acme Brand Style",
"category": "style",
"images": [
{
"url": "https://cdn.example.com/ref-0.png",
"base64": "<string>",
"mime_type": "image/png"
}
],
"instruction": "Use for hero banners and social posts.",
"webhook_url": "https://example.com/webhooks/samsa"
}
'import requests
url = "https://api.samsa.ai/public/v1/models"
payload = {
"name": "Acme Brand Style",
"category": "style",
"images": [
{
"url": "https://cdn.example.com/ref-0.png",
"base64": "<string>",
"mime_type": "image/png"
}
],
"instruction": "Use for hero banners and social posts.",
"webhook_url": "https://example.com/webhooks/samsa"
}
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({
name: 'Acme Brand Style',
category: 'style',
images: [
{
url: 'https://cdn.example.com/ref-0.png',
base64: '<string>',
mime_type: 'image/png'
}
],
instruction: 'Use for hero banners and social posts.',
webhook_url: 'https://example.com/webhooks/samsa'
})
};
fetch('https://api.samsa.ai/public/v1/models', 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/models",
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([
'name' => 'Acme Brand Style',
'category' => 'style',
'images' => [
[
'url' => 'https://cdn.example.com/ref-0.png',
'base64' => '<string>',
'mime_type' => 'image/png'
]
],
'instruction' => 'Use for hero banners and social posts.',
'webhook_url' => 'https://example.com/webhooks/samsa'
]),
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/models"
payload := strings.NewReader("{\n \"name\": \"Acme Brand Style\",\n \"category\": \"style\",\n \"images\": [\n {\n \"url\": \"https://cdn.example.com/ref-0.png\",\n \"base64\": \"<string>\",\n \"mime_type\": \"image/png\"\n }\n ],\n \"instruction\": \"Use for hero banners and social posts.\",\n \"webhook_url\": \"https://example.com/webhooks/samsa\"\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/models")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Acme Brand Style\",\n \"category\": \"style\",\n \"images\": [\n {\n \"url\": \"https://cdn.example.com/ref-0.png\",\n \"base64\": \"<string>\",\n \"mime_type\": \"image/png\"\n }\n ],\n \"instruction\": \"Use for hero banners and social posts.\",\n \"webhook_url\": \"https://example.com/webhooks/samsa\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.samsa.ai/public/v1/models")
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 \"name\": \"Acme Brand Style\",\n \"category\": \"style\",\n \"images\": [\n {\n \"url\": \"https://cdn.example.com/ref-0.png\",\n \"base64\": \"<string>\",\n \"mime_type\": \"image/png\"\n }\n ],\n \"instruction\": \"Use for hero banners and social posts.\",\n \"webhook_url\": \"https://example.com/webhooks/samsa\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"status": "pending",
"estimated_credits": 0
}{
"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"
}
}202 Accepted avec un id de modèle ; interroge
GET /models/{id}/status jusqu’à completed.
Chacune des 1 à 10 images est soit une url https (téléchargée côté serveur
sous protections SSRF) soit du base64 inline + mime_type (image/jpeg, image/png,
ou image/webp, ≤ 10 Mo chacune). L’instruction optionnelle est la guidance toujours appliquée du
modèle — injectée comme directive obligatoire (“MUST FOLLOW”) dans chaque génération qui compose le modèle,
pas une simple note d’usage (modifie-la plus tard avec
PATCH /models/{id}). Nécessite le scope models.write.
Exemple : créer un modèle de style à partir d’URLs
curl -X POST https://api.samsa.ai/public/v1/models \
-H "Authorization: Bearer $SAMSA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Brand Style",
"category": "style",
"images": [
{ "url": "https://cdn.example.com/ref-0.png" },
{ "url": "https://cdn.example.com/ref-1.png" },
{ "url": "https://cdn.example.com/ref-2.png" }
],
"instruction": "Always render on a clean, seamless white background.",
"webhook_url": "https://api.example.com/hooks/samsa"
}'
{
"name": "Acme Brand Style",
"category": "style",
"images": [
{ "url": "https://cdn.example.com/ref-0.png" },
{ "url": "https://cdn.example.com/ref-1.png" },
{ "url": "https://cdn.example.com/ref-2.png" }
],
"instruction": "Always render on a clean, seamless white background.",
"webhook_url": "https://api.example.com/hooks/samsa"
}
url soit du base64 + mime_type, pas les deux. Pour les
fichiers volumineux, utilise plutôt le flux presigned upload.
category vaut l’une des valeurs style, object, person, setting.Autorisations
Organization API key as a bearer token: Authorization: Bearer samsa_sk_....
Corps
POST /models body — inline base64 and/or https-URL reference images.
1 - 100"Acme Brand Style"
Model category — one of style, object, person, setting.
style, object, person, setting "style"
1-10 reference images, each a url or inline base64+mime_type.
1 - 10 elementsShow child attributes
Show child attributes
Optional free-text guidance for how to use the model.
8000"Use for hero banners and social posts."
Optional https webhook notified once on terminal status (signed per the webhook signature scheme; see the webhooks docs).
"https://example.com/webhooks/samsa"
Réponse
Successful Response
202 body for POST /models and POST /models/{id}/complete (ADR §7.1).
The created model's id — poll GET /models/{id}/status.
Initial status: pending (create) or processing (complete).
pending, processing, completed, failed "pending"
Credits the finished job will cost (model creation is free = 0).
0

