Luma Video Generation API Integration Guide

As AI applications become more widespread, various AI programs have gradually become commonplace. AI has gradually made its way into every aspect of people's work and lives. The industries involving AI are also expanding, from writing at the beginning, to healthcare and education, and now to video.

Luma is a professional, high-quality video generation platform. Users only need to upload materials to automatically generate high-quality videos in different styles and with different effects. This AI video generator was developed by team members from well-known technology companies, with the goal of enabling everyone to easily create excellent videos without complex editing tools.

However, Luma does not officially provide an API. AceDataCloud provides a Luma API that simulates integration with the official Suno service, allowing users to generate the videos they want quickly and conveniently.

Application and Usage

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

A general application's API Key can be used for services enabled for the account; a dedicated application's Key is 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 what is displayed in the account. If the balance is insufficient, click the "Recharge" button.

📘 Full documentation: Luma Videos Generation API →

Basic Usage

To generate a video, you can enter any text describing what you want. For example, if I want to generate a video about astronauts traveling between space and a volcano, I can enter Astronauts shuttle from space to volcano, as shown below:

The generated code is as follows:

Main request parameters:

  • prompt: The prompt for generating the video.
  • aspect_ratio: The video aspect ratio, 16:9 by default.
  • end_image_url: Optional, specifies the last frame.
  • enhancement: Optional, the clarity enhancement switch.
  • loop: Whether to generate a looping video, false by default.
  • timeout: Optional, the timeout in seconds.
  • callback_url: The asynchronous callback URL.
  • async: Optional, when set to true, the API immediately returns a task_id without requiring a callback_url. The result can then be obtained by polling the corresponding task query API.

You can click the "Try" button to test the API directly. After waiting 1–2 minutes, the result is as follows:

{
  "success": true,
  "task_id": "e4018a99-1522-4f24-9330-62c2a9b50b59",
  "video_id": "155838f8-7f1e-44d8-b387-192f3b4b509d",
  "prompt": "Astronauts shuttle from space to volcano",
  "video_url": "https://cdn.acedata.cloud/assets/examples/gemini/04a043bd-6b23-4b4e-945c-ce48158c3eee-3a89912507c7.mp4",
  "video_height": 752,
  "video_width": 1360,
  "state": "completed",
  "thumbnail_url": "https://platform.cdn.acedata.cloud/luma/e4018a99-1522-4f24-9330-62c2a9b50b59.jpg",
  "thumbnail_width": 1360,
  "thumbnail_height": 752
}

As you can see, we have now obtained information about the video, including the video ID, video link, video thumbnail, and other details.

The fields are described as follows:

  • success: Whether generation succeeded; true if successful, otherwise false
  • task_id: The unique ID of the video generation task here
  • video_id: The unique ID of the video produced by the video generation task here
  • prompt: The keywords for the video generation task here
  • video_url: The link to the resulting video from the video generation task here
  • video_height: The height of the generated video's thumbnail image
  • video_width: The width of the generated video's thumbnail image
  • state: The status of the video generation task here; completed if the task is finished.
  • thumbnail_url: The link to the generated video's thumbnail image
  • thumbnail_width: The width of the generated video's thumbnail image
  • thumbnail_height: The height of the generated video's thumbnail image

Generation with Custom First and Last Frames

If you want to generate a video by customizing its first and last frames, you can enter the image links for those frames:

At this point, the following image can be passed in through the video's first-frame start_image_url field as the first frame of the video:

First frame

Next, to generate a custom video based on the first and last frames and keywords, we can specify the following:

  • action: The action of the video generation task, usually normal generation generate or extended generation extend, with generate as the default.
  • start_image_url: Specifies the first frame of the generated video.
  • end_image_url: Specifies the last frame of the generated video.
  • prompt: The keywords for generating the video.

An example is filled in as follows:

After filling it in, the code is automatically generated as follows:

The corresponding code:

import requests

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

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

payload = {
    "start_image_url": "https://cdn.acedata.cloud/r9vsv9.png",
    "action": "generate",
    "prompt": "Astronauts shuttle from space to volcano"
}

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

