Hailuo Tasks API Integration and Usage

The main function of the Hailuo Tasks API is to query the execution status of tasks by inputting the task ID generated by the Hailuo Videos Generation API.

This document will provide detailed integration instructions for the Hailuo Tasks API, helping you easily integrate and fully utilize the powerful features of this API. With the Hailuo Tasks API, you can easily query the execution status of tasks from the Hailuo Videos Generation API.

Application Process

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

If you are not logged in or registered, you will be automatically redirected to the login page to invite you to register and log in. After completing this, you will be automatically returned to the current page.

One API Token can call all services on the platform without needing to apply separately for each service. The first application will grant a free quota for a trial experience; when the quota is insufficient, you can recharge the general balance in the console.

📘 Complete Documentation: Hailuo Videos Generation API →

Request Example

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

We will take a task ID returned by the Hailuo Videos Generation API as an example to demonstrate how to use this API. Suppose we have a task ID: 58cc618b-9639-4ee7-add2-d2fcf260d9a3, and we will demonstrate how to pass in a task ID.

Task Example Image

Setting Request Headers and Request Body

Request Headers include:

  • accept: Specifies that the response result should be in JSON format, set to application/json.
  • authorization: The key to call the API, which can be selected directly after application.

Request Body includes:

  • id: The uploaded task ID.
  • action: The operation method for the task.

Set as shown in the image below:

Code Example

You can see that various language codes have been automatically generated on the right side of the page, as shown in the image:

Some code examples are as follows:

CURL

curl -X POST 'https://api.acedata.cloud/hailuo/tasks' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "id": "58cc618b-9639-4ee7-add2-d2fcf260d9a3",
  "action": "retrieve"
}'

Python

import requests

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

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

payload = {
    "id": "58cc618b-9639-4ee7-add2-d2fcf260d9a3",
    "action": "retrieve"
}

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

Response Example

Upon successful request, the API will return the detailed information of the video task here. For example:

{
  "_id": "67866dff550a4144a5867aa7",
  "id": "58cc618b-9639-4ee7-add2-d2fcf260d9a3",
  "api_id": "d5af91f6-a7ec-4015-b0a5-d25051158470",
  "application_id": "2f9f4d93-9193-4c49-a1a5-eddf0ff38abb",
  "created_at": 1736863231.588,
  "credential_id": "f634e655-012e-432e-92a8-a87e4a80d636",
  "request": {
    "action": "generate",
    "prompt": "Internal heat"
  },
  "trace_id": "0c1f9f13-0aef-4d9a-a9d2-1d27055ff190",
  "user_id": "ad7afe47-cea9-4cda-980f-2ad8810e51cf",
  "response": {
    "success": true,
    "task_id": "58cc618b-9639-4ee7-add2-d2fcf260d9a3",
    "trace_id": "0c1f9f13-0aef-4d9a-a9d2-1d27055ff190",
    "data": [
      {
        "id": "2a1tbgnjdxrg80cmcmes19s33r",
        "model": "minimax-t2v",
        "prompt": "Internal heat",
        "first_image_url": null,
        "video_url": "https://platform.cdn.acedata.cloud/czjl/tjU3QYKgU96IJFgpL0eMfBFhmy0qXz9Y05P2IBhShCYaDCFUA/tmp5uligw3a.output.mp4",
        "state": "succeeded"
      }
    ]
  }
}

The returned result contains multiple fields, with the request field being the request body when the task was initiated, and the response field being the response body returned after the task is completed. The field descriptions are as follows.

  • id: The ID of the video task generated, used to uniquely identify this video generation task.
  • request: The request information in the video task.
  • response: The return information in the video task.

Batch Query Operation

This is for querying the details of multiple task IDs, and unlike the above, the action needs to be selected as retrieve_batch.

Request Body includes:

  • ids: An array of uploaded task IDs.
  • action: The operation method for the task.

Set as shown in the image below:

Code Example

You can see that various language codes have been automatically generated on the right side of the page, as shown in the image:

Some code examples are as follows:

Response Example

