Luma Tasks API Integration and Usage

The main function of the Luma Tasks API is to query the execution status of a task by entering the task ID generated by the Luma Videos Generation API.

This document provides detailed integration instructions for the Luma Tasks API, helping you easily integrate and take full advantage of the API's powerful features. With the Luma Tasks API, you can easily query the execution status of Luma Videos Generation API tasks.

Application Process

To use the Luma Videos Generation API, first go to the Ace Data Cloud Console to obtain your API Token for later use.

If you have not yet logged in or registered, you will be automatically redirected to the login page to register and log in. Once completed, you will be automatically returned to the current page.

The API Key for a general application can be used for services enabled for the account; the Key for a dedicated application can be used within that application's service scope. Please check the Key's permissions, validity period, and limits, and confirm that the application balance is sufficient to pay for this request. Available trial credits are subject to the amount shown in your account. If the balance is insufficient, click the "Recharge" button.

📘 Full documentation: Luma Videos Generation API →

Request Example

The Luma Tasks API can be used to query the results of the Luma Videos Generation API. For information on how to use the Luma Videos Generation API, please refer to the documentation Luma Videos Generation API.

We will use a task ID returned by the Luma Videos Generation API service as an example to demonstrate how to use this API. Suppose we have a task ID: 50fc6182-fa86-4c7d-ac12-2fa27ec2f151. Next, we will demonstrate how to pass in a task ID.

Task Example Image

Set the Request Headers and Request Body

Request Headers include:

  • accept: Specifies that the response should be received in JSON format; set this to application/json.
  • authorization: The key used to call the API; after applying, you can select it directly from the drop-down list.

Request Body includes:

  • id: The submitted task ID.
  • action: The operation to perform on the task.

The settings are shown below:

Code Examples

You can see that code in various languages has already been automatically generated on the right side of the page, as shown below:

Some code examples are as follows:

CURL

curl -X POST 'https://api.acedata.cloud/luma/tasks' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "id": "50fc6182-fa86-4c7d-ac12-2fa27ec2f151",
  "action": "retrieve"
}'

Python

import requests

url = "https://api.acedata.cloud/luma/tasks"

headers = {
    "accept": "application/json",
    "authorization": "Bearer {token}",
    "content-type": "application/json"
}

payload = {
    "id": "50fc6182-fa86-4c7d-ac12-2fa27ec2f151",
    "action": "retrieve"
}

response = requests.post(url, json=payload, headers=headers)
print(response.text)

Response Example

After a successful request, the API will return the details of the video task. For example:

{
  "_id": "66d297a3550a4144a5a5db42",
  "id": "50fc6182-fa86-4c7d-ac12-2fa27ec2f151",
  "api_id": "94fc9028-5a9f-4875-aae4-38463bd30ac5",
  "application_id": "06484a45-9d04-498a-98a7-67086dee8166",
  "created_at": 1725077411.961,
  "started_at": 1725077412.021,
  "finished_at": 1725077566.241,
  "elapsed": 154.22,
  "credential_id": "e6a879e5-a7c0-4f7b-9d6f-f9a837421a50",
  "request": {
    "action": "generate",
    "prompt": "Astronauts shuttle from space to volcano"
  },
  "trace_id": "0b7c1c1a-045c-4145-a434-609cba88f0a9",
  "user_id": "ad7afe47-cea9-4cda-980f-2ad8810e51cf",
  "response": {
    "success": true,
    "task_id": "50fc6182-fa86-4c7d-ac12-2fa27ec2f151",
    "video_id": "4b088fc8-2bbc-4706-80a6-a0fb118adc1a",
    "prompt": "Astronauts shuttle from space to volcano",
    "video_url": "https://platform.cdn.acedata.cloud/luma/50fc6182-fa86-4c7d-ac12-2fa27ec2f151.mp4",
    "video_height": 752,
    "video_width": 1360,
    "state": "completed",
    "thumbnail_url": "https://platform.cdn.acedata.cloud/luma/50fc6182-fa86-4c7d-ac12-2fa27ec2f151.jpg",
    "thumbnail_width": 1360,
    "thumbnail_height": 752
  }
}

The result contains multiple fields. The request field is the request body used when the task was initiated, while the response field is the response body returned after the task is completed. These correspond to the request and response of the Luma Videos Generation API. The fields are described below.

  • id, the ID of the video generation task, used to uniquely identify this task.
  • video_id, the unique identifier of the video in the queried video task. This parameter is required when you need to extend the video later.
  • request, the request information in the queried video task.
  • response, the response information in the queried video task.
  • created_at, the task creation time, as a Unix timestamp (seconds, floating-point).
  • started_at, the time the task began execution, as a Unix timestamp (seconds, floating-point).
  • finished_at, the task completion time, as a Unix timestamp (seconds, floating-point). This field is not returned if the task is incomplete.
  • elapsed, the task execution time in seconds (floating-point, rounded to 3 decimal places). This field is not returned if the task is incomplete.

Batch Query Operation

This is used to query video task details for multiple task IDs. Unlike the above, you need to select retrieve_batch for action.

Request Body includes:

  • ids: An array of submitted task IDs.
  • action: The operation to perform on the tasks.

The settings are shown below:

Code Examples

You can see that code in various languages has already been automatically generated on the right side of the page, as shown below:

