Skip to Content
API reference

Create a generation

POST
/v1/generations

Starts an image and answers 202 with the generation, usually status: "queued". Then get it with GET /v1/generations/{id}?wait=10 until it is over.

Send a new Idempotency-Key for each new image and the same key when you retry the same request: a retry answers with the generation the first request made. Fields not listed here are refused with 400. A prompt that names a real, identifiable person is still accepted, then the run ends failed with real_person, charged nothing.

When no GPU worker has room (the first image after a quiet spell, or every running worker's line full), the run is still accepted: it stays queued, oldest first, until a worker can take it (a fresh worker takes several minutes to start) and then runs. One that gets no worker within 20 minutes ends failed with timed_out, charged nothing. 503 unavailable means the run couldn't be handed to a GPU worker at all. Nothing is charged, so retry with the same Idempotency-Key. The line has no length limit.

Authorization

apiKey
headerAuthorizationBearer <tf_...>

Your API key from API keys, sent as Authorization: Bearer $TENSORFACTORY_API_KEY. Keep it on your server.

Header Parameters

Idempotency-Key*string

A new random value (a UUID) for each new image, and the same one when you retry. Up to 200 characters. The same key with a different body is 409 idempotency_conflict.

Lengthlength <= 200

Request Body

application/json
  1. body
model*string

The model. qwen-image/text-to-image draws from a prompt, qwen-image/edit changes your uploads, qwen-image/camera-angle shows a photo's subject from another angle, qwen-image/inpaint redraws the masked part of an image, or extends it past its edges. Each model takes only its own fields: any other is refused with 400 naming it. Camera angle and inpaint take no steps or mode: camera angle and a mask fill run 8 steps, an outpaint 4.

Value in"qwen-image/text-to-image""qwen-image/edit""qwen-image/camera-angle""qwen-image/inpaint"
prompt?string

Required, except for camera angle, which takes none. What the image shows, or the change to make, in plain sentences. The model reads the first 512 tokens. Put words that should appear in the image in double quotes and say where they sit. Inpaint: the instruction, such as "Remove the man" or "Extend the beach to the left".

Length1 <= length <= 2000
aspect_ratio?string

The image's shape. Text to image: 1:1 (default), 16:9, 9:16, 4:3, 3:4 or 4:5. Edit and camera angle: auto (default: the result keeps the shape of image, held between 1:2 and 2:1), 1:1, 16:9 or 9:16. Not for inpaint: its result is the image's own size, plus any margins.

Value in"1:1""16:9""9:16""4:3""3:4""4:5""auto"
resolution?string

The size the model draws at. Larger costs more, and every shape of a size costs the same (price_table_usd in GET /v1/models). Text to image: 1K (default since 2026-12-03), 1.3K or 2K. Edit: 1K (default) or 2K. Camera angle: 1K only. Not for inpaint. The pixel sizes per shape are in sizes_by_resolution and on the Limits page.

Value in"1K""1.3K""2K"
seed?integer

The same seed and inputs repeat the image exactly on the same GPU machine. On another machine it can differ slightly. Random when left out.

Range0 <= value <= 2147483647
steps?integer

Text to image and edit only. Denoising steps, to set the count yourself. Leave it out to let mode choose. Priced in bands, 1 to 4, 5 to 8, 9 to 20 and 21 to 50 (price_table_usd in GET /v1/models). Send steps or mode, not both: sending both answers 400.

Range1 <= value <= 50
mode?string

Text to image and edit only. How the run is made. Left out (and no steps): auto. Text to image: auto always takes fast. Edit: auto reads the prompt, and an edit about a person (their face, hair, skin, clothes or accessories) at 16:9 or 9:16, 1K, with one or two images takes detail. Any other edit takes fast. If auto cannot read the prompt in time, it takes fast. fast: 4 steps, quickest and cheapest. max: the full model at 50 steps, slow. detail (edit only): draws the edit larger and shrinks it, for sharper faces, only for aspect_ratio 16:9 or 9:16 at resolution 1K. Send steps or a mode, not both (auto with steps runs your step count). A mode the model or shape cannot take answers 400 on mode. Each model's modes and prices are in GET /v1/models.

Default"auto"
Value in"auto""fast""max""detail"
output_format?string

png (lossless), jpeg (quality 95) or webp (quality 90). jpeg and webp are smaller and arrive sooner.

Default"png"
Value in"png""jpeg""webp"
image?string

Edit, camera angle and inpaint, required there. The image to change (picture 1 in an edit's prompt), as any of: an https link to a JPEG, PNG or WebP, the image itself as a data: URL (data:image/png;base64,...), or an upload's asset_id from POST /v1/uploads.

image_2?string

Edit only. A second image the edit uses (picture 2), such as a garment or a logo, in any of the same forms.

image_3?string

Edit only. A third image (picture 3), in any of the same forms. Needs image_2. All images together are at most 7 MiB.

transparent_background?boolean

Edit and camera angle only. true: the result comes back with its background removed, the main subject on transparency. Needs output_format png or webp. It adds nothing to the listed price.

Defaultfalse
horizontal_angle?number

Camera angle only. Degrees around the subject: 0 is the subject's own front, not the photo's view (a car photographed from the side, at 0, shows its grille), 90 its right side, 180 its back, 270 its left side. Drawn at the nearest 45 degrees.

Range0 <= value <= 360
Default0
vertical_angle?number

Camera angle only. The camera's height in degrees: -30 low, looking up, 0 eye level, 30 elevated, 60 high, looking down. Drawn at the nearest of these four. 61 to 90 is drawn as 60.

Range-30 <= value <= 90
Default0
zoom?number

Camera angle only. How close the camera is, 0 wide, 5 medium, 10 close-up. Drawn at the nearest of the three.

Range0 <= value <= 10
Default5
mask?string

Inpaint only, and then mask or outpaint, not both. Where to redraw, in any of the forms image takes, the same pixel size as image: white (or transparent) is redrawn, black is kept as it is. The image itself is at most 8192 pixels a side and 16,777,216 pixels.

outpaint?

Inpaint only, and then outpaint or mask, not both. Pixels to add on each side of the image, any of them, the rest are 0, at least 1 in all. The result is at most twice the image on each side, 8192 pixels a side and 16,777,216 pixels.

end_user?EndUser

Optional. An opaque id you choose for your own user: 1 to 128 letters, digits, dots, dashes, underscores, colons or @. Never an email. It only lets you delete that user's data later with DELETE /v1/end-users/{end_user}. It is not part of the idempotency check and is never returned.

Match^[A-Za-z0-9._:@-]{1,128}$

Response Body

The generation, new or the one this Idempotency-Key already made.

application/json
  1. response
id*string

The generation's id.

Formatuuid
status*string

queued and running are not over yet. done, failed and cancelled are final.

Value in"queued""running""done""failed""cancelled"
model*string

The model id.

prompt*|

The prompt as you sent it, only while the run is queued or running. It is not kept once the run ends, and is then null. Camera angle: the pose drawn, in words (camera.pose), always.

aspect_ratio*string

The shape you asked for. auto for inpaint.

seed*integer

The seed the run used: the one you sent, or the random one we drew, so you can make the same image again.

steps*integer

Denoising steps.

mode?|

The mode the run used (auto resolved to the mode it picked), custom when you sent steps, null for camera angle, inpaint and runs made before modes.

image*|

The edited upload's asset_id.

image_2*|

The second upload the edit used.

image_3*|

The third upload the edit used.

transparent_background*boolean

Whether the background was asked to be removed.

camera?

Camera angle only. The pose drawn, your three numbers each at the nearest pose the model draws.

mask?|

Inpaint only. The mask's upload asset_id, null for an outpaint.

outpaint?|

Inpaint only. The margins added, {left, top, right, bottom}, null for a mask. result.width and result.height are the image with them.

price_usd*number

What the run costs. While queued or running, the table price it will be charged; once done, the price charged; 0 for a failed or cancelled run. See Pricing.

usage*|

Once done, the run's GPU time.

result*|

Once done, the files the run made. Download them 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 files.

error*|

When the run failed: type is model_error, timed_out, node_lost (the GPU stopped answering), expired (the result was not read in time), background_removal_failed, bad_output (the result could not be stored, or the GPU that took a camera angle or inpaint run couldn't run that model yet) or real_person (the prompt names a real, identifiable person). A failed run costs nothing. Run it again.

created_at*string
Formatdate-time
started_at*|
Formatdate-time
finished_at*|
Formatdate-time
curl -X POST 'https://tensorfactory.ai/v1/generations' \  -H 'Idempotency-Key: 7d9f1c2a-3b4e-4c5d-8e6f-0a1b2c3d4e5f' \  -H 'Content-Type: application/json' \  -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.",  "mode": "auto",  "aspect_ratio": "1:1"}'
Example Response
{  "id": "0b8c6f0e-5d1a-4a3e-9c61-2f7d8e4b9a10",  "status": "queued",  "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",  "seed": 1873024519,  "steps": 4,  "mode": "fast",  "image": null,  "image_2": null,  "image_3": null,  "transparent_background": false,  "price_usd": 0.003,  "usage": null,  "result": null,  "error": null,  "created_at": "2026-11-07T10:00:00.000Z",  "started_at": null,  "finished_at": null}