Upon successful request, the API will return the specific details of all batch video tasks this time. For example:

{
  "items": [
    {
      "_id": "67866fad550a4144a587053c",
      "id": "09d4a93e-d5c8-4778-bdf2-711773d71c59",
      "api_id": "d5af91f6-a7ec-4015-b0a5-d25051158470",
      "application_id": "2f9f4d93-9193-4c49-a1a5-eddf0ff38abb",
      "created_at": 1736863661.511,
      "credential_id": "f634e655-012e-432e-92a8-a87e4a80d636",
      "request": {
        "action": "generate",
        "prompt": "Internal heat"
      },
      "trace_id": "0edc94c6-4938-4bff-bb16-20364c254e40",
      "user_id": "ad7afe47-cea9-4cda-980f-2ad8810e51cf",
      "response": {
        "success": true,
        "task_id": "09d4a93e-d5c8-4778-bdf2-711773d71c59",
        "trace_id": "0edc94c6-4938-4bff-bb16-20364c254e40",
        "data": [
          {
            "id": "24zdgea0s1rge0cmcmjbsfj2m8",
            "model": "minimax-t2v",
            "prompt": "Internal heat",
            "first_image_url": null,
            "video_url": "https://platform.cdn.acedata.cloud/czjl/6cTYBRBDVJIQANzG7GaPwPblbeIiFe4yUDcVoMkkXttqJCFUA/tmpm4ke45c5.output.mp4",
            "state": "succeeded"
          }
        ]
      }
    },
    {
      "_id": "67866dff550a4144a5867aa7",
      "id": "58cc618b-9639-4ee7-add2-d2fcf260d9a3",
      "api_id": "d5af91f6-a7ec-4015-b0a5-d25051158470",
      "application_id": "2f9f4d93-9193-4c49-a1a5-eddf0ff38abb",
      "created_at": 1736863231.588,
      "credential_id": "f634e655-012e-432e-92a8-a87e4a80d636",
      "request": {
        "action": "generate",
        "prompt": "Internal heat"
      },
      "trace_id": "0c1f9f13-0aef-4d9a-a9d2-1d27055ff190",
      "user_id": "ad7afe47-cea9-4cda-980f-2ad8810e51cf",
      "response": {
        "success": true,
        "task_id": "58cc618b-9639-4ee7-add2-d2fcf260d9a3",
        "trace_id": "0c1f9f13-0aef-4d9a-a9d2-1d27055ff190",
        "data": [
          {
            "id": "2a1tbgnjdxrg80cmcmes19s33r",
            "model": "minimax-t2v",
            "prompt": "Internal heat",
            "first_image_url": null,
            "video_url": "https://platform.cdn.acedata.cloud/czjl/tjU3QYKgU96IJFgpL0eMfBFhmy0qXz9Y05P2IBhShCYaDCFUA/tmp5uligw3a.output.mp4",
            "state": "succeeded"
          }
        ]
      }
    }
  ],
  "count": 2
}

The returned result contains multiple fields, among which items includes the specific details of batch video tasks, and the specific information of each video task is the same as the format of the single task return result mentioned above. The field information is as follows.

  • items, all specific detail information of batch video tasks. It is an array, and each element of the array has the same format as the return result of querying a single task above.
  • count, the number of video tasks in this batch query.

CURL

curl -X POST 'https://api.acedata.cloud/hailuo/tasks' \
-H 'accept: application/json' \
-H 'authorization: Bearer {token}' \
-H 'content-type: application/json' \
-d '{
  "ids": ["09d4a93e-d5c8-4778-bdf2-711773d71c59","58cc618b-9639-4ee7-add2-d2fcf260d9a3"],
  "action": "retrieve_batch"
}'

Python

import requests

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

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

payload = {
    "ids": ["09d4a93e-d5c8-4778-bdf2-711773d71c59","58cc618b-9639-4ee7-add2-d2fcf260d9a3"],
    "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 Hailuo Tasks API to query all specific detail information of single or batch video tasks. We hope this document can help you better integrate and use this API. If you have any questions, please feel free to contact our technical support team.