Video edit: create an edit task from a video + reference images + instruction
curl --request POST \
--url https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-DashScope-Async: <x-dashscope-async>' \
--data @- <<EOF
{
"model": "wan2.7-videoedit",
"input": {
"prompt": "Replace the girl's outfit in the video with the outfit in the image",
"media": [
{
"type": "video",
"url": "https://your-cdn.com/source.mp4"
},
{
"type": "reference_image",
"url": "https://your-cdn.com/new-clothes.png"
}
]
}
}
EOFimport requests
url = "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
payload = {
"model": "wan2.7-videoedit",
"input": {
"prompt": "Replace the girl's outfit in the video with the outfit in the image",
"media": [
{
"type": "video",
"url": "https://your-cdn.com/source.mp4"
},
{
"type": "reference_image",
"url": "https://your-cdn.com/new-clothes.png"
}
]
}
}
headers = {
"X-DashScope-Async": "<x-dashscope-async>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-DashScope-Async': '<x-dashscope-async>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'wan2.7-videoedit',
input: {
prompt: 'Replace the girl\'s outfit in the video with the outfit in the image',
media: [
{type: 'video', url: 'https://your-cdn.com/source.mp4'},
{type: 'reference_image', url: 'https://your-cdn.com/new-clothes.png'}
]
}
})
};
fetch('https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'wan2.7-videoedit',
'input' => [
'prompt' => 'Replace the girl\'s outfit in the video with the outfit in the image',
'media' => [
[
'type' => 'video',
'url' => 'https://your-cdn.com/source.mp4'
],
[
'type' => 'reference_image',
'url' => 'https://your-cdn.com/new-clothes.png'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-DashScope-Async: <x-dashscope-async>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
payload := strings.NewReader("{\n \"model\": \"wan2.7-videoedit\",\n \"input\": {\n \"prompt\": \"Replace the girl's outfit in the video with the outfit in the image\",\n \"media\": [\n {\n \"type\": \"video\",\n \"url\": \"https://your-cdn.com/source.mp4\"\n },\n {\n \"type\": \"reference_image\",\n \"url\": \"https://your-cdn.com/new-clothes.png\"\n }\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-DashScope-Async", "<x-dashscope-async>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis")
.header("X-DashScope-Async", "<x-dashscope-async>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"wan2.7-videoedit\",\n \"input\": {\n \"prompt\": \"Replace the girl's outfit in the video with the outfit in the image\",\n \"media\": [\n {\n \"type\": \"video\",\n \"url\": \"https://your-cdn.com/source.mp4\"\n },\n {\n \"type\": \"reference_image\",\n \"url\": \"https://your-cdn.com/new-clothes.png\"\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-DashScope-Async"] = '<x-dashscope-async>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"wan2.7-videoedit\",\n \"input\": {\n \"prompt\": \"Replace the girl's outfit in the video with the outfit in the image\",\n \"media\": [\n {\n \"type\": \"video\",\n \"url\": \"https://your-cdn.com/source.mp4\"\n },\n {\n \"type\": \"reference_image\",\n \"url\": \"https://your-cdn.com/new-clothes.png\"\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"output": {
"task_id": "3b216861-6a5f-441d-a438-602ab2c0d103",
"task_status": "PENDING"
},
"request_id": "..."
}Генерация видео Wan2.7 (Alibaba Cloud)
Справочник API для редактирования видео Wan2.7
Справочник API редактирования видео Wan2.7-videoedit и живая песочница: входное видео + эталонные изображения + инструкция на естественном языке для локальных/глобальных правок, таких как замена одежды и замена фона.
POST
/
wan
/
api
/
v1
/
services
/
aigc
/
video-generation
/
video-synthesis
Video edit: create an edit task from a video + reference images + instruction
curl --request POST \
--url https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-DashScope-Async: <x-dashscope-async>' \
--data @- <<EOF
{
"model": "wan2.7-videoedit",
"input": {
"prompt": "Replace the girl's outfit in the video with the outfit in the image",
"media": [
{
"type": "video",
"url": "https://your-cdn.com/source.mp4"
},
{
"type": "reference_image",
"url": "https://your-cdn.com/new-clothes.png"
}
]
}
}
EOFimport requests
url = "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
payload = {
"model": "wan2.7-videoedit",
"input": {
"prompt": "Replace the girl's outfit in the video with the outfit in the image",
"media": [
{
"type": "video",
"url": "https://your-cdn.com/source.mp4"
},
{
"type": "reference_image",
"url": "https://your-cdn.com/new-clothes.png"
}
]
}
}
headers = {
"X-DashScope-Async": "<x-dashscope-async>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-DashScope-Async': '<x-dashscope-async>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'wan2.7-videoedit',
input: {
prompt: 'Replace the girl\'s outfit in the video with the outfit in the image',
media: [
{type: 'video', url: 'https://your-cdn.com/source.mp4'},
{type: 'reference_image', url: 'https://your-cdn.com/new-clothes.png'}
]
}
})
};
fetch('https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'wan2.7-videoedit',
'input' => [
'prompt' => 'Replace the girl\'s outfit in the video with the outfit in the image',
'media' => [
[
'type' => 'video',
'url' => 'https://your-cdn.com/source.mp4'
],
[
'type' => 'reference_image',
'url' => 'https://your-cdn.com/new-clothes.png'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-DashScope-Async: <x-dashscope-async>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
payload := strings.NewReader("{\n \"model\": \"wan2.7-videoedit\",\n \"input\": {\n \"prompt\": \"Replace the girl's outfit in the video with the outfit in the image\",\n \"media\": [\n {\n \"type\": \"video\",\n \"url\": \"https://your-cdn.com/source.mp4\"\n },\n {\n \"type\": \"reference_image\",\n \"url\": \"https://your-cdn.com/new-clothes.png\"\n }\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-DashScope-Async", "<x-dashscope-async>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis")
.header("X-DashScope-Async", "<x-dashscope-async>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"wan2.7-videoedit\",\n \"input\": {\n \"prompt\": \"Replace the girl's outfit in the video with the outfit in the image\",\n \"media\": [\n {\n \"type\": \"video\",\n \"url\": \"https://your-cdn.com/source.mp4\"\n },\n {\n \"type\": \"reference_image\",\n \"url\": \"https://your-cdn.com/new-clothes.png\"\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-DashScope-Async"] = '<x-dashscope-async>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"wan2.7-videoedit\",\n \"input\": {\n \"prompt\": \"Replace the girl's outfit in the video with the outfit in the image\",\n \"media\": [\n {\n \"type\": \"video\",\n \"url\": \"https://your-cdn.com/source.mp4\"\n },\n {\n \"type\": \"reference_image\",\n \"url\": \"https://your-cdn.com/new-clothes.png\"\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"output": {
"task_id": "3b216861-6a5f-441d-a438-602ab2c0d103",
"task_status": "PENDING"
},
"request_id": "..."
}Песочница справа позволяет отлаживать напрямую: поместите
Bearer sk-your-api-key в Authorization, заполните model / input.media / parameters и отправьте запрос. Успешная отправка возвращает task_id; ниже см. сведения о polling и загрузке.Эта страница — эндпоинт создания для
wan2.7-videoedit (редактирование видео): передайте видео + 1-5 reference images + инструкцию редактирования на естественном языке, чтобы изменить элементы видео, например заменить одежду или фон. Обратите внимание: у названия модели нет дефиса (videoedit). Полный асинхронный процесс см. в Обзор Wan.input.mediaдолжен содержать иvideo(редактируемое видео), и как минимум одноreference_image(референсный объект, ≤5).- Название модели —
wan2.7-videoedit(без дефиса), оно отличается от HappyHorse’shappyhorse-1.0-video-edit(с дефисами), так что не путайте их. - Запросы на создание отправляются в
/wan/api/v1/...сX-DashScope-Async: enable; не используйте/v1/videos.
Примеры кода
curl -X POST "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis" \
-H "X-DashScope-Async: enable" \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "wan2.7-videoedit",
"input": {
"prompt": "Replace the girl's outfit in the video with the outfit in the image",
"media": [
{"type": "video", "url": "https://your-cdn.com/source.mp4"},
{"type": "reference_image", "url": "https://your-cdn.com/new-clothes.png"}
]
},
"parameters": {"resolution": "720P", "prompt_extend": true, "watermark": true}
}'
import requests
url = "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
headers = {
"Authorization": "Bearer sk-your-api-key",
"Content-Type": "application/json",
"X-DashScope-Async": "enable",
}
body = {
"model": "wan2.7-videoedit",
"input": {
"prompt": "Replace the girl's outfit in the video with the outfit in the image",
"media": [
{"type": "video", "url": "https://your-cdn.com/source.mp4"},
{"type": "reference_image", "url": "https://your-cdn.com/new-clothes.png"},
],
},
"parameters": {"resolution": "720P", "prompt_extend": True, "watermark": True},
}
resp = requests.post(url, json=body, headers=headers, timeout=30)
print("task_id:", resp.json()["output"]["task_id"])
import requests
# Up to 5 reference_image for finer local/global edits
body = {
"model": "wan2.7-videoedit",
"input": {
"prompt": "Replace the background in the video with the seaside in image 1, and change the character's outfit to image 2",
"media": [
{"type": "video", "url": "https://your-cdn.com/source.mp4"},
{"type": "reference_image", "url": "https://your-cdn.com/beach.png"},
{"type": "reference_image", "url": "https://your-cdn.com/outfit.png"},
],
},
"parameters": {"resolution": "720P", "prompt_extend": True},
}
resp = requests.post(
"https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis",
json=body,
headers={"Authorization": "Bearer sk-your-api-key", "Content-Type": "application/json",
"X-DashScope-Async": "enable"},
timeout=30,
)
print(resp.json()["output"]["task_id"])
Краткая справка по параметрам и медиа
| Параметр | Тип | Обязательно | По умолчанию | Примечания |
|---|---|---|---|---|
model | string | ✓ | — | Фиксированное wan2.7-videoedit |
input.prompt | string | ✓ | — | Инструкция по редактированию на естественном языке |
input.media | array | ✓ | — | См. таблицу медиа ниже |
parameters.resolution | string | 720P | 720P / 1080P | |
parameters.prompt_extend | bool | true | Умное переписывание | |
parameters.watermark | bool | false | Водяной знак «сгенерировано AI» |
Значения media[]
type | Обязательно | Количество | Примечания |
|---|---|---|---|
video | ✓ | 1 | Исходное видео, которое редактируется |
reference_image | ✓ | 1-5 | Референсный файл (новый наряд, новый фон и т. д.) |
Длительность результата редактирования видео соответствует входному видео, а не параметру
duration, поэтому эта возможность обычно не передает duration.Формат ответа
{
"output": { "task_id": "3b216861-6a5f-441d-a438-602ab2c0d103", "task_status": "PENDING" },
"request_id": "..."
}
Проверка статуса и скачивание
Когда у вас естьtask_id, выполните следующие три шага, чтобы опрашивать статус и скачать mp4:
- Опрос
GET /v1/tasks/{task_id}(сAuthorization; запросу не нужен заголовокX-DashScope-Async) каждые 5-10 секунд (не < 3 секунд), покаstatusне станетcompleted. - Значения статуса:
submitted(в очереди) /in_progress(генерируется; еслиprogressчасто остается на 30%, это нормально) /completed(успешно) /failed(проверьтеerror). - Скачивание: получите
result_urlнапрямую из ответа, без заголовкаAuthorization(это подписанная прямая ссылка OSS — при отправке Auth возвращается 403);result_urlпо умолчанию истекает через 24 часа, поэтому сохраните ее сразу.
curl "https://api.apiyi.com/v1/tasks/3b216861-6a5f-441d-a438-602ab2c0d103" \
-H "Authorization: Bearer sk-your-api-key"
{
"status": "completed",
"progress": 100,
"result_url": "https://dashscope-result-xxx.oss-cn-beijing.aliyuncs.com/xxx.mp4?Expires=...&Signature=...",
"task_id": "3b216861-6a5f-441d-a438-602ab2c0d103"
}
# result_url is an OSS signed direct link — do NOT send the Authorization header (it returns 403)
curl -L -o out.mp4 "https://dashscope-result-xxx.oss-cn-beijing.aliyuncs.com/xxx.mp4?Expires=...&Signature=..."
TASK_ID="3b216861-6a5f-441d-a438-602ab2c0d103"
URL=$(curl -s "https://api.apiyi.com/v1/tasks/$TASK_ID" \
-H "Authorization: Bearer sk-your-api-key" | jq -r '.result_url')
curl -L -o out.mp4 "$URL" # no Authorization
Выше приведен быстрый путь проверки/скачивания для случая «у вас уже есть task_id». Для полного цикла опроса (с запасным вариантом при тайм-ауте) и Python-клиента см. Обзор Wan · Поток асинхронного вызова.
Авторизации
The API Key obtained from the APIYI console
Заголовки
Async processing switch; must be set to enable
Доступные опции:
enable Тело
application/json
Была ли эта страница полезной?
⌘I