Hailuo(海螺)API 示例
本页面示例基于 Agentsflare 网关,适用于海螺标准通道模型(例如 minimax-hailuo-2.3 / minimax-hailuo-2.3-Fast / minimax-hailuo-02)。
-- 创建端点:POST https://api.agentsflare.com/v1/videos/generations -- 查询端点:GET https://api.agentsflare.com/v1/async-result/{task_id}
- 认证:
Authorization: Bearer <API_KEY>
快速说明
- 对于部分海螺模型(例如
minimax-hailuo-2.3-Fast),图生视频接口使用first_frame_image(字符串 URL)作为单图输入。 - 对于首尾帧/帧模式(仅
minimax-hailuo-02支持),使用images: [{ url: "..." }, { url: "..." }]。
参考原厂文档:详细参数与字段说明请参阅海螺(Hailuo)原厂文档: https://zhipu-ai.feishu.cn/wiki/LoMfwR0E0ih12ikR5a7cuS4fnwh
请求参数(摘要)
| 参数 | 必填 | 说明 |
|---|---|---|
model | 是 | 模型名称,例如 minimax-hailuo-2.3-Fast 或 minimax-hailuo-02 |
prompt | 是 | 正向提示词,描述主体、动作、镜头、光线等 |
duration | 是 | 视频时长(秒),常用 5 或 6 |
resolution | 否 | 输出分辨率,例如 768P / 1080P |
first_frame_image | 条件 | 单图输入的首帧 URL(仅 Fast 单图模式) |
images | 条件 | 帧数组,minimax-hailuo-02 的首尾帧列表,例如 [{ "url": "..." }, { "url": "..." }] |
mode | 否 | 质量档位,如 std / pro |
aspect_ratio | 否 | 画幅比,如 16:9 / 1:1 / 9:16 |
callback_url | 否 | 异步回调 URL |
external_task_id | 否 | 业务自定义任务 ID |
cURL 示例(单图 — first_frame_image)
bash
curl -X POST "https://api.agentsflare.com/v1/videos/generations" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "minimax-hailuo-2.3-Fast",
"prompt": "A cinematic sci-fi city skyline at dusk",
"duration": 6,
"resolution": "768P",
"first_frame_image": "https://example.com/first-frame.png"
}'javascript
const API_BASE = 'https://api.agentsflare.com';
const API_KEY = process.env.API_KEY;
async function createVideo() {
const payload = {
model: 'minimax-hailuo-2.3-Fast',
prompt: 'Camera slowly pulls back as the subject turns toward the light',
duration: 6,
resolution: '768P',
first_frame_image: 'https://example.com/first-frame.png'
};
const res = await fetch(`${API_BASE}/v1/videos/generations`, {
method: 'POST',
headers: {
Authorization: `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
});
console.log('HTTP', res.status);
console.log(await res.text());
}
createVideo().catch(console.error);python
import requests
import os
API_BASE = 'https://api.agentsflare.com/v1/videos/generations'
API_KEY = os.getenv('API_KEY')
payload = {
'model': 'minimax-hailuo-2.3-Fast',
'prompt': 'Camera slowly pulls back as the subject turns toward the light',
'duration': 6,
'resolution': '768P',
'first_frame_image': 'https://example.com/first-frame.png'
}
headers = {
'Authorization': f'Bearer {API_KEY}',
'Content-Type': 'application/json'
}
resp = requests.post(API_BASE, json=payload, headers=headers)
print(resp.status_code)
print(resp.text)java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class HailuoFast {
public static void main(String[] args) throws Exception {
String apiBase = "https://api.agentsflare.com/v1/videos/generations";
String apiKey = System.getenv("API_KEY");
String json = "{\"model\":\"minimax-hailuo-2.3-Fast\",\"prompt\":\"Camera slowly pulls back as the subject turns toward the light\",\"duration\":6,\"resolution\":\"768P\",\"first_frame_image\":\"https://example.com/first-frame.png\"}";
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create(apiBase))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.statusCode());
System.out.println(resp.body());
}
}cURL 示例(首尾帧 — images,仅 minimax-hailuo-02)
bash
curl -X POST "https://api.agentsflare.com/v1/videos/generations" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "minimax-hailuo-02",
"prompt": "A short scene transitioning from A to B",
"duration": 6,
"resolution": "768P",
"images": [
{ "url": "https://example.com/first-frame.png" },
{ "url": "https://example.com/last-frame.png" }
]
}'常见问题与注意事项
- 若收到
invalid params或上游提示不支持 Text-to-Video,请确认使用的是first_frame_image(单图)或images(首尾帧)格式,并确认所选模型支持该模式。
示例调用以 cURL、Python、Node、Go 四种形式给出;详细参数请参阅原厂文档(上方链接)。