Skip to content

HappyHorse 创建任务-视频编辑

HappyHorse 视频编辑模型支持输入视频与参考图,结合文本指令完成风格变换、局部替换等编辑任务。

1 请求地址

POSThttps://llm.infiflow.cn/dashscope/api/v1/services/aigc/video-generation/video-synthesis

2. 请求参数

参数名类型必填默认值描述
modelstring模型名称。固定值:happyhorse-1.0-video-edit
inputobject输入信息,包含 promptmedia 字段
input.promptstring文本提示词,描述对视频的编辑意图(如风格转换、局部替换等)。支持任何语言输入,长度不超过 5000 个非中文字符或 2500 个中文字符
input.mediaarray媒体素材列表。必须包含 1 个 video,可选 0~5 个 reference_image
input.media[].typestring媒体素材类型。可选值:video(待编辑视频)、reference_image(参考图像)
input.media[].urlstring媒体素材 URL。视频格式:MP4、MOV(H.264);时长 3~60s;分辨率长边 ≤ 4096px、短边 ≥ 360px;大小 ≤ 100MB;帧率 > 8fps。图像格式:JPEG、JPG、PNG、WEBP;尺寸 ≥ 300px;大小 ≤ 20MB
parametersobject-视频编辑参数
parameters.resolutionstring1080P视频分辨率档位。可选值:720P1080P
parameters.watermarkbooleantrue是否添加水印标识
parameters.audio_settingstringauto声音控制。可选值:auto(模型控制)、origin(保留原始声音)
parameters.seedinteger随机数种子,取值范围 [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 $response
python
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 Module
java
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. 响应参数

字段类型描述
outputobject任务输出信息,包含 task_idtask_status
output.task_idstring任务 ID,查询有效期 24 小时
output.task_statusstring任务状态。枚举值:PENDING(排队中)、RUNNING(处理中)、SUCCEEDED(成功)、FAILED(失败)、CANCELED(已取消)、UNKNOWN(未知)
request_idstring请求唯一标识,用于请求明细溯源和问题排查
codestring请求失败的错误码,请求成功时不返回
messagestring请求失败的详细信息,请求成功时不返回

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"
}

算力有源 智算无限