Skip to content

Get Task Result

After you submit an async image or video job, Pixapi returns a task id. Use that id with GET /v1/tasks/{id} to read status, progress, and the final media URLs.

For how to submit async work, see Async Media Tasks.

Endpoint

MethodPathDescription
GET/v1/tasks/{id}Fetch task status and result

Authentication: Authorization: Bearer <API_KEY>

You can only query tasks created by the same API key / account. Unknown ids return 404.

Request

bash
curl --request GET \
  --url 'https://api.pixapi.ai/v1/tasks/task_01KPQ7J7DWB7QZ3WCEK3YVPBRA' \
  --header 'Authorization: Bearer $PIXAPI_KEY'

Path parameter:

FieldTypeRequiredDescription
idstringYesTask id returned when the async job was submitted (for example task_...).

Status values

StatusMeaning
submittedPixapi accepted the task and queued it.
processingUpstream generation is in progress.
completedFinished successfully. Read result.data[].url.
failedFinished with an error. Read error.

Poll until status is completed or failed. While the task is in progress, result is null.

In-progress response

json
{
  "id": "task_01KPQ7J7DWB7QZ3WCEK3YVPBRA",
  "status": "processing",
  "credits_cost": 64,
  "model": "veo3.1-fast",
  "progress": 40,
  "result": null,
  "created": 1703884800
}

Completed response

json
{
  "id": "task_01KPQ7J7DWB7QZ3WCEK3YVPBRA",
  "status": "completed",
  "credits_cost": 64,
  "model": "veo3.1-fast",
  "progress": 100,
  "result": {
    "type": "video",
    "data": [
      {
        "url": "https://cdn.example.com/output.mp4"
      }
    ]
  },
  "created": 1703884800,
  "completed": 1703884880
}

For image tasks, result.type is image and each data[] item still exposes a public url.

Failed response

json
{
  "id": "task_01KPQ7J7DWB7QZ3WCEK3YVPBRA",
  "status": "failed",
  "credits_cost": 64,
  "model": "veo3.1-fast",
  "progress": 100,
  "error": {
    "code": 400,
    "message": "Upstream generation failed",
    "type": "api_error"
  },
  "created": 1703884800,
  "completed": 1703884820
}

Response fields

FieldDescription
idTask id.
statussubmitted, processing, completed, or failed.
credits_costCredits associated with the task.
modelModel id used when the task was submitted.
progressInteger from 0 to 100.
resultPresent when completed; null while running.
result.typeimage or video.
result.dataOutput items. Use result.data[0].url for the primary asset.
errorPresent when status is failed.
createdUnix timestamp (seconds) when the task was created.
completedUnix timestamp (seconds) when the task reached a terminal state.

Polling example

bash
TASK_ID="task_01KPQ7J7DWB7QZ3WCEK3YVPBRA"

while true; do
  RESP=$(curl -s \
    -H "Authorization: Bearer $PIXAPI_KEY" \
    "https://api.pixapi.ai/v1/tasks/$TASK_ID")
  STATUS=$(printf '%s' "$RESP" | python3 -c 'import sys,json; print(json.load(sys.stdin)["status"])')
  echo "$STATUS"
  case "$STATUS" in
    completed|failed) printf '%s\n' "$RESP"; break ;;
  esac
  sleep 3
done
js
async function waitForTask(taskId) {
  for (;;) {
    const response = await fetch(`https://api.pixapi.ai/v1/tasks/${taskId}`, {
      headers: { Authorization: `Bearer ${process.env.PIXAPI_KEY}` },
    });
    if (!response.ok) throw new Error(await response.text());
    const task = await response.json();
    if (task.status === 'completed' || task.status === 'failed') return task;
    await new Promise((resolve) => setTimeout(resolve, 3000));
  }
}

const task = await waitForTask('task_01KPQ7J7DWB7QZ3WCEK3YVPBRA');
if (task.status === 'completed') {
  console.log(task.result.data[0].url);
} else {
  console.error(task.error);
}

Integration notes

  1. Store the task id from the async submit response.
  2. Poll GET /v1/tasks/{id} from your backend with backoff (for example every 2–5 seconds).
  3. Stop when status is completed or failed.
  4. Persist result.data[].url (or the error) in your own storage.

Do not expose your Pixapi API key in browser-only polling code.