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.

GEThttps://api.jiufeng.ai/v1/tasks/{task_id}
3 things to know before polling
  1. data.status has only four values: pending / processing / completed / failed; the last two are final
  2. pending does not prove a task exists: an unknown id returns pending for 15 minutes after creation, then 404 — stop polling on 404
  3. Result files are kept for 30 days (see expires_at for 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:

statusMeaningTerminal
pendingSubmitted / queuedNo
processingGeneratingNo
completedSucceededYes
failedFailed (credits refunded)Yes

pending does not prove the task exists. A freshly submitted task may not be written yet, so a task_id that cannot be found within 15 minutes of its creation also returns pending (message: "任务排队中,请稍后查询"). Use the submit response to confirm a submission succeeded.

Not found and errors

SituationResponseWhat to do
task_id not found within 15 minutes of creation (still in the write window)200, status = pendingKeep polling
Still not found after 15 minutes, a timestamp in the future, or a task that is not your account's404, 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 timeNot-found ids return 429 with Retry-After; your own tasks still return normallyBack off per Retry-After; check whether the wrong key or task_id source is being used
Past the result retention period400 (task expired)Stop polling

Response fields (data)

FieldTypeDescription
idstringTask id (the same task_id returned on submission)
statusstringpending / processing / completed / failed
progressintegerProgress 0–100
createdintegerSubmission time (Unix seconds)
estimated_timeintegerEstimated duration (seconds)
completedintegerCompletion time (Unix seconds; terminal states only)
actual_timeintegerActual duration (seconds; terminal states only)
credits_costnumberCredits charged for this task (decimal, e.g. 0.08). Usually 0 on failure (exception: see “Failures and refunds” below)
costnumberThe same charge in US dollars (credits_cost = cost × 10)
resultobjectPresent on success (see below)
errorobjectPresent on failure: { message, type, param, code }

result (success)

FieldTypeDescription
imagesobject[]Image tasks. Each item: url (string[]), expires_at (deadline, Unix seconds)
videosobject[]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); on 429, back off per Retry-After.
  • Put a ceiling on polling (e.g. 5 minutes for images, 20 for video). A task_id with one mistyped character returns pending for 15 minutes after its creation time, then 404.
  • To skip polling entirely, use Webhook callbacks.

Batch query

POSThttps://api.jiufeng.ai/v1/tasks/batch

Query 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.

curl https://api.jiufeng.ai/v1/tasks/batch \
  -H "Authorization: Bearer sk-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "task_ids": ["task_01M0...", "task_02N1..."] }'
{
  "code": 200,
  "data": [
    { "id": "task_01M0...", "status": "completed" },
    { "id": "task_02N1...", "status": "processing" }
  ]
}

To fetch result URLs, call GET /v1/tasks/{task_id} on each completed task.

Query tasks · Jiufeng Open API