The result obtained is as follows:

{
  "success": true,
  "task_id": "12a18694-fd4b-47e7-9c50-34f30862cff6",
  "video_id": "0105c090-03a5-425a-8026-523341cd575b",
  "prompt": "Astronauts shuttle from space to volcano",
  "video_url": "https://platform.cdn.acedata.cloud/luma/12a18694-fd4b-47e7-9c50-34f30862cff6.mp4",
  "video_height": 656,
  "video_width": 1552,
  "state": "completed",
  "thumbnail_url": "https://platform.cdn.acedata.cloud/luma/12a18694-fd4b-47e7-9c50-34f30862cff6.jpg",
  "thumbnail_width": 1552,
  "thumbnail_height": 656
}

The final result is similar to the one above, and the first frame of the generated video contains the image we provided. Of course, you can also provide image links for both the first and last frames to generate a video. You only need to add a last-frame image to the above example. The last-frame image is as follows:

Last frame

An example is filled in as follows:

Finally, the following result is obtained:

{
  "success": true,
  "task_id": "d1cb723a-e554-4775-94a4-bb6ae8c7ea67",
  "video_id": "6bebd0d2-f793-472e-9326-38528a9273bb",
  "prompt": "Astronauts shuttle from space to volcano",
  "video_url": "https://platform.cdn.acedata.cloud/luma/d1cb723a-e554-4775-94a4-bb6ae8c7ea67.mp4",
  "video_height": 656,
  "video_width": 1552,
  "state": "completed",
  "thumbnail_url": "https://platform.cdn.acedata.cloud/luma/d1cb723a-e554-4775-94a4-bb6ae8c7ea67.jpg",
  "thumbnail_width": 1552,
  "thumbnail_height": 656
}

The result is similar to the one above. The generated video contains both the first-frame and last-frame images, thus completing video generation with custom first and last frames.

Video Extension Feature

If you want to continue generating a video, you can set the action parameter to extend and enter the ID or link of the video to be continued. The video ID and link can be obtained according to the basic usage instructions, as shown below:

You can see that the video ID is:

"video_id": "0105c090-03a5-425a-8026-523341cd575b",
"video_url": "https://platform.cdn.acedata.cloud/luma/12a18694-fd4b-47e7-9c50-34f30862cff6.mp4"

Note that video_id and video_url here are the ID and link of the generated video. If you do not know how to generate a video, you can refer to the basic usage instructions above.

To continue generating a video, you must provide the video link or ID. The following demonstrates how to extend a video using its ID. Next, you must enter keywords to customize the generated video. You can specify the following:

  • action: The action for extending the video, which should be extend here.
  • prompt: The keywords for the video to be extended.
  • video_url: The link to the video to be extended.
  • video_id: The unique ID of the video to be extended.
  • end_image_url: The link to an image that can be specified as the last frame of the extended video; an optional parameter.

An example is shown below:

After filling in the information, the following code is automatically generated:

The corresponding Python code:

import requests

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

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

payload = {
    "action": "extend",
    "video_id": "0105c090-03a5-425a-8026-523341cd575b",
    "prompt": "Astronauts shuttle from space to volcano"
}

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

Click Run, and you will get a result as follows:

{
  "success": true,
  "task_id": "c6e529d1-a06d-4c12-91b2-c855135131c3",
  "video_id": "36908c49-c2bb-4a11-bd5a-b8512b004818",
  "prompt": "Astronauts shuttle from space to volcano",
  "video_url": "https://platform.cdn.acedata.cloud/luma/c6e529d1-a06d-4c12-91b2-c855135131c3.mp4",
  "video_height": 656,
  "video_width": 1552,
  "state": "completed",
  "thumbnail_url": "https://platform.cdn.acedata.cloud/luma/c6e529d1-a06d-4c12-91b2-c855135131c3.jpg",
  "thumbnail_width": 1552,
  "thumbnail_height": 656
}

You can see that this video is extended from the video to be extended, and the result is consistent with the one above, thus achieving the feature of continuing song generation.

