跳转到主要内容
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.0-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.0-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.0-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.0-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.0-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.0-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.0-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": "..."
}
You can debug directly in the Playground on the right: fill in Authorization with Bearer sk-your-api-key, set model / input / parameters, then send the request. A successful submission returns a task_id; see below for polling and downloading.
This page covers the create endpoint for happyhorse-1.0-t2v (Text-to-Video) and needs only a text prompt. For the complete async flow, status table, and Python client, see the HappyHorse Overview.
  • The create request must go to /wan/api/v1/services/aigc/video-generation/video-synthesis with the request header X-DashScope-Async: enable. Do not use /v1/videos.
  • duration must be an integer (5, not "5"); write resolution in uppercase 720P.

Code Examples

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.0-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.0-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.0-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"])

Parameter Quick Reference

ParameterTypeRequiredDefaultNotes
modelstringFixed to happyhorse-1.0-t2v
input.promptstringText prompt; describe scene, camera movement, lighting, and style
parameters.resolutionstring720P720P / 1080P (uppercase)
parameters.durationint5Integer of 2–15 seconds
parameters.prompt_extendbooltrueSmart rewriting, recommended on
parameters.watermarkboolfalse”AI Generated” watermark in the bottom-right corner
parameters.seedintrandom0–2147483647, fix for reproducibility

Response Format

A successful creation returns a task_id (not the video itself):
{
  "output": { "task_id": "...", "task_status": "PENDING" },
  "request_id": "..."
}
After submission, you must poll GET /v1/tasks/{task_id} until status: "completed", then download the mp4 from the result_url in the response. When downloading, do not include the Authorization header (it’s a signed OSS direct link), and result_url expires in 24 hours by default. See the full polling loop in HappyHorse Overview · Async Call Flow.

授权

Authorization
string
header
必填

The API Key obtained from the APIYI Console

请求头

X-DashScope-Async
enum<string>
默认值:enable
必填

Async processing switch, must be set to enable

可用选项:
enable

请求体

application/json
model
enum<string>
默认值:happyhorse-1.0-t2v
必填

Model ID, fixed to happyhorse-1.0-t2v for Text-to-Video

可用选项:
happyhorse-1.0-t2v
input
object
必填
parameters
object

响应

Task submitted, returns task_id and PENDING status

output
object
request_id
string

Unique request identifier

示例:

"..."