Luma 批量任务查询接口 - QuickRouter API 中转接口
▼
Authorization
在 Header 添加参数 Authorization,其值为 Bearer 之后拼接 Token
示例:
Authorization: Bearer ********************
概述
"state": "completed" 枚举值: "pending", "processing", "completed", "failed"
请求参数
Header 参数
Content-Type
string
必需
示例: application/json
Accept
string
必需
示例: application/json
Authorization
string
必需
示例: Bearer {{YOUR_API_KEY}}
Body 参数 application/json
model
string
必需
使用的模型,可选,默认为 kling-image
prompt
string
必需
正向提示词,必需,描述你想要生成的图像内容,不能超过500个字符
negative_prompt
string
必需
负向提示词,可选,描述你不想在图像中出现的元素,不能超过200个字符
image
string
必需
参考图片,可选,支持 Base64 编码或图片 URL,支持 .jpg/.jpeg/.png 格式,大小不能超过 10MB
image_fidelity
number
必需
参考图片的影响强度,可选,取值范围:0-1,值越大,生成的图像越接近参考图片
n
integer
必需
生成图片的数量,可选,取值范围:1-9
aspect_ratio
string
必需
生成图片的纵横比,可选,可选值:16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3
callback_url
string
必需
回调通知地址,可选,当任务状态发生变化时,系统会向这个地址发送通知 { "ids": [ "4665a07c-7641-4809-a133-10786201bb56" ] } 请求
示例
{
"ids": [
"4665a07c-7641-4809-a133-10786201bb56"
]
}
请求示例代码
curl --location --request POST 'https://api.quickrouter.ai/luma/tasks' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"ids": [
"4665a07c-7641-4809-a133-10786201bb56"
]
}'
var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Authorization", "Bearer YOUR_API_KEY");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"ids": [
"4665a07c-7641-4809-a133-10786201bb56"
]
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.quickrouter.ai/luma/tasks", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
import java.io.*;
import java.net.*;
import java.util.*;
URL url = new URL("https://api.quickrouter.ai/luma/tasks");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestProperty("Authorization", "Bearer YOUR_API_KEY");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);
String jsonInputString = "{
\"ids\": [
\"4665a07c-7641-4809-a133-10786201bb56\"
]
}";
try(OutputStream os = conn.getOutputStream()) {
byte[] input = jsonInputString.getBytes("utf-8");
os.write(input, 0, input.length);
}
int responseCode = conn.getResponseCode();
System.out.println("Response Code: " + responseCode);
import Foundation
let urlString = "https://api.quickrouter.ai/luma/tasks"
guard let url = URL(string: urlString) else { return }
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("application/json", forHTTPHeaderField: "Accept")
request.addValue("Bearer YOUR_API_KEY", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
let httpBody = "{
\"ids\": [
\"4665a07c-7641-4809-a133-10786201bb56\"
]
}"
request.httpBody = httpBody.data(using: .utf8)
let task = URLSession.shared.dataTask(with: request) { data, response, error in
if let data = data {
print(String(data: data, encoding: .utf8)!)
}
}
task.resume()
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
body := strings.NewReader(`{
"ids": [
"4665a07c-7641-4809-a133-10786201bb56"
]
}`)
req, _ := http.NewRequest("POST", "https://api.quickrouter.ai/luma/tasks", body)
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
bodyBytes, _ := io.ReadAll(resp.Body)
fmt.Println(string(bodyBytes))
}
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.quickrouter.ai/luma/tasks',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{
"ids": [
"4665a07c-7641-4809-a133-10786201bb56"
]
}',
CURLOPT_HTTPHEADER => array(
"Accept: application/json",
"Authorization: Bearer YOUR_API_KEY",
"Content-Type: application/json",
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import http.client
import json
conn = http.client.HTTPSConnection("api.quickrouter.ai")
payload = json.dumps({
"ids": [
"4665a07c-7641-4809-a133-10786201bb56"
]
})
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
}
conn.request("POST", "/luma/tasks", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
POST https://api.quickrouter.ai/luma/tasks HTTP/1.1
Accept: application/json
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
{
"ids": [
"4665a07c-7641-4809-a133-10786201bb56"
]
}
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.quickrouter.ai/luma/tasks");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Authorization: Bearer YOUR_API_KEY");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{
\"ids\": [
\"4665a07c-7641-4809-a133-10786201bb56\"
]
}");
CURLcode ret = curl_easy_perform(hnd);
var client = new RestClient("https://api.quickrouter.ai/luma/tasks");
var request = new RestRequest(Method.POST);
request.AddHeader("Accept", "application/json");
request.AddHeader("Authorization", "Bearer YOUR_API_KEY");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", @"{
"ids": [
"4665a07c-7641-4809-a133-10786201bb56"
]
}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
#import <Foundation/Foundation.h>
NSURL *url = [NSURL URLWithString:@"https://api.quickrouter.ai/luma/tasks"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"Bearer YOUR_API_KEY" forHTTPHeaderField:@"Authorization"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:[@"{
\"ids\": [
\"4665a07c-7641-4809-a133-10786201bb56\"
]
}" dataUsingEncoding:NSUTF8StringEncoding]];
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSLog(@"%@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
}];
[task resume];
require "uri"
require "net/http"
require "json"
url = URI("https://api.quickrouter.ai/luma/tasks")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Accept"] = "application/json"
request["Authorization"] = "Bearer YOUR_API_KEY"
request["Content-Type"] = "application/json"
request.body = '{
"ids": [
"4665a07c-7641-4809-a133-10786201bb56"
]
}'
response = http.request(request)
puts response.read_body
(* Requires cohttp and lwt *)
let url = "https://api.quickrouter.ai/luma/tasks" in
let headers = Cohttp.Header.of_list [
("Accept", "application/json");
("Authorization", "Bearer YOUR_API_KEY");
("Content-Type", "application/json");
] in
let body = Cohttp_lwt.Body.of_string '{
"ids": [
"4665a07c-7641-4809-a133-10786201bb56"
]
}' in
Lwt_main.run (
Cohttp_lwt_unix.Client.request ?body:(Some body) ~method_:`POST ~headers (Uri.of_string url)
>>= fun (resp, body) ->
Cohttp_lwt.Body.to_string body >|= fun s -> print_endline s
)
import 'package:http/http.dart' as http;
import 'dart:convert';
var headers = {
"Accept": "application/json",
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
};
var body = json.encode({
"ids": [
"4665a07c-7641-4809-a133-10786201bb56"
]
});
var response = await http.post(Uri.parse("https://api.quickrouter.ai/luma/tasks"), headers: headers, body: body);
print(response.body);
library(httr)
url <- "https://api.quickrouter.ai/luma/tasks"
body <- '{
"ids": [
"4665a07c-7641-4809-a133-10786201bb56"
]
}'
response <- post(url, body = body, add_headers("Accept" = "application/json", "Authorization" = "Bearer YOUR_API_KEY", "Content-Type" = "application/json"))
content(response, "text", encoding = "UTF-8")
返回响应
响应参数 🟢 200 OK · application/json
artifact
object
可选
created_at
string
必需
last_frame
object
必需
thumbnail
object
必需
video
object
必需
video_raw
object
必需
created_at
string
可选
id
string
可选
last_frame
object
可选
height
integer
必需
media_type
string
必需
palette
null
必需
url
string
必需
width
integer
必需
request
object
可选
aspect_ratio
string
必需
prompt
string
必需
state
string
可选
thumbnail
object
可选
height
integer
必需
media_type
string
必需
palette
object
必需
url
string
必需
width
integer
必需
video
object
可选
download_url
string
必需
height
integer
必需
url
string
必需
width
integer
必需
video_raw
object
可选
duration
number
必需
height
integer
必需
media_type
string
必需
url
string
必需
width
integer
必需
[ { "artifact": { "created_at": "0001-01-01T00:00:00Z", "last_frame": { "height": 752, "media_type": "image", "palette": null, "url": "https://storage.cdn-luma.com/dream-machine/b0d67582-c6f0-4973-a89c-3fea9d46d5e9/606108d9-9daf-4265-84fb-595f18240ac5/video_0_last_frame.jpg", "width": 1360 }, "thumbnail": { "height": 752, "media_type": "image", "palette": { "grid": "em9csKqXYUgqdHVmmqeZLB8YaFpLjVw2bmFTTElBHhMNTzgodD8eVzUeTDorRSkYYEQymV80e1M0ck0ugWVRwKCApWk0hF1BgmVP" }, "url": "https://imagedelivery.net/1KomXrSWiTojGGip43n0SQ/e4268de5-4a74-45ff-67b8-dc46df12de00/public", "width": 1360 }, "video": { "download_url": "https://storage.cdn-luma.com/dream-machine/b0d67582-c6f0-4973-a89c-3fea9d46d5e9/35049450-c008-4607-b1d0-0b025599f15d/video0b6619468da8e409da860706bbf26bbad.mp4", "height": 752, "url": "https://storage.cdn-luma.com/dream-machine/b0d67582-c6f0-4973-a89c-3fea9d46d5e9/35049450-c008-4607-b1d0-0b025599f15d/video0b6619468da8e409da860706bbf26bbad.mp4", "width": 1360 }, "video_raw": { "duration": 5.041667, "height": 752, "media_type": "video", "url": "https://storage.cdn-luma.com/dream-machine/b0d67582-c6f0-4973-a89c-3fea9d46d5e9/35049450-c008-4607-b1d0-0b025599f15d/video0b6619468da8e409da860706bbf26bbad.mp4", "width": 1360 } }, "created_at": "2024-12-22T13:38:40.139Z", "id": "4665a07c-7641-4809-a133-10786201bb56", "last_frame": { "height": 752, "media_type": "image", "palette": null, "url": "https://storage.cdn-luma.com/dream-machine/b0d67582-c6f0-4973-a89c-3fea9d46d5e9/606108d9-9daf-4265-84fb-595f18240ac5/video_0_last_frame.jpg", "width": 1360 }, "request": { "aspect_ratio": "16:9", "prompt": "cat dance" }, "state": "completed", "thumbnail": { "height": 752, "media_type": "image", "palette": { "grid": "em9csKqXYUgqdHVmmqeZLB8YaFpLjVw2bmFTTElBHhMNTzgodD8eVzUeTDorRSkYYEQymV80e1M0ck0ugWVRwKCApWk0hF1BgmVP" }, "url": "https://imagedelivery.net/1KomXrSWiTojGGip43n0SQ/e4268de5-4a74-45ff-67b8-dc46df12de00/public", "width": 1360 }, "video": { "download_url": "https://storage.cdn-luma.com/dream-machine/b0d67582-c6f0-4973-a89c-3fea9d46d5e9/35049450-c008-4607-b1d0-0b025599f15d/video0b6619468da8e409da860706bbf26bbad.mp4", "height": 752, "url": "https://storage.cdn-luma.com/dream-machine/b0d67582-c6f0-4973-a89c-3fea9d46d5e9/35049450-c008-4607-b1d0-0b025599f15d/video0b6619468da8e409da860706bbf26bbad.mp4", "width": 1360 }, "video_raw": { "duration": 5.041667, "height": 752, "media_type": "video", "url": "https://storage.cdn-luma.com/dream-machine/b0d67582-c6f0-4973-a89c-3fea9d46d5e9/35049450-c008-4607-b1d0-0b025599f15d/video0b6619468da8e409da860706bbf26bbad.mp4", "width": 1360 } } ]
示例
[
{
"artifact": {
"created_at": "0001-01-01T00:00:00Z",
"last_frame": {
"height": 752,
"media_type": "image",
"palette": null,
"url": "https://storage.cdn-luma.com/dream-machine/b0d67582-c6f0-4973-a89c-3fea9d46d5e9/606108d9-9daf-4265-84fb-595f18240ac5/video_0_last_frame.jpg",
"width": 1360
},
"thumbnail": {
"height": 752,
"media_type": "image",
"palette": {
"grid": "em9csKqXYUgqdHVmmqeZLB8YaFpLjVw2bmFTTElBHhMNTzgodD8eVzUeTDorRSkYYEQymV80e1M0ck0ugWVRwKCApWk0hF1BgmVP"
},
"url": "https://imagedelivery.net/1KomXrSWiTojGGip43n0SQ/e4268de5-4a74-45ff-67b8-dc46df12de00/public",
"width": 1360
},
"video": {
"download_url": "https://storage.cdn-luma.com/dream-machine/b0d67582-c6f0-4973-a89c-3fea9d46d5e9/35049450-c008-4607-b1d0-0b025599f15d/video0b6619468da8e409da860706bbf26bbad.mp4",
"height": 752,
"url": "https://storage.cdn-luma.com/dream-machine/b0d67582-c6f0-4973-a89c-3fea9d46d5e9/35049450-c008-4607-b1d0-0b025599f15d/video0b6619468da8e409da860706bbf26bbad.mp4",
"width": 1360
},
"video_raw": {
"duration": 5.041667,
"height": 752,
"media_type": "video",
"url": "https://storage.cdn-luma.com/dream-machine/b0d67582-c6f0-4973-a89c-3fea9d46d5e9/35049450-c008-4607-b1d0-0b025599f15d/video0b6619468da8e409da860706bbf26bbad.mp4",
"width": 1360
}
},
"created_at": "2024-12-22T13:38:40.139Z",
"id": "4665a07c-7641-4809-a133-10786201bb56",
"last_frame": {
"height": 752,
"media_type": "image",
"palette": null,
"url": "https://storage.cdn-luma.com/dream-machine/b0d67582-c6f0-4973-a89c-3fea9d46d5e9/606108d9-9daf-4265-84fb-595f18240ac5/video_0_last_frame.jpg",
"width": 1360
},
"request": {
"aspect_ratio": "16:9",
"prompt": "cat dance"
},
"state": "completed",
"thumbnail": {
"height": 752,
"media_type": "image",
"palette": {
"grid": "em9csKqXYUgqdHVmmqeZLB8YaFpLjVw2bmFTTElBHhMNTzgodD8eVzUeTDorRSkYYEQymV80e1M0ck0ugWVRwKCApWk0hF1BgmVP"
},
"url": "https://imagedelivery.net/1KomXrSWiTojGGip43n0SQ/e4268de5-4a74-45ff-67b8-dc46df12de00/public",
"width": 1360
},
"video": {
"download_url": "https://storage.cdn-luma.com/dream-machine/b0d67582-c6f0-4973-a89c-3fea9d46d5e9/35049450-c008-4607-b1d0-0b025599f15d/video0b6619468da8e409da860706bbf26bbad.mp4",
"height": 752,
"url": "https://storage.cdn-luma.com/dream-machine/b0d67582-c6f0-4973-a89c-3fea9d46d5e9/35049450-c008-4607-b1d0-0b025599f15d/video0b6619468da8e409da860706bbf26bbad.mp4",
"width": 1360
},
"video_raw": {
"duration": 5.041667,
"height": 752,
"media_type": "video",
"url": "https://storage.cdn-luma.com/dream-machine/b0d67582-c6f0-4973-a89c-3fea9d46d5e9/35049450-c008-4607-b1d0-0b025599f15d/video0b6619468da8e409da860706bbf26bbad.mp4",
"width": 1360
}
}
]
常见错误
- 401 认证失败:检查 API Key 是否正确
- 429 请求限流:降低调用频率或升级套餐
- 500 服务器错误:稍后重试
注意事项
- 请确保 API Key 有足够的余额
- 请求频率受 API 限制,请参考价格页面