Text-to-Video: create a video generation task from a text prompt
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 '
{
"model": "happyhorse-1.1-t2v",
"input": {
"prompt": "A cat running across a meadow, bright sunshine, camera following, cinematic lighting"
}
}
'import requests
url = "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
payload = {
"model": "happyhorse-1.1-t2v",
"input": { "prompt": "A cat running across a meadow, bright sunshine, camera following, cinematic lighting" }
}
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: 'happyhorse-1.1-t2v',
input: {
prompt: 'A cat running across a meadow, bright sunshine, camera following, cinematic lighting'
}
})
};
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' => 'happyhorse-1.1-t2v',
'input' => [
'prompt' => 'A cat running across a meadow, bright sunshine, camera following, cinematic lighting'
]
]),
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\": \"happyhorse-1.1-t2v\",\n \"input\": {\n \"prompt\": \"A cat running across a meadow, bright sunshine, camera following, cinematic lighting\"\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\": \"happyhorse-1.1-t2v\",\n \"input\": {\n \"prompt\": \"A cat running across a meadow, bright sunshine, camera following, cinematic lighting\"\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\": \"happyhorse-1.1-t2v\",\n \"input\": {\n \"prompt\": \"A cat running across a meadow, bright sunshine, camera following, cinematic lighting\"\n }\n}"
response = http.request(request)
puts response.read_body{
"output": {
"task_id": "hh-12ab34cd-...",
"task_status": "PENDING"
},
"request_id": "..."
}HappyHorse 동영상 생성 (Alibaba)
HappyHorse 텍스트-투-비디오 API 레퍼런스
HappyHorse-1.1-t2v 텍스트-투-비디오 API 레퍼런스 및 온라인 디버깅: 순수한 텍스트 prompt로 동영상을 생성하는 DashScope 비동기 패스스루 엔드포인트입니다.
POST
/
wan
/
api
/
v1
/
services
/
aigc
/
video-generation
/
video-synthesis
Text-to-Video: create a video generation task from a text prompt
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 '
{
"model": "happyhorse-1.1-t2v",
"input": {
"prompt": "A cat running across a meadow, bright sunshine, camera following, cinematic lighting"
}
}
'import requests
url = "https://api.apiyi.com/wan/api/v1/services/aigc/video-generation/video-synthesis"
payload = {
"model": "happyhorse-1.1-t2v",
"input": { "prompt": "A cat running across a meadow, bright sunshine, camera following, cinematic lighting" }
}
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: 'happyhorse-1.1-t2v',
input: {
prompt: 'A cat running across a meadow, bright sunshine, camera following, cinematic lighting'
}
})
};
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' => 'happyhorse-1.1-t2v',
'input' => [
'prompt' => 'A cat running across a meadow, bright sunshine, camera following, cinematic lighting'
]
]),
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\": \"happyhorse-1.1-t2v\",\n \"input\": {\n \"prompt\": \"A cat running across a meadow, bright sunshine, camera following, cinematic lighting\"\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\": \"happyhorse-1.1-t2v\",\n \"input\": {\n \"prompt\": \"A cat running across a meadow, bright sunshine, camera following, cinematic lighting\"\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\": \"happyhorse-1.1-t2v\",\n \"input\": {\n \"prompt\": \"A cat running across a meadow, bright sunshine, camera following, cinematic lighting\"\n }\n}"
response = http.request(request)
puts response.read_body{
"output": {
"task_id": "hh-12ab34cd-...",
"task_status": "PENDING"
},
"request_id": "..."
}오른쪽 플레이그라운드에서 바로 디버깅할 수 있습니다: Authorization에
Bearer sk-your-api-key를 입력하고, model / input / parameters를 설정한 다음 요청을 전송하십시오. 성공적으로 제출되면 task_id가 반환됩니다. 폴링과 다운로드는 아래를 참조하십시오.이 페이지는
happyhorse-1.1-t2v(텍스트-투-비디오)의 생성 엔드포인트를 다루며, 텍스트 prompt만 필요합니다. 전체 비동기 흐름, 상태 표, Python 클라이언트는 HappyHorse 개요를 참조하십시오.- 생성 요청은 요청 헤더
X-DashScope-Async: enable와 함께/wan/api/v1/services/aigc/video-generation/video-synthesis로 전송해야 합니다./v1/videos를 사용하지 마십시오. duration는 정수여야 합니다(5,"5"아님).resolution는 대문자720P로 작성하십시오.
코드 예시
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": "happyhorse-1.1-t2v",
"input": {
"prompt": "A cat running across a meadow, bright sunshine, camera following, cinematic lighting"
},
"parameters": {
"resolution": "720P",
"duration": 5,
"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", # Required for creating a task
}
body = {
"model": "happyhorse-1.1-t2v",
"input": {"prompt": "A cat running across a meadow, bright sunshine, camera following"},
"parameters": {"resolution": "720P", "duration": 5, "prompt_extend": True, "watermark": True},
}
resp = requests.post(url, json=body, headers=headers, timeout=30)
print("task_id:", resp.json()["output"]["task_id"])
import json, urllib.request
BASE, KEY = "https://api.apiyi.com", "sk-your-api-key"
body = {
"model": "happyhorse-1.1-t2v",
"input": {"prompt": "A cat running across a meadow, bright sunshine"},
"parameters": {"resolution": "720P", "duration": 5, "prompt_extend": True},
}
req = urllib.request.Request(
BASE + "/wan/api/v1/services/aigc/video-generation/video-synthesis",
data=json.dumps(body).encode(),
headers={"Authorization": f"Bearer {KEY}", "Content-Type": "application/json",
"X-DashScope-Async": "enable"},
method="POST",
)
print(json.loads(urllib.request.urlopen(req).read())["output"]["task_id"])
매개변수 빠른 참조
| 매개변수 | 유형 | 필수 | 기본값 | 비고 |
|---|---|---|---|---|
model | string | ✓ | — | happyhorse-1.1-t2v로 고정 |
input.prompt | string | ✓ | — | 텍스트 prompt; 장면, 카메라 움직임, 조명, 스타일을 설명합니다 |
parameters.resolution | string | 720P | 720P / 1080P (대문자) | |
parameters.duration | int | 5 | 2~15초 정수 | |
parameters.prompt_extend | bool | true | 스마트 재작성, 켜기를 권장합니다 | |
parameters.watermark | bool | false | 오른쪽 아래 모서리의 “AI 생성됨” 워터마크 | |
parameters.seed | int | random | 0–2147483647, 재현성을 위해 고정 |
응답 형식
성공적으로 생성되면task_id를 반환합니다 (동영상 자체는 아님):
{
"output": { "task_id": "...", "task_status": "PENDING" },
"request_id": "..."
}
제출 후에는
status: "completed"가 될 때까지 GET /v1/tasks/{task_id}를 폴링한 다음, 응답의 result_url에서 mp4를 다운로드합니다. 다운로드할 때는 Authorization 헤더를 포함하지 마십시오(서명된 OSS 직접 링크입니다). 또한 result_url는 기본적으로 24시간 후 만료됩니다. 전체 폴링 루프는 HappyHorse Overview · Async Call Flow에서 확인할 수 있습니다.인증
The API Key obtained from the APIYI Console
헤더
Async processing switch, must be set to enable
사용 가능한 옵션:
enable 본문
application/json
이 페이지가 도움이 되었나요?
⌘I