Appearance
HappyHorse 创建任务-视频编辑
HappyHorse 视频编辑模型支持输入视频与参考图,结合文本指令完成风格变换、局部替换等编辑任务。
1 请求地址
POSThttps://llm.infiflow.cn/dashscope/api/v1/services/aigc/video-generation/video-synthesis
2. 请求参数
| 参数名 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| model | string | 是 | 无 | 模型名称。固定值:happyhorse-1.0-video-edit |
| input | object | 是 | 无 | 输入信息,包含 prompt 和 media 字段 |
| input.prompt | string | 是 | 无 | 文本提示词,描述对视频的编辑意图(如风格转换、局部替换等)。支持任何语言输入,长度不超过 5000 个非中文字符或 2500 个中文字符 |
| input.media | array | 是 | 无 | 媒体素材列表。必须包含 1 个 video,可选 0~5 个 reference_image |
| input.media[].type | string | 是 | 无 | 媒体素材类型。可选值:video(待编辑视频)、reference_image(参考图像) |
| input.media[].url | string | 是 | 无 | 媒体素材 URL。视频格式:MP4、MOV(H.264);时长 3~60s;分辨率长边 ≤ 4096px、短边 ≥ 360px;大小 ≤ 100MB;帧率 > 8fps。图像格式:JPEG、JPG、PNG、WEBP;尺寸 ≥ 300px;大小 ≤ 20MB |
| parameters | object | 否 | - | 视频编辑参数 |
| parameters.resolution | string | 否 | 1080P | 视频分辨率档位。可选值:720P、1080P |
| parameters.watermark | boolean | 否 | true | 是否添加水印标识 |
| parameters.audio_setting | string | 否 | auto | 声音控制。可选值:auto(模型控制)、origin(保留原始声音) |
| parameters.seed | integer | 否 | 无 | 随机数种子,取值范围 [0, 2147483647]。固定 seed 可提升结果复现性 |
3. 请求示例
bash
curl --location 'https://llm.infiflow.cn/dashscope/api/v1/services/aigc/video-generation/video-synthesis' \
-H 'X-DashScope-Async: enable' \
-H "Authorization: Bearer YOUR_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "happyhorse-1.0-video-edit",
"input": {
"prompt": "将视频背景更换为海滩日落场景",
"media": [
{
"type": "video",
"url": "https://example.com/input-video.mp4"
}
]
},
"parameters": {
"resolution": "720P",
"duration": 5
}
}'powershell
$headers = @{
"X-DashScope-Async" = "enable"
"Authorization" = "Bearer YOUR_API_KEY"
"Content-Type" = "application/json"
}
$body = @{
model = "happyhorse-1.0-video-edit"
input = @{
prompt = "将视频背景更换为海滩日落场景"
media = @(
@{ type = "video"; url = "https://example.com/input-video.mp4" }
)
}
parameters = @{
resolution = "720P"
duration = 5
}
} | ConvertTo-Json -Depth 10
$response = Invoke-RestMethod -Uri "https://llm.infiflow.cn/dashscope/api/v1/services/aigc/video-generation/video-synthesis" -Method Post -Headers $headers -Body $body
Write-Host $responsepython
import requests
url = "https://llm.infiflow.cn/dashscope/api/v1/services/aigc/video-generation/video-synthesis"
headers = {
"X-DashScope-Async": "enable",
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"model": "happyhorse-1.0-video-edit",
"input": {
"prompt": "将视频背景更换为海滩日落场景",
"media": [
{"type": "video", "url": "https://example.com/input-video.mp4"}
]
},
"parameters": {
"resolution": "720P",
"duration": 5
}
}
response = requests.post(url, headers=headers, json=data)
print(response.json())java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
String json = """
{
"model": "happyhorse-1.0-video-edit",
"input": {
"prompt": "将视频背景更换为海滩日落场景",
"media": [
{"type": "video", "url": "https://example.com/input-video.mp4"}
]
},
"parameters": {
"resolution": "720P",
"duration": 5
}
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://llm.infiflow.cn/dashscope/api/v1/services/aigc/video-generation/video-synthesis"))
.header("X-DashScope-Async", "enable")
.header("Authorization", "Bearer YOUR_API_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());vue
<script setup>
import axios from 'axios'
const url = 'https://llm.infiflow.cn/dashscope/api/v1/services/aigc/video-generation/video-synthesis'
const data = {
model: 'happyhorse-1.0-video-edit',
input: {
prompt: '将视频背景更换为海滩日落场景',
media: [{ type: 'video', url: 'https://example.com/input-video.mp4' }]
},
parameters: { resolution: '720P', duration: 5 }
}
const res = await axios.post(url, data, {
headers: {
'X-DashScope-Async': 'enable',
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
})
console.log(res.data)
</script>javascript
const url = 'https://llm.infiflow.cn/dashscope/api/v1/services/aigc/video-generation/video-synthesis'
fetch(url, {
method: 'POST',
headers: {
'X-DashScope-Async': 'enable',
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'happyhorse-1.0-video-edit',
input: {
prompt: '将视频背景更换为海滩日落场景',
media: [{ type: 'video', url: 'https://example.com/input-video.mp4' }]
},
parameters: { resolution: '720P', duration: 5 }
})
})
.then(res => res.json())
.then(data => console.log(data))csharp
using System.Net.Http;
using System.Text;
using Newtonsoft.Json.Linq;
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-DashScope-Async", "enable");
client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");
var requestBody = new JObject
{
["model"] = "happyhorse-1.0-video-edit",
["input"] = new JObject
{
["prompt"] = "将视频背景更换为海滩日落场景",
["media"] = new JArray
{
new JObject { ["type"] = "video", ["url"] = "https://example.com/input-video.mp4" }
}
},
["parameters"] = new JObject
{
["resolution"] = "720P",
["duration"] = 5
}
};
var content = new StringContent(requestBody.ToString(), Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://llm.infiflow.cn/dashscope/api/v1/services/aigc/video-generation/video-synthesis", content);
Console.WriteLine(await response.Content.ReadAsStringAsync());vb
Imports System.Net.Http
Imports System.Text
Imports Newtonsoft.Json.Linq
Module VideoEdit
Sub Main()
Dim client As New HttpClient()
client.DefaultRequestHeaders.Add("X-DashScope-Async", "enable")
client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY")
Dim requestBody As New JObject()
requestBody("model") = "happyhorse-1.0-video-edit"
Dim inputObj As New JObject()
inputObj("prompt") = "将视频背景更换为海滩日落场景"
Dim mediaArray As New JArray()
mediaArray.Add(New JObject From {{"type", "video"}, {"url", "https://example.com/input-video.mp4"}})
inputObj("media") = mediaArray
requestBody("input") = inputObj
Dim paramsObj As New JObject()
paramsObj("resolution") = "720P"
paramsObj("duration") = 5
requestBody("parameters") = paramsObj
Dim json As String = requestBody.ToString()
Dim content As New StringContent(json, Encoding.UTF8, "application/json")
Dim response As HttpResponseMessage = client.PostAsync(
"https://llm.infiflow.cn/dashscope/api/v1/services/aigc/video-generation/video-synthesis", content).Result
Console.WriteLine(response.Content.ReadAsStringAsync().Result)
End Sub
End Modulejava
import System.*;
import System.Net.*;
import System.IO.*;
import System.Text.*;
public class VideoEdit {
public static void main(String[] args) throws Exception {
String url = "https://llm.infiflow.cn/dashscope/api/v1/services/aigc/video-generation/video-synthesis";
String json = "{\"model\":\"happyhorse-1.0-video-edit\",\"input\":{\"prompt\":\"将视频背景更换为海滩日落场景\",\"media\":[{\"type\":\"video\",\"url\":\"https://example.com/input-video.mp4\"}]},\"parameters\":{\"resolution\":\"720P\",\"duration\":5}}";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/json";
request.Headers.Add("X-DashScope-Async", "enable");
request.Headers.Add("Authorization", "Bearer YOUR_API_KEY");
byte[] bytes = Encoding.UTF8.GetBytes(json);
request.ContentLength = bytes.length;
request.GetRequestStream().write(bytes, 0, bytes.length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
String result = new StreamReader(response.getResponseStream()).readToEnd();
System.out.println(result);
}
}4. 响应参数
| 字段 | 类型 | 描述 |
|---|---|---|
| output | object | 任务输出信息,包含 task_id、task_status 等 |
| output.task_id | string | 任务 ID,查询有效期 24 小时 |
| output.task_status | string | 任务状态。枚举值:PENDING(排队中)、RUNNING(处理中)、SUCCEEDED(成功)、FAILED(失败)、CANCELED(已取消)、UNKNOWN(未知) |
| request_id | string | 请求唯一标识,用于请求明细溯源和问题排查 |
| code | string | 请求失败的错误码,请求成功时不返回 |
| message | string | 请求失败的详细信息,请求成功时不返回 |
5. 响应示例
json
{
"output": {
"task_status": "PENDING",
"task_id": "0385dc79-5ff8-4d82-bcb6-xxxxxx"
},
"request_id": "4909100c-7b5a-9f92-bfe5-xxxxxx"
}json
{
"code": "InvalidApiKey",
"message": "No API-key provided.",
"request_id": "7438d53d-6eb8-4596-8835-xxxxxx"
}