接口说明
视频生成(万相)
shell
POST https://api.scnet.cn/api/llm/v1/videos/generations
GET https://api.scnet.cn/api/llm/v1/tasks/{task_id}
POST https://api.scnet.cn/api/llm/v1/tasks
POST https://api.scnet.cn/api/llm/v1/tasks/{task_id}/cancel1.功能介绍
万相文生视频接口(Wan2.7-T2V)用于根据输入的文本提示词创建视频生成任务。视频生成任务为异步任务,提交任务后会返回任务 ID,您需要通过查询任务状态接口获取任务状态和生成视频地址。
调用流程:
- 调用提交生成任务接口,获取任务 ID。
- 使用任务 ID 查询任务状态。
- 任务成功后,从查询响应中的
output.results获取生成视频地址。 - 如需取消排队中或处理中的任务,可调用取消任务接口。
2.提交生成任务
shell
POST https://api.scnet.cn/api/llm/v1/videos/generations2.1 请求参数
Header 参数
| 名称 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| Content-Type | string | 是 | application/json | \ |
| Authorization | string | 是 | Bearer <API Key> | \ |
| X-MultiModal-Async | string | 是 | true | 视频生成为异步任务,必须传 true。提交后返回任务 ID,需轮询任务状态接口获取生成视频地址。 |
Body 参数
| 名称 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| model | string | 是 | \ | 调用模型的名称。例如:Wan2.7-T2V。 |
| input | object | 是 | \ | 输入给模型用于生成视频的信息。 |
| parameters | object | 否 | \ | 视频生成参数配置,包括分辨率、比例、时长、提示词扩展、水印等。 |
input 参数说明
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| prompt | string | 是 | 文本提示词,用来描述期望生成的视频内容。 |
| negative_prompt | string | 否 | 反向提示词,用来描述不希望在视频画面中看到的内容,可以对视频画面进行限制。 |
| audio_url | string | 否 | 音频文件URL,模型将使用该音频生成视频。 |
parameters 参数说明
| 名称 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| resolution | string | 否 | \ | 生成视频的分辨率,如 480p/720p/1080p。 |
| ratio | string | 否 | \ | 生成视频的宽高比,如 16:9/9:16。 |
| duration | integer | 否 | \ | 生成视频的时长,单位为秒,取值范围 [2, 15]。 |
| prompt_extend | boolean | 否 | \ | 是否开启提示词扩展。开启后会对提示词进行扩写优化。 |
| watermark | boolean | 否 | \ | 生成视频是否包含水印。 |
| seed | integer | 否 | \ | 随机种子,取值范围 [0, 2147483647]。 |
2.2 响应参数
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| request_id | string | 是 | 请求唯一标识。可用于请求明细溯源和问题排查。 |
| output | object | 是 | 任务输出信息。 |
| output.task_id | string | 是 | 视频生成任务 ID。提交任务后,需使用该 ID 查询任务状态。 |
| output.task_status | string | 是 | 任务状态。提交成功后通常为 pending。 |
2.3 请求示例
cURL请求示例
shell
curl -X POST 'https://api.scnet.cn/api/llm/v1/videos/generations' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <API Key>' \
-H 'X-MultiModal-Async: true' \
--data-raw '{
"model": "Wan2.7-T2V",
"input": {
"prompt": "一只金毛犬在海边奔跑,夕阳西下,海浪轻轻拍打沙滩"
},
"parameters": {
"resolution": "1080p",
"ratio": "16:9",
"duration": 5,
"prompt_extend": true,
"watermark": false,
"seed": 42
}
}'Python请求示例
python
import requests
url = "https://api.scnet.cn/api/llm/v1/videos/generations"
payload = {
"model": "Wan2.7-T2V",
"input": {
"prompt": "一只金毛犬在海边奔跑,夕阳西下,海浪轻轻拍打沙滩"
},
"parameters": {
"resolution": "1080p",
"ratio": "16:9",
"duration": 5,
"prompt_extend": True,
"watermark": False,
"seed": 42
}
}
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer <API Key>",
"X-MultiModal-Async": "true"
}
response = requests.post(url, headers=headers, json=payload)
print(response.text)2.4 响应示例
json
{
"request_id": "93181007-6691-9bf8-810d-c04e37959265",
"output": {
"task_id": "2069294934625923074",
"task_status": "pending"
}
}3.查询任务状态
shell
GET https://api.scnet.cn/api/llm/v1/tasks/{task_id}3.1 请求参数
Header 参数
| 名称 | 类型 | 必填 | 示例值 |
|---|---|---|---|
| Content-Type | string | 是 | application/json |
| Authorization | string | 是 | Bearer <API Key> |
Path 参数
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| task_id | string | 是 | 需要查询的视频生成任务 ID。 |
3.2 响应参数
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| request_id | string | 是 | 请求唯一标识。可用于请求明细溯源和问题排查。 |
| output | object | 是 | 任务输出信息。 |
| output.task_id | string | 是 | 视频生成任务 ID。 |
| output.task_status | string | 是 | 任务状态。常见值包括 pending、running、succeeded、failed、cancelled。 |
| output.submit_time | string | 否 | 任务提交时间。 |
| output.end_time | string | 否 | 任务结束时间。 |
| output.results | array | 否 | 生成视频的下载地址列表。任务成功后返回。 |
| output.error_code | string | 否 | 错误码。任务失败时返回。 |
| output.error_message | string | 否 | 错误信息。任务失败时返回。 |
| usage | object | 否 | 本次请求的用量信息。 |
| usage.video_count | integer | 否 | 生成视频数量。 |
| usage.video_duration | integer | 否 | 生成视频的时长,单位为秒。 |
| usage.resolution | string | 否 | 生成视频的分辨率档位,如 720p。 |
| usage.ratio | string | 否 | 生成视频的宽高比,如 16:9。 |
3.3 请求示例
cURL请求示例
shell
curl -X GET 'https://api.scnet.cn/api/llm/v1/tasks/<task_id>' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <API Key>'Python请求示例
python
import requests
task_id = "<task_id>"
url = f"https://api.scnet.cn/api/llm/v1/tasks/{task_id}"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer <API Key>"
}
response = requests.get(url, headers=headers)
print(response.text)3.4 响应示例
json
{
"request_id": "a4205108-eefa-9f6c-a7f4-3509357abbd5",
"output": {
"task_id": "2069294934625923074",
"task_status": "succeeded",
"submit_time": "2026-05-29 10:26:49.775",
"end_time": "2026-05-29 10:27:21.393",
"results": [
"https://example.com/video.mp4"
]
},
"usage": {
"video_count": 1,
"video_duration": 5,
"resolution": "1080p",
"ratio": "16:9"
}
}4.批量查询任务状态
shell
POST https://api.scnet.cn/api/llm/v1/tasks请求体传入 task_ids 数组(单次最多 10 个),响应为数组,每个元素的结构与查询任务状态的响应一致。
shell
curl -X POST 'https://api.scnet.cn/api/llm/v1/tasks' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <API Key>' \
--data-raw '{
"task_ids": [
"2069294934625923074",
"2069294934625923075"
]
}'5.取消任务
shell
POST https://api.scnet.cn/api/llm/v1/tasks/{task_id}/cancel仅非终态任务(pending、running 等)可以取消。已处于终态(succeeded、failed、cancelled)的任务无法取消。取消成功后 output.task_status 为 cancelled。
shell
curl -X POST 'https://api.scnet.cn/api/llm/v1/tasks/<task_id>/cancel' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <API Key>'6.任务状态说明
| 状态 | 描述 |
|---|---|
| pending | 任务等待调度。 |
| running | 任务运行中。 |
| succeeded | 任务成功,可从查询响应中的 output.results 获取生成视频地址。 |
| failed | 任务失败,可从 output.error_code 与 output.error_message 获取失败原因。 |
| cancelled | 任务已取消。 |
7.注意事项
- 万相文生视频为异步任务,提交任务时请求头必须携带
X-MultiModal-Async: true,提交任务后不会立即返回视频地址。 - 仅需在
input.prompt中传入文本提示词即可发起文生视频任务。 - 批量查询任务单次最多查询 10 个任务 ID。