Sign In
Using the latest Dream Machine model

Introduction

Since the release of Dream Machine by Luma Labs, everyone in the world can now access the text/image-to-video generation model and this has allowed us to create visually stunning videos at our fingertips. But how do we create one?

In this article, we will cover the steps to create your own Dream Machine generated video.

Do note we will be using HTTPs call.

Let's get into it!

Step 1: Generate a task_id in the Dream Machine endpoint.

This is where we will generate a task_id with the prompt that you wish to see in the video.

POST /api/luma/v1/video HTTP/1.1
X-Api-Key: {{x-api-key}}                      //Insert your API Key
Content-Type: application/json
Accept: application/json
Host: api.piapi.ai
Content-Length: 53
{
  "prompt": "A cosmic battle between two powerful wizards, with their spells colliding in a spectacular display of energy and light.",     //Insert your prompt here
  "expand_prompt": true
}

Step 2: Response

After sending in the request, keep the returned task_id in the response terminal for the next step.

{
  "code": 200,
  "data": {
    "task_id": "6c*****************************aa"    //Keep the task_id for later use
  },
  "message": "success"
}

Step 3: Fetching the Dream Machine task_id

In the fetch endpoint, replace the {task_id} with the returned task_id that you kept from the previous step then send the request.

GET /api/luma/v1/video/task_id HTTP/1.1    //Replace the task_id with your task_id
Accept: application/json
Host: api.piapi.ai

Step 4: Retrieving the result

Regarding the output response of the fetch endpoint, you may refer to their documentation for more information.

In the response terminal, copy the video's link into a web browser and you should see the resulting video.

Sample video

Prompt: "A cosmic battle between two powerful wizards, with their spells colliding in a spectacular display of energy and light."

Here is a video generated:


The video above is generated by PiAPI's Dream Machine API model.

1

Comments