图像生成视频(创建任务)¶
POST /api/v5/video/generate
调用此接口创建视频生成任务,如果没有异常返回,可根据 request_id 异步查询视频生成结果。
访问令牌支持说明¶
- AtomGit 用户访问令牌(AtomGit user access tokens)
是否允许匿名访问¶
此接口允许匿名访问
请求参数¶
| 参数名 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
Authorization |
header | string | 否 | 用户个人令牌;匿名访问时可携带也可省略 |
Request Body:
请求体为 JSON 对象,包含图片、模型与提示词等参数。
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"img_url": {
"description": "输入图片,支持 Base64 或图片 URL",
"type": "string"
},
"model": {
"description": "模型名称",
"type": "string"
},
"prompt": {
"description": "提示词",
"type": "string"
},
"seed": {
"description": "随机种子",
"type": "integer",
"format": "int64",
"minimum": 0,
"maximum": 2147483648,
"default": 0
}
},
"required": ["img_url", "model", "prompt"]
}
响应参数¶
| 字段 | 类型 | 必返 | 可为空 | 说明 |
|---|---|---|---|---|
request_id |
string | 是 | 否 | 请求 ID,用于异步查询视频生成结果 |
status |
string | 是 | 否 | 处理状态,如 running |
error_message |
string | 否 | 是 | 错误信息(仅异常时出现) |
失败响应¶
该接口在参数缺失或凭证无效时可能返回 400 / 401,错误结构以后端实际返回为准,以下示例仅供示意。
400 参数错误
401 未认证
HTTP 响应状态码¶
| 状态码 | 说明 |
|---|---|
200 |
成功(OK) |
400 |
参数错误(Bad Request) |
401 |
需要认证(Requires authentication) |
500 |
系统内部错误(Internal Server Error) |
请求示例¶
参数说明¶
<img_url> 替换为图片地址或 Base64 数据;<model> 替换为模型名称(如 Wan2.2-I2V-A14B);<prompt> 替换为提示词;<seed> 替换为随机种子(可选,默认 0,范围 0 ~ 2147483648)。本接口允许匿名访问,也可携带 Authorization 头传入用户令牌。
cURL¶
curl -X POST 'https://api.atomgit.com/api/v5/video/generate' \
-H 'Content-Type: application/json' \
-d '{
"img_url": "https://api.atomgit.com/images/example.png",
"model": "Wan2.2-I2V-A14B",
"prompt": "小猫在散步",
"seed": 0
}'
JavaScript¶
// 原生 fetch (Node.js 18+ / 浏览器)
const response = await fetch("https://api.atomgit.com/api/v5/video/generate", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
img_url: "https://api.atomgit.com/images/example.png",
model: "Wan2.2-I2V-A14B",
prompt: "小猫在散步",
seed: 0,
}),
});
if (!response.ok) {
throw new Error(`请求失败: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
resp = requests.post(
"https://api.atomgit.com/api/v5/video/generate",
headers={"Content-Type": "application/json"},
json={
"img_url": "https://api.atomgit.com/images/example.png",
"model": "Wan2.2-I2V-A14B",
"prompt": "小猫在散步",
"seed": 0,
},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
响应示例¶
状态码: 200
错误码¶
| 错误码 | 说明 |
|---|---|
400 |
参数错误或请求无法解析 |
401 |
未认证或凭证无效(缺少/无效的访问凭证) |
500 |
系统内部错误 |
本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 gitcode-dev/atomgit-api-doc