Some code examples are as follows:

Response Example

After a successful request, the API will return the specific details of all video tasks in the batch. For example:

{
  "items": [
    {
      "_id": "66d297a3550a4144a5a5db42",
      "id": "50fc6182-fa86-4c7d-ac12-2fa27ec2f151",
      "api_id": "94fc9028-5a9f-4875-aae4-38463bd30ac5",
      "application_id": "06484a45-9d04-498a-98a7-67086dee8166",
      "created_at": 1725077411.961,
      "started_at": 1725077412.021,
      "finished_at": 1725077566.241,
      "elapsed": 154.22,
      "credential_id": "e6a879e5-a7c0-4f7b-9d6f-f9a837421a50",
      "request": {
        "action": "generate",
        "prompt": "Astronauts shuttle from space to volcano"
      },
      "trace_id": "0b7c1c1a-045c-4145-a434-609cba88f0a9",
      "user_id": "ad7afe47-cea9-4cda-980f-2ad8810e51cf",
      "response": {
        "success": true,
        "task_id": "50fc6182-fa86-4c7d-ac12-2fa27ec2f151",
        "video_id": "4b088fc8-2bbc-4706-80a6-a0fb118adc1a",
        "prompt": "Astronauts shuttle from space to volcano",
        "video_url": "https://platform.cdn.acedata.cloud/luma/50fc6182-fa86-4c7d-ac12-2fa27ec2f151.mp4",
        "video_height": 752,
        "video_width": 1360,
        "state": "completed",
        "thumbnail_url": "https://platform.cdn.acedata.cloud/luma/50fc6182-fa86-4c7d-ac12-2fa27ec2f151.jpg",
        "thumbnail_width": 1360,
        "thumbnail_height": 752
      }
    },
    {
      "_id": "66d29ed3550a4144a5a6c089",
      "id": "76a05f61-68ad-4c1a-838f-a00cd08cf65b",
      "api_id": "94fc9028-5a9f-4875-aae4-38463bd30ac5",
      "application_id": "06484a45-9d04-498a-98a7-67086dee8166",
      "created_at": 1725079250.921,
      "started_at": 1725079250.981,
      "finished_at": 1725079406.71,
      "elapsed": 155.729,
      "credential_id": "e6a879e5-a7c0-4f7b-9d6f-f9a837421a50",
      "request": {
        "action": "generate",
        "prompt": "la la la"
      },
      "trace_id": "338f1616-741d-40b6-8d62-c025434024c6",
      "user_id": "ad7afe47-cea9-4cda-980f-2ad8810e51cf",
      "response": {
        "success": true,
        "task_id": "76a05f61-68ad-4c1a-838f-a00cd08cf65b",
        "video_id": "5a638d6a-7481-4c5e-8843-36c9d1b5bcd5",
        "prompt": "la la la",
        "video_url": "https://platform.cdn.acedata.cloud/luma/76a05f61-68ad-4c1a-838f-a00cd08cf65b.mp4",
        "video_height": 752,
        "video_width": 1360,
        "state": "completed",
        "thumbnail_url": "https://platform.cdn.acedata.cloud/luma/76a05f61-68ad-4c1a-838f-a00cd08cf65b.jpg",
        "thumbnail_width": 1360,
        "thumbnail_height": 752
      }
    }
  ],
  "count": 2
}

The response contains multiple fields, of which items contains the details of the batch video tasks. The details of each video task are the same as the fields above. The field information is as follows.

  • items, all details of the batch video tasks. It is an array, and each element has the same format as the response for querying a single task above.
  • count, the number of video tasks queried in this batch.

CURL

curl -X POST 'https://api.acedata.cloud/luma/tasks' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "ids": ["50fc6182-fa86-4c7d-ac12-2fa27ec2f151","76a05f61-68ad-4c1a-838f-a00cd08cf65b"],
  "action": "retrieve_batch"
}'

Python

import requests

url = "https://api.acedata.cloud/luma/tasks"

headers = {
    "accept": "application/json",
    "authorization": "Bearer {token}",
    "content-type": "application/json"
}

payload = {
    "ids": ["50fc6182-fa86-4c7d-ac12-2fa27ec2f151","76a05f61-68ad-4c1a-838f-a00cd08cf65b"],
    "action": "retrieve_batch"
}

response = requests.post(url, json=payload, headers=headers)
print(response.text)

Error Handling

When calling the API, if an error occurs, the API will return the corresponding error code and message. For example:

  • 400 token_mismatched: Bad request, possibly due to missing or invalid parameters.
  • 400 api_not_implemented: Bad request, possibly due to missing or invalid parameters.
  • 401 invalid_token: Unauthorized, invalid or missing authorization token.
  • 429 too_many_requests: Too many requests, you have exceeded the rate limit.
  • 500 api_error: Internal server error, something went wrong on the server.

Error Response Example

{
  "success": false,
  "error": {
    "code": "api_error",
    "message": "fetch failed"
  },
  "trace_id": "2cf86e86-22a4-46e1-ac2f-032c0f2a4e89"
}

Conclusion

Through this document, you have learned how to use the Luma Tasks API to query all the details of a single video task or a batch of video tasks. We hope this document helps you integrate and use the API more effectively. If you have any questions, please feel free to contact our technical support team.