Katama·Docs
StatsWorkspace ↗

Image generation

One endpoint, one body, one receipt. Every run is priced before it starts, and the price you were quoted is the price you are charged.

Endpoint

POST /api/generate

Authenticate as described in Authentication. The same endpoint serves images, video and chat — kind decides which.

Request body

FieldTypeRequiredNotes
kindstringyesUse "image".
promptstringyesChecked by the safety guard before anything is priced or run.
modelstringyesOne of the ids below. An unknown id is refused with unknown_cost — nothing runs, nothing is charged.
qualitystringnoModel-specific. Falls back to the model default.
aspectstringnoFor example "16:9" or "9:16". Snapped server-side to what the model actually supports.
The field is quality, not resolution. A body carrying resolution is accepted, but the value is ignored and the model default is used instead — silently. If your output looks different from what you asked for, check this first.

Models and what they cost

Read straight from the pricing table the billing code uses, so this list cannot drift.

Model idAlso accepted asCredits per image
image-fluxflux3
kie-z-image3
kie-seedream-44
image-flux-dev5
image-qwen5
gpt-image-1gpt-image6
image-seedream-36
image-nano-banana8
image-nano-banana-28
image-recraft-v39
image-flux-ultra12
image-ideogram-v215
image-nano-pronano-pro17
gpt-image-1-high17
image-gpt-highgpt-high22

Example

curl https://katama.ai/api/generate \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "image",
    "prompt": "a small red paper crane on a plain grey table, soft light",
    "model": "flux"
  }'

Response

The call returns a generation record. When it comes back with status: "succeeded", outputUrl is ready to fetch.

{
  "generation": {
    "id": "dabb8909-369e-4118-9b89-186a3da81c5a",
    "kind": "image",
    "model": "flux",
    "status": "succeeded",
    "outputUrl": "https://…/PPhtLdquFOEu.jpg",
    "creditsCharged": 3,
    "error": null
  }
}

A longer run may return status: "queued" or "running" first. Poll the generation until it settles. While it runs, the credits sit in a hold; the hold is released if the run fails, so a failed generation costs nothing.

Errors worth handling

CodeHTTPWhat it means
unknown_cost400No price is defined for that model id. Nothing ran.
insufficient_credits402The quoted price exceeds the balance. Top up, then retry.
unauthorized401No valid session or API key — see Authentication.

Next: Video generation · Plans & credits