Of course, we can also specify a video link to extend it. Enter the following information:

After running it, the following result is obtained:

{
  "success": true,
  "task_id": "1dcb5902-a7be-4b77-ba5d-dd8ec82b26ca",
  "video_id": "f0187dc2-339f-4a08-a435-c3a3341f620a",
  "prompt": "Astronauts shuttle from space to volcano",
  "video_url": "https://platform.cdn.acedata.cloud/luma/1dcb5902-a7be-4b77-ba5d-dd8ec82b26ca.mp4",
  "video_height": 656,
  "video_width": 1552,
  "state": "completed",
  "thumbnail_url": "https://platform.cdn.acedata.cloud/luma/1dcb5902-a7be-4b77-ba5d-dd8ec82b26ca.jpg",
  "thumbnail_width": 1552,
  "thumbnail_height": 656
}

The result shows that the video extension feature can also be implemented using a video link.

Finally, we can also specify a last-frame image when extending a video. Below is the last-frame image:

Last frame

Next, add the last-frame image information to the above settings, as shown below:

After clicking Run, the following information is obtained:

{
  "success": true,
  "task_id": "b816b2b4-c345-4673-9e19-83e91f91b643",
  "video_id": "c5400053-63e6-4206-8082-31cf9dd1e7ed",
  "prompt": "Astronauts shuttle from space to volcano",
  "video_url": "https://platform.cdn.acedata.cloud/luma/b816b2b4-c345-4673-9e19-83e91f91b643.mp4",
  "video_height": 656,
  "video_width": 1552,
  "state": "completed",
  "thumbnail_url": "https://platform.cdn.acedata.cloud/luma/b816b2b4-c345-4673-9e19-83e91f91b643.jpg",
  "thumbnail_width": 1552,
  "thumbnail_height": 656
}

As you can see, a last-frame image can also be specified when extending the video above.

Asynchronous Callback

Since Luma takes a relatively long time to generate a video, approximately 1–2 minutes, if the API does not respond for a long time, the HTTP request will keep the connection open, resulting in additional system resource consumption. Therefore, this API also provides support for asynchronous callbacks. The overall process is as follows: When the client initiates a request, it additionally specifies a callback_url field. After the client initiates the API request, the API immediately returns a result containing a task_id field, which represents the current task ID. Once the task is complete, the music generation result is sent as POST JSON to the callback_url specified by the client, and it also includes the task_id field, so the task results can be associated by ID.

Below, we will use an example to see how this works in practice.

First, a Webhook callback is a service that can receive HTTP requests, and developers should replace it with the URL of their own HTTP server. For ease of demonstration, we use a public Webhook sample website, https://webhook.site/. Open the website to obtain a Webhook URL, as shown below:

Copy this URL to use it as a Webhook. The example here is https://webhook.site/0c87ca0e-cd74-4577-8d68-f2b80fbf8a13.

Next, we can set the callback_url field to the Webhook URL above and fill in the prompt, as shown below:

Click Run, and you will see that a result is returned immediately, as follows:

{
  "task_id": "732f8282-7cf8-401c-95f2-42c33aa079a6"
}

After a short wait, we can see the song generation result at https://webhook.site/0c87ca0e-cd74-4577-8d68-f2b80fbf8a13, as shown below:

The content is as follows:

{
    "success": true,
    "task_id": "732f8282-7cf8-401c-95f2-42c33aa079a6",
    "video_id": "4d8013c3-5de0-41aa-966e-0b1a51d1c633",
    "prompt": "Astronauts shuttle from space to volcano",
    "video_url": "https://platform.cdn.acedata.cloud/luma/732f8282-7cf8-401c-95f2-42c33aa079a6.mp4",
    "video_height": 752,
    "video_width": 1360,
    "state": "completed",
    "thumbnail_url": "https://platform.cdn.acedata.cloud/luma/732f8282-7cf8-401c-95f2-42c33aa079a6.jpg",
    "thumbnail_width": 1360,
    "thumbnail_height": 752
}

As you can see, the result contains a task_id field, and the other fields are similar to those above. This field can be used to associate the task.