Text-to-Video v1 (legacy)

Here is our backward-compatible support for the older Luma AI API.

Overview

The Luma AI Dream Machine API allows developers to generate, retrieve, and extend AI-generated content using a variety of inputs. This API is particularly useful for creative applications, such as generating visual content from text prompts.

Each generation costs 500 000 AI/ML Tokens.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

How to Make a Call

Generating a video using this model involves making two sequential API calls:

  • The first one is for creating and sending a video generation task to the server (returns a generation ID). This can be either a generation from a reference image/prompt or a video extension operation that adds length to an existing video.

  • The second one is for requesting the generated or extended video from the server using the generation ID received from the first endpoint.

Below, you can find three corresponding API schemas and examples for all endpoint calls.

API Schemas

Ensure you replace <YOUR_AIMLAPI_KEY> with your actual API key before running the code.

Generate Video

post
Authorizations
Body
aspect_ratiostring · enumRequired

The aspect ratio of the image

Example: 16:9Available options:
expand_promptbooleanOptional

Whether to expand the prompt

Default: falseExample: true
image_end_urlstring · uriOptional

The URL for the end of the image

Example: https://example.com/image-end.jpg
image_urlstring · uriOptional

The URL of the main image

Example: https://example.com/main-image.jpg
user_promptstringRequired

The user-provided prompt for image generation

Example: A beautiful sunset over the ocean
Responses
post
POST /luma-ai/generations HTTP/1.1
Host: api.aimlapi.com
Authorization: Bearer <YOUR_AIMLAPI_KEY>
Content-Type: application/json
Accept: */*
Content-Length: 195

{
  "aspect_ratio": "16:9",
  "expand_prompt": true,
  "image_end_url": "https://example.com/image-end.jpg",
  "image_url": "https://example.com/main-image.jpg",
  "user_prompt": "A beautiful sunset over the ocean"
}
201Success

No content

Example

import requests

url = "https://api.aimlapi.com/luma-ai/generations"

payload = {
  "aspect_ratio": "16:9",
  "expand_prompt": True,
  "user_prompt": "Flying jellyfish"
}
headers = {
  "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
  "content-type": "application/json"
}

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

print(response.json())

Fetch Generations

get
Authorizations
Query parameters
idsanyRequired

Array of UUID strings or string with comma-separated UUID strings

Responses
get
GET /luma-ai/generation HTTP/1.1
Host: api.aimlapi.com
Authorization: Bearer <YOUR_AIMLAPI_KEY>
Accept: */*
200Success

No content

Example

import requests

url = "https://api.aimlapi.com/luma-ai/generation"

querystring = {"ids[0]":"4c9126f3-d9a6-4eaf-aa4c-b64b634f65bd"}

headers = {
  "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
  "content-type": "application/json"
}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())

Extend Video

Extend allows you to effortlessly add length to an existing video.

post
Authorizations
Path parameters
taskIdstringRequired
Body
all ofOptional
Responses
post
POST /luma-ai/generations/{taskId}/extend HTTP/1.1
Host: api.aimlapi.com
Authorization: Bearer <YOUR_AIMLAPI_KEY>
Content-Type: application/json
Accept: */*
Content-Length: 195

{
  "aspect_ratio": "16:9",
  "expand_prompt": true,
  "image_end_url": "https://example.com/image-end.jpg",
  "image_url": "https://example.com/main-image.jpg",
  "user_prompt": "A beautiful sunset over the ocean"
}
201Success

No content

Example

import requests

url = "https://api.aimlapi.com/luma-ai/generations/57a6cb80-6da0-49bd-b29a-3f089b9e55e4/extend"

payload = {
  "aspect_ratio": "16:9",
  "expand_prompt": True,
  "user_prompt": "Flying jellyfish with a hat"
}
headers = {
  "Authorization": "Bearer <YOUR_AIMLAPI_KEY>",
  "content-type": "application/json"
}

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

print(response.json())

Last updated

Was this helpful?