知识库
知识wiki
Agnes Video v2.0 AI视频生成 API 使用指南
!!! note "" Agnes AI 的视频生成 API,当前为免费使用期,支持 Text-to-Video、Image-to-Video 等多种模式。
基本信息
| 项目 | 值 |
|---|---|
| 模型 | agnes-video-v2.0 |
| Endpoint | https://apihub.agnes-ai.com/v1/videos |
| 认证方式 | Bearer Token |
| 工作模式 | 异步(创建任务 → 轮询结果) |
| 状态 | 🆓 免费使用期 |
认证
在请求头中携带 Bearer Token:
Authorization: Bearer <your_api_key>
API Key 存储在服务器本地文件 ~/.agnes_api_key,备用 Key 存储在 ~/.agnes_api_key_old。
API 调用流程
整个流程分为两步:创建任务 → 轮询结果。
1. 创建视频生成任务
POST https://apihub.agnes-ai.com/v1/videos
Content-Type: application/json
Authorization: Bearer <your_api_key>
{
"model": "agnes-video-v2.0",
"prompt": "一只橘猫在草地上追蝴蝶,阳光明媚",
"width": 1152,
"height": 768,
"num_frames": 121,
"frame_rate": 24
}
成功返回:
{
"task_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
2. 轮询任务状态
GET https://apihub.agnes-ai.com/v1/videos/{task_id}
Authorization: Bearer <your_api_key>
返回示例(进行中):
{
"status": "in_progress",
"progress": 65
}
返回示例(完成):
{
"status": "completed",
"progress": 100,
"remixed_from_video_id": "https://..."
}
返回示例(失败):
{
"status": "failed",
"progress": 0,
"error": "error message"
}
请求参数
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
model |
string | — | 必填。模型名称,固定为 agnes-video-v2.0 |
prompt |
string | — | 必填。视频描述 prompt |
width |
integer | 1152 |
视频宽度(像素) |
height |
integer | 768 |
视频高度(像素) |
num_frames |
integer | 121 |
总帧数(约 5 秒 @ 24fps) |
frame_rate |
integer | 24 |
帧率(fps) |
响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
status |
string | 任务状态:queued / in_progress / completed / failed |
progress |
integer | 进度百分比,0–100 |
remixed_from_video_id |
string | 视频下载 URL(完成时返回)。注意字段名并非 video_url |
error |
string | 错误信息(失败时返回) |
输出规格
| 规格 | 值 |
|---|---|
| 分辨率 | 1152 × 768 |
| 时长 | 约 5 秒(121 帧 @ 24fps) |
| 格式 | MP4 |
| 文件大小 | 约 1.4 MB |
支持的功能模式
- Text-to-Video — 纯文本描述生成视频
- Image-to-Video — 参考图片生成视频
- Keyframe — 关键帧控制
- Scene Motion — 场景运动控制
注意事项
- 每日调用次数限制 — 免费期有配额上限,超出后请求被拒绝
- 准备多个 Key 备用 — 建议准备多个 API Key 轮流使用,避免单 Key 配额耗尽影响业务
- 视频 URL 字段名 — 视频下载地址在
remixed_from_video_id字段中,不是video_url,注意不要找错字段 - 异步轮询 — 视频生成需要时间(约 30–60 秒),建议每隔 5–10 秒轮询一次状态
快速示例(curl)
创建任务
curl -s -X POST https://apihub.agnes-ai.com/v1/videos \
-H "Authorization: Bearer $(cat ~/.agnes_api_key)" \
-H "Content-Type: application/json" \
-d '{
"model": "agnes-video-v2.0",
"prompt": "日落海滩,海浪拍打沙滩,暖色调光线",
"width": 1152,
"height": 768,
"num_frames": 121,
"frame_rate": 24
}'
轮询结果
TASK_ID="<上一步返回的task_id>"
curl -s https://apihub.agnes-ai.com/v1/videos/$TASK_ID \
-H "Authorization: Bearer $(cat ~/.agnes_api_key)" | jq .
轮询直到完成
TASK_ID="<task_id>"
while true; do
resp=$(curl -s https://apihub.agnes-ai.com/v1/videos/$TASK_ID \
-H "Authorization: Bearer $(cat ~/.agnes_api_key)")
status=$(echo "$resp" | jq -r '.status')
progress=$(echo "$resp" | jq -r '.progress // 0')
echo "Status: $status, Progress: $progress%"
if [ "$status" = "completed" ] || [ "$status" = "failed" ]; then
echo "$resp" | jq .
break
fi
sleep 5
done
相关配置
API Key 管理方式见 API Key 管理。


黑公网安备 23010302001359号