HappyHorse 1.1 視頻生成
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"action": "<string>",
"prompt": "<string>",
"image_urls": [
"<string>"
],
"reference_images": [
"<string>"
],
"url": "<string>",
"audio_setting": "<string>",
"duration": 123,
"resolution": "<string>",
"aspect_ratio": "<string>",
"seed": 123,
"watermark": true
}
'import requests
url = "https://toapis.com/v1/videos/generations"
payload = {
"model": "<string>",
"action": "<string>",
"prompt": "<string>",
"image_urls": ["<string>"],
"reference_images": ["<string>"],
"url": "<string>",
"audio_setting": "<string>",
"duration": 123,
"resolution": "<string>",
"aspect_ratio": "<string>",
"seed": 123,
"watermark": True
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
action: '<string>',
prompt: '<string>',
image_urls: ['<string>'],
reference_images: ['<string>'],
url: '<string>',
audio_setting: '<string>',
duration: 123,
resolution: '<string>',
aspect_ratio: '<string>',
seed: 123,
watermark: true
})
};
fetch('https://toapis.com/v1/videos/generations', 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://toapis.com/v1/videos/generations",
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' => '<string>',
'action' => '<string>',
'prompt' => '<string>',
'image_urls' => [
'<string>'
],
'reference_images' => [
'<string>'
],
'url' => '<string>',
'audio_setting' => '<string>',
'duration' => 123,
'resolution' => '<string>',
'aspect_ratio' => '<string>',
'seed' => 123,
'watermark' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$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://toapis.com/v1/videos/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"action\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image_urls\": [\n \"<string>\"\n ],\n \"reference_images\": [\n \"<string>\"\n ],\n \"url\": \"<string>\",\n \"audio_setting\": \"<string>\",\n \"duration\": 123,\n \"resolution\": \"<string>\",\n \"aspect_ratio\": \"<string>\",\n \"seed\": 123,\n \"watermark\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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://toapis.com/v1/videos/generations")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"action\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image_urls\": [\n \"<string>\"\n ],\n \"reference_images\": [\n \"<string>\"\n ],\n \"url\": \"<string>\",\n \"audio_setting\": \"<string>\",\n \"duration\": 123,\n \"resolution\": \"<string>\",\n \"aspect_ratio\": \"<string>\",\n \"seed\": 123,\n \"watermark\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://toapis.com/v1/videos/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"action\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image_urls\": [\n \"<string>\"\n ],\n \"reference_images\": [\n \"<string>\"\n ],\n \"url\": \"<string>\",\n \"audio_setting\": \"<string>\",\n \"duration\": 123,\n \"resolution\": \"<string>\",\n \"aspect_ratio\": \"<string>\",\n \"seed\": 123,\n \"watermark\": true\n}"
response = http.request(request)
puts response.read_bodyHappyHorse
HappyHorse 1.1 視頻生成
使用 HappyHorse 1.1 生成、參考圖生成或編輯視頻
POST
/
v1
/
videos
/
generations
HappyHorse 1.1 視頻生成
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"action": "<string>",
"prompt": "<string>",
"image_urls": [
"<string>"
],
"reference_images": [
"<string>"
],
"url": "<string>",
"audio_setting": "<string>",
"duration": 123,
"resolution": "<string>",
"aspect_ratio": "<string>",
"seed": 123,
"watermark": true
}
'import requests
url = "https://toapis.com/v1/videos/generations"
payload = {
"model": "<string>",
"action": "<string>",
"prompt": "<string>",
"image_urls": ["<string>"],
"reference_images": ["<string>"],
"url": "<string>",
"audio_setting": "<string>",
"duration": 123,
"resolution": "<string>",
"aspect_ratio": "<string>",
"seed": 123,
"watermark": True
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
action: '<string>',
prompt: '<string>',
image_urls: ['<string>'],
reference_images: ['<string>'],
url: '<string>',
audio_setting: '<string>',
duration: 123,
resolution: '<string>',
aspect_ratio: '<string>',
seed: 123,
watermark: true
})
};
fetch('https://toapis.com/v1/videos/generations', 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://toapis.com/v1/videos/generations",
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' => '<string>',
'action' => '<string>',
'prompt' => '<string>',
'image_urls' => [
'<string>'
],
'reference_images' => [
'<string>'
],
'url' => '<string>',
'audio_setting' => '<string>',
'duration' => 123,
'resolution' => '<string>',
'aspect_ratio' => '<string>',
'seed' => 123,
'watermark' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$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://toapis.com/v1/videos/generations"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"action\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image_urls\": [\n \"<string>\"\n ],\n \"reference_images\": [\n \"<string>\"\n ],\n \"url\": \"<string>\",\n \"audio_setting\": \"<string>\",\n \"duration\": 123,\n \"resolution\": \"<string>\",\n \"aspect_ratio\": \"<string>\",\n \"seed\": 123,\n \"watermark\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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://toapis.com/v1/videos/generations")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"action\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image_urls\": [\n \"<string>\"\n ],\n \"reference_images\": [\n \"<string>\"\n ],\n \"url\": \"<string>\",\n \"audio_setting\": \"<string>\",\n \"duration\": 123,\n \"resolution\": \"<string>\",\n \"aspect_ratio\": \"<string>\",\n \"seed\": 123,\n \"watermark\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://toapis.com/v1/videos/generations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"action\": \"<string>\",\n \"prompt\": \"<string>\",\n \"image_urls\": [\n \"<string>\"\n ],\n \"reference_images\": [\n \"<string>\"\n ],\n \"url\": \"<string>\",\n \"audio_setting\": \"<string>\",\n \"duration\": 123,\n \"resolution\": \"<string>\",\n \"aspect_ratio\": \"<string>\",\n \"seed\": 123,\n \"watermark\": true\n}"
response = http.request(request)
puts response.read_body- 對外模型固定爲
happyhorse-1.1 - 通過
action區分文生視頻、首幀圖生視頻、參考圖生視頻和視頻編輯 - 未傳
action時,存在首幀圖會自動按圖生視頻處理,否則按文生視頻處理 - 異步任務管理,通過任務 ID 查詢結果
Authorizations
string
必填
所有接口均需要使用 Bearer Token 進行認證。
Authorization: Bearer YOUR_API_KEY
Body
string
預設值:"happyhorse-1.1"
必填
視頻生成模型名稱,固定爲
happyhorse-1.1。string
預設值:"text-to-video"
生成模式。可選項:
text-to-video- 文生視頻image-to-video- 首幀圖生視頻reference-to-video- 參考圖生視頻video-edit- 視頻編輯
string
視頻內容描述。文生視頻、參考圖生視頻和視頻編輯必填。首幀圖生視頻可選,但建議填寫以控制畫面運動和風格。
string[]
圖生視頻首幀圖片 URL。僅使用第一張圖片。也可以使用兼容字段
input_reference、images、image 或 image_with_roles[{ role: "first_frame" }]。圖片要求:- 格式:
JPEG、JPG、PNG、BMP、WEBP - 文件大小:不超過
10MB - 寬高:不小於
300px - 寬高比:
1:2.5到2.5:1
string[]
參考圖片 URL 列表。
reference-to-video 必填,支持 1 到 9 張;video-edit 可選,最多 5 張。string
視頻編輯的輸入視頻 URL。
action=video-edit 時必填。string
預設值:"auto"
視頻編輯的聲音控制。僅
action=video-edit 有效。可選項:autoorigin
integer
預設值:5
視頻時長,單位秒。可選範圍:
3 到 15。string
預設值:"1080P"
視頻分辨率。可選項:
720P1080P
string
預設值:"16:9"
文生視頻寬高比。圖生視頻會根據首幀圖決定畫幅。可選項:
16:99:161:14:33:4
size。integer
隨機種子,用於控制生成結果的確定性。
boolean
預設值:true
是否添加水印。
文生視頻示例
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header "Authorization: Bearer YOUR_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "happyhorse-1.1",
"action": "text-to-video",
"prompt": "夜晚的鐵路橋下,一個塗鴉少年從牆上活過來,一邊快速演唱英文 rap,一邊做出充滿活力的說唱動作。",
"duration": 10,
"resolution": "1080P",
"aspect_ratio": "16:9",
"seed": 42,
"watermark": true
}'
圖生視頻示例
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header "Authorization: Bearer YOUR_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "happyhorse-1.1",
"action": "image-to-video",
"prompt": "讓圖片中的角色自然動起來,保持原始畫面風格。",
"image_urls": ["https://example.com/first-frame.png"],
"duration": 5,
"resolution": "1080P"
}'
參考圖生視頻示例
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header "Authorization: Bearer YOUR_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "happyhorse-1.1",
"action": "reference-to-video",
"prompt": "圖 1 中的主角在圖 2 的場景中奔跑,隨後拿起圖 3 中的道具。畫面保持 3D 卡通風格。",
"reference_images": [
"https://example.com/image-01.jpg",
"https://example.com/image-02.png",
"https://example.com/image-03.jpeg"
],
"duration": 5,
"resolution": "1080P",
"aspect_ratio": "16:9",
"watermark": false
}'
視頻編輯示例
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header "Authorization: Bearer YOUR_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "happyhorse-1.1",
"action": "video-edit",
"prompt": "讓視頻中的場景更有電影感,保留主體動作。",
"url": "https://example.com/input.mp4",
"reference_images": ["https://example.com/reference.png"],
"resolution": "1080P",
"audio_setting": "origin",
"seed": 42
}'
查詢任務
提交接口會返回任務 ID。使用通用視頻任務查詢接口獲取狀態和結果:curl --request GET \
--url https://toapis.com/v1/videos/generations/{task_id} \
--header "Authorization: Bearer YOUR_API_KEY"
渠道配置
HappyHorse 使用 DashScope API Key。默認上游地址爲https://dashscope.aliyuncs.com。
如需使用國際站,在管理後臺將該渠道的 Base URL 覆蓋爲:
https://dashscope-intl.aliyuncs.com
⌘I