Luma AI Text-to-Video
Generate Videos from Text or Images
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.
Authentication
All API requests require a Bearer token for authentication. Include your token in the Authorization header of each request.
Pricing
Each generation costs 500 000 AI/ML Tokens
API Reference
使用 Luma AI 根据提示生成视频,允许根据文本描述创建视频。
The aspect ratio of the image
16:9Whether to expand the prompt
trueThe URL for the end of the image
https://example.com/image-end.jpgThe URL of the main image
https://example.com/main-image.jpgThe user-provided prompt for image generation
A beautiful sunset over the oceanPOST /luma-ai/generations HTTP/1.1
Host: api.aimlapi.com
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"
}{
"created_at": "text",
"estimate_wait_seconds": "text",
"id": "text",
"liked": "text",
"prompt": "text",
"state": "text",
"video": {
"height": 1,
"width": 1,
"thumbnail": "text",
"url": "text"
}
}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-api-key",
"content-type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const axios = require('axios');
const url = "https://api.aimlapi.com/luma-ai/generations";
const payload = {
aspect_ratio: "16:9",
expand_prompt: true,
user_prompt: "Flying jellyfish"
};
const headers = {
"Authorization": "Bearer your-api-key",
"content-type": "application/json"
};
axios.post(url, payload, { headers })
.then(response => console.log(response.data))
.catch(error => console.error(error));
根据 Luma AI 中的 ID 返回视频生成列表。
GET /luma-ai/generation?ids=text HTTP/1.1
Host: api.aimlapi.com
Accept: */*
[
{
"created_at": "text",
"estimate_wait_seconds": "text",
"id": "text",
"liked": "text",
"prompt": "text",
"state": "text",
"video": {
"height": 1,
"width": 1,
"thumbnail": "text",
"url": "text"
}
}
]Example
import requests
url = "https://api.aimlapi.com/luma-ai/generation"
querystring = {"ids[0]":"4c9126f3-d9a6-4eaf-aa4c-b64b634f65bd"}
headers = {
"Authorization": "Bearer your-api-key",
"content-type": "application/json"
}
response = requests.get(url, headers=headers, params=querystring)
print(response.json())
const axios = require('axios');
const url = "https://api.aimlapi.com/luma-ai/generation";
const params = {
"ids[0]": "4c9126f3-d9a6-4eaf-aa4c-b64b634f65bd"
};
const headers = {
"Authorization": "Bearer your-api-key",
"content-type": "application/json"
};
axios.get(url, { headers, params })
.then(response => console.log(response.data))
.catch(error => console.error(error));
上传图像以便在 Luma AI 中进一步处理,通常用于 3D 建模或视频生成。
POST /luma-ai/generations/file-upload HTTP/1.1
Host: api.aimlapi.com
Content-Type: application/json
Accept: */*
Content-Length: 14
{
"url": "text"
}[
{
"id": "text",
"presigned_url": "https://example.com",
"public_url": "https://example.com"
}
]Example
import requests
url = "https://api.aimlapi.com/luma-ai/generations/file-upload"
payload = { "url": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQDozQhfHZ0SUoYPxSsIp7FXZmwHcSBijueGg&s" }
headers = {
"Authorization": "Bearer your-api-key",
"content-type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const axios = require('axios');
const url = "https://api.aimlapi.com/luma-ai/generations/file-upload";
const payload = {
url: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQDozQhfHZ0SUoYPxSsIp7FXZmwHcSBijueGg&s"
};
const headers = {
"Authorization": "Bearer your-api-key",
"content-type": "application/json"
};
axios.post(url, payload, { headers })
.then(response => console.log(response.data))
.catch(error => console.error(error));
使用 Luma AI 扩展现有视频,为视频项目创建附加内容。
The aspect ratio of the image
16:9Whether to expand the prompt
trueThe URL for the end of the image
https://example.com/image-end.jpgThe URL of the main image
https://example.com/main-image.jpgThe user-provided prompt for image generation
A beautiful sunset over the oceanPOST /luma-ai/generations/{taskId}/extend HTTP/1.1
Host: api.aimlapi.com
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"
}{
"id": "text",
"created_at": "text",
"estimate_wait_seconds": "text",
"liked": "text",
"prompt": "text",
"state": "text",
"video": {
"height": 1,
"width": 1,
"thumbnail": "text",
"url": "text"
}
}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-api-key",
"content-type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json())
const axios = require('axios');
const url = "https://api.aimlapi.com/luma-ai/generations/57a6cb80-6da0-49bd-b29a-3f089b9e55e4/extend";
const payload = {
aspect_ratio: "16:9",
expand_prompt: true,
user_prompt: "Flying jellyfish with a hat"
};
const headers = {
"Authorization": "Bearer your-api-key",
"content-type": "application/json"
};
axios.post(url, payload, { headers })
.then(response => console.log(response.data))
.catch(error => console.error(error));
最后更新于