Images and video / Tasks API
Tasks API
Every call to list image and video models, price a task, create it, follow it and erase it.
Base URL https://api.unaligned.pw/v1. Bodies are JSON. Amounts are in USD, dates in Unix seconds. Every route but the model list takes your API key, as on the other routes. How tasks work, what they cost and what is kept: Images and video.
List the models
https://api.unaligned.pw/v1/media/models
No key needed. kind is image or video; unit is what a price is for: image, second or request. price_from is the lowest price per unit, in USD. uncensored marks the models with fewer limits on content.
One model and its settings
https://api.unaligned.pw/v1/media/models/{id}
No key needed. The ID has slashes in it: put it in the path as it is, as in the sample.
Response
- input object
- A JSON Schema of the settings the model takes: send them as
inputwhen you quote or create a task. - prices array
variantandprice(USD per unit). A model with one price has thedefaultvariant.- variant_fields array
- The settings that choose the variant, such as a resolution.
- quantity_field string
- The setting that counts the units, such as a duration in seconds. Empty when a task is one unit.
- timeout_seconds integer | null
- How long a generation may take before it fails with
timeout.
The other fields are those of the list. A model’s settings are its own: read them before you build a request, and send only those the schema has. A setting the model doesn’t take is refused with a 400 whose message comes from the model.
The models’ status
https://api.unaligned.pw/v1/media/status
No key needed. What the status page shows: every model is checked every 5 minutes, whether it is still listed and answers a price request. That does not prove a generation succeeds.
Response
- state string
upordownat the last check;unknownwhen there was none in the last 15 minutes.- availability number | null
- The share of checks that found it up over 30 days (%);
nullunder 36 checks. - days array
- The last 30 days, oldest first:
day(UTC),polls(checks that day) andup(those that found it up).
The other fields are those of the list. days always holds 30 entries; the sample is cut short.
Price a task
https://api.unaligned.pw/v1/media/quote
What a task with these settings would cost. No task is made and nothing is taken from your balance, but the settings go through the content filter like a task’s, and count in the same minute.
Request
Body
- model string required
- The model’s ID.
- input object required
- The settings, as the model’s
inputschema describes them.
Response
- price number
- What the task would cost, in USD.
- unit string
image,secondorrequest.- quantity number
- How many units the settings make.
- expires_at integer
- Until when this price is expected to hold. A task is priced again when it is created: cap it with
max_price.
Create a task
https://api.unaligned.pw/v1/media/tasks
Checks the settings, prices them, holds the price from your balance and starts the task. The content check and the pricing come first; once the price is held, it answers 202 as soon as the generation service has the task, or after about 25 seconds with the task still queued: follow it with GET. With ?wait=, it waits up to wait seconds in all, or longer if creating the task takes longer. Anything refused before the hold costs nothing.
Request
Body
- model string required
- The model’s ID.
- input object required
- The settings, as the model’s
inputschema describes them. - max_price number
- The most you accept to pay, in USD, from 0.000001 to 1,000,000. Above it, a
409price_changedand nothing is taken. - keep_hours integer
- How long the generation service keeps the settings and results, in hours, from 1: 24 by default. You can ask for less than the default, never for more.
Request
Query
- wait integer
- 1 to 60: wait that many seconds in all for the task to end before answering. The creation’s own time counts in it.
Request
Headers
- Idempotency-Key string
- 1 to 128 visible ASCII characters. Sent again by the same key, it returns the task it made as it stands, with a
200and at once, whateverwaitsays, even if the settings differ: a retry after a network error never makes a second task. The request is still checked first: an unknown model, malformed settings or a field out of range get their error. If that task was erased, a409conflict.
Response
The task, as GET returns it:
- id string
- The task’s ID.
- model string
- The model it runs on.
- price number
- USD. While
settledis false, the price held from your balance; then what the task cost in the end. - settled boolean
- Whether
priceis final. - files array
- The results of a
succeededtask:index,mime,bytes, andwidth,heightorduration(seconds) when known. Download one with itsindex. - error object
- Only on a
failedtask:codeandmessage. See why a task fails. - created_at integer
- Unix seconds.
- deadline_at integer | null
- When the generation service gives up on the task, once known.
- completed_at integer
- When it ended. Absent before.
- expires_at integer
- Until when its
filescan be downloaded. Absent when there are none.
Other answers: a 404 unknown_model; a 400 for a setting the model refuses, a reference to a file you can’t use, a text too long for the content filter or a field out of range (param names it); a 413 when the settings are over 256 KiB; a 429 when the account’s quotes and new tasks are paused after refusals; a 503 when the generation service or the filter can’t be reached, with nothing charged.
Follow a task
https://api.unaligned.pw/v1/media/tasks/{id}
The task, if this key created it. With ?wait=, the answer comes as soon as the task ends, or when the time is up: one call a minute is enough to follow it.
Request
Query
- wait integer
- 1 to 60: seconds to wait for the task to end. A key can have 4 such calls waiting at once; a fifth is answered at once.
The fields are those of a new task. A task of another key, an erased task and an unknown ID all get the same 404.
List your tasks
https://api.unaligned.pw/v1/media/tasks
This key’s latest tasks, newest first, as {"tasks": […]}. When more are left, the answer also carries next: pass it as before to read the following page.
Request
Query
- limit integer
- 1 to 100. Default 20.
- before string
- The
nextof the page before: the tasks older than the last one it listed. Still valid if that task was erased meanwhile. - since integer
- Unix seconds: only the tasks created at or after this time.
- source string
site: only the tasks made on the website, when signed in there. Refused with an API key, which sees only its own tasks.
Response
Erase a task
https://api.unaligned.pw/v1/media/tasks/{id}
Erases a task that has ended: the generation service is asked to delete its settings and results at once (if it does not, they go at their normal expiry). Answers 204, no body. From then on, no route shows the task.