Skip to Content

Generate an image

Start an image, wait for it, download it.

The flow

POST /v1/generations with a new Idempotency-Key (a UUID). Send the same key when you retry the same image. The answer is 202 with id and status: "queued".

GET /v1/generations/{id}?wait=10 until status is done. Each call answers as soon as the status changes (the run starts or ends), or after 10 seconds with no change.

Download result.image_url when the run is done: it is deleted after the first download, or 10 minutes after the run if nobody downloads it. TensorFactory keeps the run's settings, not its prompt or the image, so save the file. Once it is deleted, the generation shows result.expired: true with no link, and the old link answers 410 file_expired.

# 1. Start an image: the answer is 202 with its id and status "queued"
curl https://tensorfactory.ai/v1/generations \
  -H "Authorization: Bearer $TENSORFACTORY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"model": "qwen-image/text-to-image", "prompt": "A studio packshot of a frosted glass serum bottle with a gold dropper on a pale stone plinth, soft diffused light, minimal beige background.", "aspect_ratio": "1:1"}'

# 2. Poll until status is "done": each call answers when the status changes, or after 10 seconds
curl "https://tensorfactory.ai/v1/generations/$ID?wait=10" \
  -H "Authorization: Bearer $TENSORFACTORY_API_KEY"

# 3. Download the image
curl -o image.png "$IMAGE_URL"

After a quiet spell, the first image is accepted and waits queued while a GPU worker starts, which takes a few minutes. Then it runs. Keep polling. Later images are quick.

A finished generation

{
  "id": "0b8c6f0e-5d1a-4a3e-9c61-2f7d8e4b9a10",
  "status": "done",
  "model": "qwen-image/text-to-image",
  "prompt": "A brass microscope on a graph-paper notebook, warm window light",
  "aspect_ratio": "1:1",
  "seed": 1834920211,
  "steps": 4,
  "mode": "fast",
  "image": null,
  "price_usd": 0.003,
  "usage": {
    "execution_s": 2.1,
    "queue_s": 0.132,
    "gpu_cost_usd": 0.00105,
    "switch_s": 0
  },
  "result": {
    "image_url": "https://tensorfactory.ai/v1/files/outputs/0b8c6f0e-5d1a-4a3e-9c61-2f7d8e4b9a10.png?expires=1794046209&signature=...",
    "width": 1024,
    "height": 1024,
    "expires_at": "2026-11-07T10:10:09.000Z",
    "expired": false,
    "available_until": "2026-11-07T10:10:09.700Z"
  },
  "error": null,
  "created_at": "2026-11-07T10:00:00.000Z",
  "started_at": "2026-11-07T10:00:01.200Z",
  "finished_at": "2026-11-07T10:00:09.700Z"
}

Modes

Send mode to choose how the image is made:

ModeWhat it does
fast4 steps. The quickest and cheapest.
maxThe full model at 50 steps. Slow.

Leave mode out for auto, which takes fast (4 steps) for every prompt. Send steps instead of mode to set the count yourself, but not both: steps with any mode other than auto is refused. Each mode's price is in modes in GET /v1/models, and the finished generation's mode says which one ran.

Photos that look real

Without a style named, many subjects come back as a polished render rather than a photograph: food, landscapes, products, a figure in a space suit. More steps don't change that. For a photo, end your prompt with "Realistic photography, natural light, true-to-life colors." Prompts that ask for an illustration stay illustrations. The playground's random photo ideas end with this sentence.

Text to image draws at 1K unless you send resolution: 1024x1024 at 1:1. Until 2026-12-03 it drew at 1.3K, 1328x1328. Send resolution: "1.3K" or "2K" for a larger image. Each size's price is on Pricing.

See Create a generation for every field and option, such as aspect_ratio, resolution, seed, mode, steps and output_format.

On this page