视频生成
最后更新:2026-11-14
POSThttps://www.sagelib.com/videos
将文本、图片作为输入,自动生成视频内容。当前支持文生视频、图生视频。
接口鉴权方式请参考:API接入与鉴权
当前展示通用接口文档,各模型支持的参数存在差异。请点击下方模型标签查看专属文档。
请求参数
请求头
| 参数名称 | 描述 |
|---|---|
*Authorization string |
鉴权令牌,格式为 Bearer ${AIGATEWAY_TOKEN} |
*Content-Type string |
可选值:multipart/form-data、application/json multipart/form-data 或 application/json |
Body 参数
| 参数名称 | 描述 |
|---|---|
*model string |
默认值:Per AI gateway configuration 可选值:sora-2、sora-2-pro、MiniMax-Hailuo-2.3、viduq2 模型名称 |
*prompt string |
文本描述,用于指导视频生成 |
seconds integer |
默认值:4 可选值:Model dependent 视频时长(秒) |
size string |
默认值:Model default 可选值:MiniMax-Hailuo-02 and MiniMax-Hailuo-2.3: 768P, 1080P; sora-2: 720x1280, 1280x720; sora-2-pro: 720x1280, 1280x720, 1792x1024, 1024x1792; viduq2/viduq2-pro: 540p, 720p, 1080p 视频分辨率,格式为"宽度x高度"或"720P/1080P" |
input_reference array |
参考图片URL/Base64格式或文件(用于图生视频)。表单格式示例 -F "input_reference=@calico_cat_reference.png;type=image/png";JSON请求示例 "input_reference": [{"eca_voice":"xx","image":["http://example.com/example.jpeg"]}] |
eca_id string |
主体ID(Subject ID),可通过 @subjectId 在提示词中使用(部分模型支持,如vidu系列) |
eca_voice string |
默认值:Model recommended 可选值:vidu voice list 主体语音标识,模型会自动推荐合适的语音(部分模型支持,如vidu系列)。vidu音色列表:https://shengshu.feishu.cn/sheets/EgFvs6DShhiEBStmjzccr5gonOg |
image array |
对应主体的图片URL列表。每个主体最多支持3张图片,可通过URL或Base64编码提供。必须使用以下编码格式之一:PNG、JPEG、JPG、WebP。图片尺寸至少为128x128像素,图片宽高比需小于1:4或4:1,单张图片大小限制为50MB,HTTP请求体大小不超过20MB且必须包含正确的Content-Type头信息。JSON示例 "image": ["http://example.com/example.jpeg","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..."] |
eca_first_frame string |
首帧图片URL/Base64格式或文件。表单格式示例 -F "eca_first_frame=@calico_first_reference.png;type=image/png";JSON请求示例 "eca_first_frame": "http://example.com/example.jpeg" |
eca_last_frame string |
尾帧图片URL/Base64格式或文件。表单格式示例 -F "eca_last_frame=@calico_last_reference.png;type=image/png";JSON请求示例 "eca_last_frame": "http://example.com/example.jpeg" |
eca_audio boolean |
默认值:false 可选值:true、false 是否生成音频(部分模型支持,如vidu系列)。false:不需要音视频直出,输出静音视频;true:需要音视频直出,输出带台词以及背景音的视频 |
eca_voice string |
默认值:Model recommended 可选值:vidu voice list 用来决定视频中的声音音色,为空时模型会自动推荐(部分模型支持,如vidu系列),eca_audio=true生效。vidu音色列表:https://shengshu.feishu.cn/sheets/EgFvs6DShhiEBStmjzccr5gonOg |
eca_aspect_ratio string |
默认值:Model default 可选值:viduq2: 16:9, 9:16, 4:3, 3:4, 1:1 视频宽高比(部分模型使用,如viduq2) |
请求示例
curl -v 'https://www.sagelib.com/videos' \
-H "Authorization: Bearer ***" \
-H "Content-Type: application/json" \
-d '{
"model": "sora-2",
"seconds": 8,
"size": "1280x720",
"prompt": "A calico cat playing a piano on stage"
}'
import json
import requests
base_url = "https://www.sagelib.com"
api_key = "***"
url = f"https://www.sagelib.com/videos"
headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}
data = {
"model": "sora-2",
"seconds": 8,
"size": "1280x720",
"prompt": "A calico cat playing a piano on stage"
}
response = requests.post(url, headers=headers, json=data)
print(f"Status Code: {response.status_code}")
try:
print(json.dumps(response.json(), indent=2, ensure_ascii=False))
except Exception:
print(response.text)
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class LlmStreamClient {
public static void main(String[] args) {
String baseUrl = "https://www.sagelib.com";
String apiKey = "***";
String url = "https://www.sagelib.com/videos";
String jsonRequestBody = """
{
"model": "sora-2",
"seconds": 8,
"size": "1280x720",
"prompt": "A calico cat playing a piano on stage"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonRequestBody))
.build();
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Status Code: " + response.statusCode());
System.out.println(response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
baseUrl := "https://www.sagelib.com"
apiKey := "***"
url := "https://www.sagelib.com/videos"
jsonRequestBody := `
{
"model": "sora-2",
"seconds": 8,
"size": "1280x720",
"prompt": "A calico cat playing a piano on stage"
}
`
req, err := http.NewRequest("POST", url, bytes.NewBufferString(jsonRequestBody))
if err != nil {
fmt.Println("Failed to create request:", err)
return
}
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Request failed:", err)
return
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
var prettyBody map[string]interface{}
if err := json.Unmarshal(body, &prettyBody); err == nil {
pretty, _ := json.MarshalIndent(prettyBody, "", " ")
fmt.Println("Status Code:", resp.StatusCode)
fmt.Println(string(pretty))
} else {
fmt.Println("Status Code:", resp.StatusCode)
fmt.Println(string(body))
}
}
curl -v 'https://www.sagelib.com/videos' \
-H "Authorization: Bearer ***" \
-H "Content-Type: application/json" \
-d '{
"model": "sora-2",
"prompt": "A calico cat playing a piano on stage",
"seconds": 8,
"size": "1280x720",
"input_reference": [
{
"eca_id": "subject_001",
"image": [
"http://example.com/example.jpeg"
]
}
],
"eca_audio": true,
"eca_aspect_ratio": "16:9"
}'
import json
import requests
base_url = "https://www.sagelib.com"
api_key = "***"
url = f"https://www.sagelib.com/videos"
headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}
data = {
"model": "sora-2",
"prompt": "A calico cat playing a piano on stage",
"seconds": 8,
"size": "1280x720",
"input_reference": [
{
"eca_id": "subject_001",
"image": [
"http://example.com/example.jpeg"
]
}
],
"eca_audio": True,
"eca_aspect_ratio": "16:9"
}
response = requests.post(url, headers=headers, json=data)
print(f"Status Code: {response.status_code}")
try:
print(json.dumps(response.json(), indent=2, ensure_ascii=False))
except Exception:
print(response.text)
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class LlmStreamClient {
public static void main(String[] args) {
String baseUrl = "https://www.sagelib.com";
String apiKey = "***";
String url = "https://www.sagelib.com/videos";
String jsonRequestBody = """
{
"model": "sora-2",
"prompt": "A calico cat playing a piano on stage",
"seconds": 8,
"size": "1280x720",
"input_reference": [
{
"eca_id": "subject_001",
"image": [
"http://example.com/example.jpeg"
]
}
],
"eca_audio": true,
"eca_aspect_ratio": "16:9"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonRequestBody))
.build();
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Status Code: " + response.statusCode());
System.out.println(response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
baseUrl := "https://www.sagelib.com"
apiKey := "***"
url := "https://www.sagelib.com/videos"
jsonRequestBody := `
{
"model": "sora-2",
"prompt": "A calico cat playing a piano on stage",
"seconds": 8,
"size": "1280x720",
"input_reference": [
{
"eca_id": "subject_001",
"image": [
"http://example.com/example.jpeg"
]
}
],
"eca_audio": true,
"eca_aspect_ratio": "16:9"
}
`
req, err := http.NewRequest("POST", url, bytes.NewBufferString(jsonRequestBody))
if err != nil {
fmt.Println("Failed to create request:", err)
return
}
req.Header.Set("Authorization", "Bearer "+apiKey)
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Request failed:", err)
return
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
var prettyBody map[string]interface{}
if err := json.Unmarshal(body, &prettyBody); err == nil {
pretty, _ := json.MarshalIndent(prettyBody, "", " ")
fmt.Println("Status Code:", resp.StatusCode)
fmt.Println(string(pretty))
} else {
fmt.Println("Status Code:", resp.StatusCode)
fmt.Println(string(body))
}
}
响应参数
Body 参数
| 参数名称 | 描述 |
|---|---|
id string |
视频生成任务的唯一标识符 |
object string |
可选值:video 对象类型,固定为 "video" |
status string |
任务状态,如 "queued"(排队中) |
响应示例
{
"id": "video_123",
"object": "video",
"status": "queued"
}
状态码
| HTTP状态码 | 描述 |
|---|---|
| 200 | 请求成功 |
| 401 | 访问被拒绝,拒绝原因见响应主体。可能的原因有:缺少Authorization请求头,token错误等。 |
| 403 | 访问被拒绝,拒绝原因见响应主体。可能的原因有:请求主体格式错误、请求主体缺少必要参数等。 |
| 500 | 服务器内部错误,原因见响应主体 |