Query tasks
Look up a task’s status and result with the task_id you got when submitting — images and videos alike. Batch queries too.
https://api.jiufeng.ai/v1/tasks/{task_id}data.statushas only four values:pending/processing/completed/failed; the last two are finalpendingdoes not prove a task exists: an unknown id returnspendingfor 15 minutes after creation, then404— stop polling on404- Result files are kept for 30 days (see
expires_atfor the exact time); copy them before they expire
Rather not poll? Pass webhook when submitting and the platform pushes once when the task reaches a final state — see Webhooks.
Status values
data.status has exactly four public values:
| status | Meaning | Terminal |
|---|---|---|
pending | Submitted / queued | No |
processing | Generating | No |
completed | Succeeded | Yes |
failed | Failed (credits refunded) | Yes |
pendingdoes not prove the task exists. A freshly submitted task may not be written yet, so atask_idthat cannot be found within 15 minutes of its creation also returnspending(message: "任务排队中,请稍后查询"). Use the submit response to confirm a submission succeeded.
Not found and errors
| Situation | Response | What to do |
|---|---|---|
task_id not found within 15 minutes of creation (still in the write window) | 200, status = pending | Keep polling |
| Still not found after 15 minutes, a timestamp in the future, or a task that is not your account's | 404, error.code = task_not_found (a task that is not your account’s looks exactly like one that does not exist) | Stop polling; check the task_id and API key |
Many lookups of not-found task_ids in a short time | Not-found ids return 429 with Retry-After; your own tasks still return normally | Back off per Retry-After; check whether the wrong key or task_id source is being used |
| Past the result retention period | 400 (task expired) | Stop polling |
Response fields (data)
| Field | Type | Description |
|---|---|---|
id | string | Task id (the same task_id returned on submission) |
status | string | pending / processing / completed / failed |
progress | integer | Progress 0–100 |
created | integer | Submission time (Unix seconds) |
estimated_time | integer | Estimated duration (seconds) |
completed | integer | Completion time (Unix seconds; terminal states only) |
actual_time | integer | Actual duration (seconds; terminal states only) |
credits_cost | number | Credits charged for this task (decimal, e.g. 0.08). Usually 0 on failure (exception: see “Failures and refunds” below) |
cost | number | The same charge in US dollars (credits_cost = cost × 10) |
result | object | Present on success (see below) |
error | object | Present on failure: { message, type, param, code } |
result (success)
| Field | Type | Description |
|---|---|---|
images | object[] | Image tasks. Each item: url (string[]), expires_at (deadline, Unix seconds) |
videos | object[] | Video tasks. Each item: url (string[]), expires_at (deadline, Unix seconds) |
Read every URL with result.images.flatMap(i => i.url) (or result.videos[0].url[0] for a video). Result files are kept for 30 days (the exact deadline is expires_at) — download or re-host them before then.
Video tasks look the same with result.videos; see Generate videos.
Failures and refunds
Failed tasks are refunded automatically — no request needed. One exception: when the upstream model provider's own safety system rejects the prompt after reading it, the input part may still be charged and shows up in credits_cost.
Polling tips
- Exponential backoff: images usually finish in seconds — start around 1 s and stretch to ~8 s. Videos take longer — poll every 5–30 s.
- Result files are kept for 30 days, then deleted automatically (the exact deadline is
expires_at) — download or re-host them to your own storage before then. - Stop immediately on
404(the task does not exist or is not your account's); on429, back off perRetry-After. - Put a ceiling on polling (e.g. 5 minutes for images, 20 for video). A
task_idwith one mistyped character returnspendingfor 15 minutes after its creation time, then404. - To skip polling entirely, use Webhook callbacks.
Batch query
https://api.jiufeng.ai/v1/tasks/batchQuery many tasks at once (simplified: each task returns only id and status, no result). Send task_ids (an array of task_id, default limit 500). Beyond the four standard states, batch may also return invalid_id (malformed) / expired (past retention) / not_found (does not exist or is not your account's — stop querying that id) / rate_limited (too many lookups of not-found ids in a short time; recovers in about 10 minutes; your own tasks are unaffected) for the corresponding id. As with single queries, an id not found within 15 minutes of creation returns pending.
To fetch result URLs, call GET /v1/tasks/{task_id} on each completed task.