staqlydocs
REST APIAPI referenceMedia

Start an AI request

Start an AI request (media:write)

Every request sends Authorization: Bearer ...: the access token in local mode, an API key stk_... in cloud mode. Use Send to try it against your cloud instance with your API key.

POST
/v1/ai/jobs

Queues one AI operation (GET /v1/ai lists the ones this server offers); poll GET /v1/ai/jobs/{id} until it has succeeded, failed or was cancelled. Send the settings before the files. A repeated Idempotency-Key, or the same request from the same person while it still runs, answers 200 with that earlier job instead of starting another. At most 30 requests per 10 minutes and 4 running at once per workspace (429); a request that would pass the workspace's monthly AI limit is refused with 402 ai_limit_reached.

Authorization

headerAuthorizationBearer <token>

API key (stk_...), or in the Community Edition the access token (stk_local_...)

Header Parameters

Idempotency-Key?string
Lengthlength <= 200

Request Body

multipart/form-data
  1. body
operation*string
Value in"generate""edit""inpaint""erase""expand""remove_background""replace_background""upscale""enhance""text_to_video""image_to_video"
prompt?string

Required or optional as the operation's prompt says; ignored when it is none

Lengthlength <= 4000
width?integer

generate: the picture's width (default 1024, rounded down to a multiple of 16)

Range256 <= value <= 2048
height?integer
Range256 <= value <= 2048
duration?integer

Videos: seconds (default 5)

Value in510
aspect_ratio?string

text_to_video (default 16:9)

Value in"16:9""9:16""1:1"
canvas_width?integer

expand: the new size

Range64 <= value <= 4096
canvas_height?integer
Range64 <= value <= 4096
image_x?integer

expand: where the picture sits in the new size

Range0 <= value
image_y?integer
Range0 <= value
place_width?integer

expand: the picture's size there (default its own)

place_height?integer
image?file

PNG, JPEG or WebP, at most 20 MB and 4096 px a side (PNG for upscale)

Formatbinary
mask?file

inpaint, erase: a PNG of the picture's size; white marks the area to change

Formatbinary

Response Body

The earlier job that answers this request

application/json
  1. response

One AI request

id*string
operation*string
kind*string
Value in"image""video"
status*string
Value in"queued""running""succeeded""failed""canceled"
provider*string

The provider that runs it; empty until it is sent

model*string
fallback_from*string

The provider that did not take it first; empty: none

error*null|
result*null|
media_id*string

The library file it was kept as; empty until accepted

estimated_cost_usd*number

Estimated from the catalog's list prices; 0 when nothing was charged

duration_ms*integer
created_at*string
Formatdate-time
finished_at*string

Empty while it runs

Example Request
curl -X POST 'https://staqly.example.com/v1/ai/jobs' \  -F 'operation=generate'
Example Response
{  "id": "string",  "operation": "string",  "kind": "image",  "status": "queued",  "provider": "string",  "model": "string",  "fallback_from": "string",  "error": null,  "result": null,  "media_id": "string",  "estimated_cost_usd": 0,  "duration_ms": 0,  "created_at": "2019-08-24T14:15:22Z",  "finished_at": "string"}