创建素材
curl --request POST \
--url https://xxx.wengaocloud.com/v1/assets \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"asset_type": "image",
"source_url": "https://example.com/avatar-reference.png"
}
'import requests
url = "https://xxx.wengaocloud.com/v1/assets"
payload = {
"asset_type": "image",
"source_url": "https://example.com/avatar-reference.png"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({asset_type: 'image', source_url: 'https://example.com/avatar-reference.png'})
};
fetch('https://xxx.wengaocloud.com/v1/assets', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://xxx.wengaocloud.com/v1/assets"
payload := strings.NewReader("{\n \"asset_type\": \"image\",\n \"source_url\": \"https://example.com/avatar-reference.png\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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))
}{
"id": "asset_6f9a4c2b8d1e3a90",
"uri": "asset://asset_6f9a4c2b8d1e3a90",
"object": "asset",
"asset_type": "image",
"name": "avatar-reference",
"status": "processing",
"created_at": 1779782400,
"updated_at": 1779782400
}{
"error": {
"type": "invalid_request_error",
"code": "model_endpoint_mismatch",
"message": "该模型不支持当前 endpoint。"
}
}{
"error": {
"type": "invalid_request_error",
"code": "model_endpoint_mismatch",
"message": "该模型不支持当前 endpoint。"
}
}视频生成
创建素材
提交公网 HTTPS 素材 URL,或直接以 multipart/form-data 上传本地文件。平台将素材保存到平台存储并开始处理,返回平台素材 ID(asset_xxx)。
公开素材上传接口不需要传入 model 或模型 ID,平台内部按当前视频素材供应商配置完成路由。
素材处理完成(status=active)后才可用于视频生成,传入格式为 asset://asset_xxx。
创建素材
curl --request POST \
--url https://xxx.wengaocloud.com/v1/assets \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"asset_type": "image",
"source_url": "https://example.com/avatar-reference.png"
}
'import requests
url = "https://xxx.wengaocloud.com/v1/assets"
payload = {
"asset_type": "image",
"source_url": "https://example.com/avatar-reference.png"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({asset_type: 'image', source_url: 'https://example.com/avatar-reference.png'})
};
fetch('https://xxx.wengaocloud.com/v1/assets', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://xxx.wengaocloud.com/v1/assets"
payload := strings.NewReader("{\n \"asset_type\": \"image\",\n \"source_url\": \"https://example.com/avatar-reference.png\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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))
}{
"id": "asset_6f9a4c2b8d1e3a90",
"uri": "asset://asset_6f9a4c2b8d1e3a90",
"object": "asset",
"asset_type": "image",
"name": "avatar-reference",
"status": "processing",
"created_at": 1779782400,
"updated_at": 1779782400
}{
"error": {
"type": "invalid_request_error",
"code": "model_endpoint_mismatch",
"message": "该模型不支持当前 endpoint。"
}
}{
"error": {
"type": "invalid_request_error",
"code": "model_endpoint_mismatch",
"message": "该模型不支持当前 endpoint。"
}
}提交公网 HTTPS 素材 URL,或直接以
创建素材为异步接口,受理后返回
创建素材为异步接口,系统处理完成后素材状态变为
响应(202 Accepted):
multipart/form-data 上传本地文件。平台会将素材保存到平台存储并开始处理,返回平台素材 ID(asset_xxx)。
POST /v1/assets
Authorization: Bearer <API_KEY>
status=processing。需要轮询 GET /v1/assets/{id} 等待 status=active 后,才可在视频生成中使用该素材。
公开接口不需要传入 model 或模型 ID。素材上传会由平台内部按当前视频素材供应商配置完成路由。
视频生成请求中使用
uri 字段的值(即 asset://asset_xxx),不要使用 id 字段。传入时必须保留 asset:// 前缀。请求参数
JSON URL 上传
POST /v1/assets
Authorization: Bearer <API_KEY>
Content-Type: application/json
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
asset_type | string | 是 | 素材类型:image、video、audio。 |
source_url | string | 是 | 公网可访问的 HTTPS URL,平台下载校验并保存。 |
name | string | 否 | 素材名称,仅允许中文、字母、数字、下划线和短横线;未传时平台使用默认名称。 |
文件上传
POST /v1/assets
Authorization: Bearer <API_KEY>
Content-Type: multipart/form-data
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
file | file | 是 | 要上传的图片、视频或音频文件。 |
asset_type | string | 是 | 素材类型:image、video、audio。 |
name | string | 否 | 素材名称,仅允许中文、字母、数字、下划线和短横线;未传时平台使用默认名称。 |
active。需轮询 GET /v1/assets/{id} 等待 status=active 后,才可在视频生成请求中使用。
视频生成时使用
uri 字段的值(即 asset://asset_xxx),不要使用 id 字段。传入时必须保留 asset:// 前缀。素材格式要求
| 类型 | 格式 | 大小限制 |
|---|---|---|
| 图片 | jpeg、png、webp、bmp、tiff、gif | 小于 30 MB;宽高比 (0.4, 2.5);分辨率 300–6000 px |
| 视频 | mp4、mov | 小于 50 MB;建议 2–15 秒 |
| 音频 | wav、mp3 | 小于 15 MB;建议 2–15 秒 |
示例
JSON URL 上传
curl -X POST "https://{your-domain}/v1/assets" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "avatar-reference",
"asset_type": "image",
"source_url": "https://example.com/avatar-reference.png"
}'
文件上传
curl -X POST "https://{your-domain}/v1/assets" \
-H "Authorization: Bearer $API_KEY" \
-F "asset_type=image" \
-F "name=avatar-reference" \
-F "file=@./avatar-reference.png"
{
"id": "asset_6f9a4c2b8d1e3a90",
"uri": "asset://asset_6f9a4c2b8d1e3a90",
"object": "asset",
"asset_type": "image",
"name": "avatar-reference",
"status": "processing",
"created_at": 1779782400,
"updated_at": 1779782400
}
响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 平台素材 ID,格式 asset_xxx。 |
uri | string | 素材 URI,格式 asset://asset_xxx。视频生成时使用此字段。 |
object | string | 固定为 asset。 |
asset_type | string | 素材类型:image、video、audio。 |
name | string | 素材名称。 |
status | string | 素材状态,见下方状态说明。 |
created_at | integer | 创建时间,Unix 秒。 |
updated_at | integer | 最后更新时间,Unix 秒。 |
素材状态
| 状态 | 说明 | 可用于视频生成 | 下一步操作 |
|---|---|---|---|
processing | 平台已受理,正在保存或处理。 | 否 | 继续轮询 |
active | 素材可用。 | 是 | 可以在视频生成中使用 |
failed | 素材处理失败。 | 否 | 重新上传 |
disabled | 素材已被平台禁用。 | 否 | 联系平台 |
错误码
| HTTP 状态码 | error.type | 场景 |
|---|---|---|
| 400 | invalid_asset_type | asset_type 不是 image、video 或 audio。 |
| 400 | invalid_asset_name | name 包含不支持的字符。 |
| 400 | invalid_asset_url | source_url 非 HTTPS、公网不可访问、格式不合法。 |
| 400 | invalid_multipart_request | multipart/form-data 请求解析失败。 |
| 400 | invalid_asset_file | 上传文件格式、大小、尺寸、时长等不符合素材要求。 |
| 503 | asset_store_unavailable | 平台素材存储未配置。 |
授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
请求体
application/jsonmultipart/form-data
响应
素材已受理,正在处理中。
平台素材 ID,格式 asset_xxx。
示例:
"asset_6f9a4c2b8d1e3a90"
素材 URI,格式 asset://asset_xxx,视频生成请求中使用此值。
示例:
"asset://asset_6f9a4c2b8d1e3a90"
可用选项:
asset 可用选项:
image, video, audio 素材状态:processing(处理中,不可用于生成)、active(可用)、
failed(处理失败)、disabled(已禁用)。
可用选项:
processing, active, failed, disabled 平台保存后的素材访问地址,通常为平台 CDN 地址;仅在列表接口传入 include_resource_url=1 且素材类型为图片或视频时返回。
.png?fit=max&auto=format&n=v_sJS-AFS6goKAv3&q=85&s=e03202fddb83c95be2a503ab9c79163a)