Agnes 模型 API 调用指南
直接用 HTTP 调用 Agnes 视频模型——无需任何第三方工具,含完整 Python 代码示例
前置条件
在开始调用 API 之前,你需要:
- 一个有效的 Agnes API Key(从 Agnes Cloud Platform 获取)
- 基础的 HTTP 请求知识(本文以 Python 为例,任意语言均可)
API 端点
POST
https://api.agnes-ai.com/v1/video/generate
认证方式
所有 API 请求需在 Header 中携带 Bearer Token 认证:
// Authorization header
Authorization: Bearer YOUR_API_KEY
请求体
发送 POST 请求,JSON body 中包含以下参数:
{
"prompt": "A cat walking through a neon-lit Tokyo alley",
"duration": 5,
"resolution": "1080p",
"style": "cinematic",
"narration": true,
"narration_lang": "en",
"subtitles": true
}参数说明
| 参数名 | 类型 | 必需 | 说明 |
|---|---|---|---|
| prompt | string | 是 | 视频描述文本(中英文均可),建议 20-200 字 |
| duration | number | 否 | 视频时长(秒),默认 5,范围 3-30 |
| resolution | string | 否 | 分辨率:720p / 1080p,默认 1080p |
| style | string | 否 | 视频风格:cinematic / anime / realistic / abstract |
| narration | boolean | 否 | 是否生成 AI 旁白配音,默认 false |
| narration_lang | string | 否 | 旁白语言:zh / en / ja / ko 等,需 narration=true |
| subtitles | boolean | 否 | 是否生成字幕,默认 false |
Python 完整示例
以下是一个完整的 Python 示例——提交任务、轮询状态、获取视频:
import requests
API_KEY = "your_api_key_here"
url = "https://api.agnes-ai.com/v1/video/generate"
headers = {"Authorization": f"Bearer {API_KEY}"}
payload = {
"prompt": "A drone shot of a mountain lake at sunrise",
"duration": 8,
"resolution": "1080p",
}
resp = requests.post(url, json=payload, headers=headers)
task = resp.json()
print(f"Task ID: {task['task_id']}")
# Poll for result
status = requests.get(
f"https://api.agnes-ai.com/v1/video/status/{task['task_id']}",
headers=headers
)
print(status.json()['video_url'] if status.json().get('video_url')
else "Still generating...")不想手写代码?
以上所有 API 调用——认证、参数组装、状态轮询、错误重试——Agnes Video Generator 都已经替你封装好了。你只需要打开浏览器,输入文字,一键生成视频。它是使用 Agnes 视频模型的最简单方式。
打开 Agnes Video Generator 网页版体验 →