Query Tasks and Download Results
After you create a task, use the following APIs to check its progress, cancel it, and download the results.
Response when creating a task
When you create an Image to Video, Reference to Video, Text to Video, or image task, the response may contain more fields than are listed on this page. Use only the fields listed here; other fields may be changed or removed in the future.
Task fields
Every task returned by GET /api/tasks and GET /api/tasks/{publicId} contains the following fields:
| Field | Description |
|---|---|
public_id |
Task ID, used for both queries and downloads |
type |
Task type: 1 Image to Video, 2 image generation, 3 face age detection, 4 Reference to Video, 5 Text to Video |
status |
Task status; see the table below |
credits |
Credits charged for this task |
params |
The parameters sent when the task was created, including defaults filled in by the system (e.g. audio for videos) |
result |
Task result; null until the task finishes. For video and image tasks, it is { name: file path }, e.g. { "video": "results/xxx.mp4", "cover": "results/xxx_cover.jpg" }. Get the actual files as described in "Downloading files" below; for the cover of video tasks, see "Video cover image" below. After the retention period ends, the file paths become null. For face age detection, it is { "face_coordinates": [...] }, which is not affected by the retention period; see Face Age Detection |
error_code / error_message |
Error code and message on failure; null otherwise |
created_at / finished_at |
Creation time and finish time (ISO 8601). finished_at is null until the task finishes |
files_expire_at |
Retention deadline for the result files (ISO 8601); null until there is a result |
files_expired |
Whether the retention period has ended. When true, the files can no longer be downloaded |
files |
List of downloadable files [{ key, url }]; you can download directly from url. Empty array after the retention period ends; always an empty array for face age detection, which has no files |
status values
| Value | Meaning |
|---|---|
0 |
Queued |
2 |
Age check in progress. Generation tasks that include images stop here first and move to 0 after passing; see Pre-generation Age Check |
5 |
Reserved; currently never appears |
10 |
Processing |
20 |
Completed; result and files are available |
30 |
Failed; credits have been refunded automatically. See Credits and Billing |
40 |
Canceled; credits have been refunded automatically |
Get a single task
GET /api/tasks/{publicId}
X-Api-Key: sk-live-xxxx
publicIdmust belong to the account that owns this key; otherwise404is returned ({ "message": "Task not found." }).- You can keep querying a task after it finishes.
List tasks
GET /api/tasks?per_page=20
GET /api/tasks?from=2026-07-01&to=2026-07-11&per_page=20
X-Api-Key: sk-live-xxxx
| Parameter | Description |
|---|---|
per_page |
Optional. Items per page, 1–100, default 20 |
from / to |
Optional. Dates. If either is provided, historical tasks are returned, sorted by finish time from newest to oldest; if neither is provided, current tasks are returned, sorted by creation time from newest to oldest |
Invalid parameters (e.g. per_page over 100, or from not a valid date) return 422.
The response is paginated: data is the array of tasks, along with pagination fields such as current_page, last_page, per_page, and total.
Cancel a task
POST /api/tasks/{publicId}/cancel
X-Api-Key: sk-live-xxxx
- Only tasks that are queued (
status0) or in age check (status2) can be canceled. Tasks that have started processing or have finished return422. - On success, the credits charged for the task are refunded immediately, and the response is the updated task data (
status40). - If the task doesn't exist or doesn't belong to this key's account,
404is returned.
Downloading files
For example, for a completed video task, GET /api/tasks/{publicId} returns the following (only relevant fields shown):
{
"public_id": "01K0ZC8QW3E5F1234567890ABC",
"status": 20,
"result": {
"video": "results/01K0ZC8QW3E5F1234567890ABC.mp4",
"cover": "results/01K0ZC8QW3E5F1234567890ABC_cover.jpg"
},
"files_expire_at": "2026-07-20T08:00:00.000000Z",
"files_expired": false,
"files": [
{
"key": "video",
"url": "https://yuyuvideo.com/api/tasks/01K0ZC8QW3E5F1234567890ABC/files/video"
},
{
"key": "cover",
"url": "https://yuyuvideo.com/api/tasks/01K0ZC8QW3E5F1234567890ABC/files/cover"
}
]
}
Just download from the url in files; you don't need to build the URL yourself:
curl -H "X-Api-Key: sk-live-xxxx" \
"https://yuyuvideo.com/api/tasks/01K0ZC8QW3E5F1234567890ABC/files/video" \
-o output.mp4
Note: the video at the end of the URL is the field name in result, the same as files[].key. Do not use the file path (results/xxx.mp4) or file name; doing so returns 404.
Video cover image
When a video task completes, result and files include an extra cover: the video's cover image (JPEG). You can use it as a thumbnail in lists or as a player poster (e.g. HTML <video poster="...">). Download it the same way as the video, using the url in files whose key is cover; its retention period is the same as the video's.
- If the cover image fails to generate, the task still completes normally but has no
cover. Check thatfilescontains it before using it. - Tasks completed before this feature launched have no cover image.
Download API
GET /api/tasks/{publicId}/files/{key}
X-Api-Key: sk-live-xxxx
| Status code | Situation |
|---|---|
200 |
Success; returns the file itself (not JSON) |
404 |
The task doesn't exist, doesn't belong to you, or key isn't in this task's result |
410 |
The retention period has ended, or the file has been deleted |
Error codes
For all error codes, see Error Reference.