Create an API key and generate your first image with a trained style model in five steps.
This guide takes you from zero to a finished image in five steps: create a key,
verify it, submit a generation, poll for the result, and download it. Every call
targets the base URL:
https://api.samsa.ai/public/v1
The examples use a fake key (samsa_sk_example…) and placeholder ids. Replace
them with your own. Store your key in an environment variable so it never lands
in source control:
API keys are organization-owned and can only be created by an organization
admin (OWNER or ADMIN).
1
Open your organization settings
In the Samsa app, go to your organization settings and
open the API Keys tab.
2
Create a key
Give the key a name. By default it is granted all scopes
(images.generate, images.edit, videos.generate, models.read,
models.write, usage.read); narrow them if the integration needs less.
You can also set an optional expiry.
3
Copy the key now
The full key (samsa_sk_…) is shown exactly once, at creation. Samsa
stores only a hash and can never display it again. Copy it immediately and
keep it somewhere safe — if you lose it, revoke the key and create a new one.
Keys act for their organization: credits are drawn from the organization’s
pool, and any images or videos you generate appear in the app under the account
of the admin who created the key.
GET /me is the fastest way to confirm a key works. It returns the key’s
organization, its safe metadata (prefix, scopes, expiry — never the secret), and
the organization’s available credit balance.
Submit a prompt to POST /images/generations. Here we also compose one of the
organization’s trained style models by passing its id or name as style_id —
a name resolves to a model visible to you. You can combine object_ids,
person_ids, setting_ids, and a color_palette_id the same way (the color
palette is referenced by id only). The request returns 202 immediately with a job id; the image is
produced asynchronously.
curl -X POST https://api.samsa.ai/public/v1/images/generations \ -H "Authorization: Bearer $SAMSA_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "prompt": "A minimalist product shot of a ceramic mug on linen, soft daylight", "style_id": "2b9d1f7a-3c4e-4a5b-9c8d-0e1f2a3b4c5d", "aspect_ratio": "1:1", "resolution": "1K", "num_outputs": 1 }'
payload = { "prompt": "A minimalist product shot of a ceramic mug on linen, soft daylight", "style_id": "2b9d1f7a-3c4e-4a5b-9c8d-0e1f2a3b4c5d", "aspect_ratio": "1:1", "resolution": "1K", "num_outputs": 1,}resp = requests.post( f"{BASE_URL}/images/generations", headers={**HEADERS, "Content-Type": "application/json"}, json=payload,)resp.raise_for_status()job = resp.json()generation_id = job["id"]print(job)
The default engine is nano_banana_pro (pass engine to choose
nano_banana_2). num_outputs defaults to 1; each output costs
5 credits at 1K, scaling with resolution (1K ×1, 2K ×2, 4K ×4). The
style_id — an id or a name — must reference a completed model visible to you.