Skip to content
This repository was archived by the owner on Dec 1, 2025. It is now read-only.

Commit 95d4ed7

Browse files
committed
feat(docs): update authentication descriptions and add video generation API documentation
- Enhanced the authentication section in `auth-system-description.md` to clarify the use of AccessTokens for different user roles. - Introduced new documentation for video generation APIs, including detailed request/response formats, error handling, and usage examples across various models. - Added a new file for querying video generation status and results. - Included best practices and performance optimization suggestions for API usage.
1 parent 8b856b1 commit 95d4ed7

File tree

7 files changed

+1384
-65
lines changed

7 files changed

+1384
-65
lines changed

docs/api/auth-system-description.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
!!! info "说明"
44
系统采用四级鉴权机制:公开、用户、管理员、Root
5+
AccessToken 为您 **在个人设置-系统访问令牌** 中生成的用于 **/api** 路由 访问的令牌
56

67
## 🔐 鉴权
78

89
- 公开:无需登录
9-
- 用户:需要用户 Token (middleware.UserAuth)
10-
- 管理员:需要管理员 Token (middleware.AdminAuth)
11-
- Root:仅限最高权限用户 (middleware.RootAuth)
10+
- 用户:需要用户 AccessToken (middleware.UserAuth)
11+
- 管理员:需要管理员 AccessToken (middleware.AdminAuth)
12+
- Root:仅限最高权限用户 AccessToken (middleware.RootAuth)

docs/api/generate-video.md

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
# 视频生成 API
2+
3+
调用视频生成接口生成视频,支持多种视频生成服务:
4+
5+
- **可灵AI (Kling)**: [API文档](https://app.klingai.com/cn/dev/document-api/apiReference/commonInfo)
6+
- **即梦 (Jimeng)**: [API文档](https://www.volcengine.com/docs/85621/1538636)
7+
- **Gemini**: Google的视频生成服务
8+
- **Vidu**: 高质量视频生成服务
9+
10+
## NewAPI 视频生成格式
11+
12+
### API 端点
13+
14+
```
15+
POST /v1/video/generations
16+
```
17+
18+
### 请求头
19+
20+
| 参数 | 类型 | 必填 | 描述 |
21+
|------|------|------|------|
22+
| Authorization | string || 用户认证令牌 (Bearer: sk-xxxx) |
23+
| Content-Type | string || application/json |
24+
25+
### 请求参数
26+
27+
| 参数 | 类型 | 必填 | 描述 |
28+
|------|------|------|------|
29+
| model | string || 模型/风格ID |
30+
| prompt | string || 文本提示词 |
31+
| duration | number || 视频时长(秒) |
32+
| fps | integer || 视频帧率 |
33+
| height | integer || 视频高度 |
34+
| width | integer || 视频宽度 |
35+
| image | string || 图片输入(URL/Base64) |
36+
| metadata | object || 供应商特定/自定义参数(如 negative_prompt, style, quality_level 等) |
37+
| n | integer || 生成视频数量 |
38+
| response_format | string || 响应格式 |
39+
| seed | integer || 随机种子 |
40+
| user | string || 用户标识符 |
41+
42+
### 请求示例
43+
44+
#### 可灵AI 示例
45+
46+
```bash
47+
curl https://你的newapi服务器地址/v1/video/generations \
48+
--request POST \
49+
--header 'Authorization: Bearer sk-xxxx' \
50+
--header 'Content-Type: application/json' \
51+
--data '{
52+
"model": "kling-v1",
53+
"prompt": "一个穿着宇航服的宇航员在月球上行走, 高品质, 电影级",
54+
"size": "1920x1080",
55+
"image": "https://h2.inkwai.com/bs2/upload-ylab-stunt/se/ai_portal_queue_mmu_image_upscale_aiweb/3214b798-e1b4-4b00-b7af-72b5b0417420_raw_image_0.jpg",
56+
"duration": 5,
57+
"metadata": {
58+
"seed": 20231234,
59+
"negative_prompt": "模糊",
60+
"image_tail": "https://h1.inkwai.com/bs2/upload-ylab-stunt/1fa0ac67d8ce6cd55b50d68b967b3a59.png"
61+
}
62+
}'
63+
```
64+
65+
#### 即梦AI 示例
66+
67+
```bash
68+
curl https://你的newapi服务器地址/v1/video/generations \
69+
--request POST \
70+
--header 'Authorization: Bearer sk-xxxx' \
71+
--header 'Content-Type: application/json' \
72+
--data '{
73+
"model": "jimeng_vgfm_t2v_l20",
74+
"prompt": "一个穿着宇航服的宇航员在月球上行走",
75+
"image": "https://h2.inkwai.com/bs2/upload-ylab-stunt/se/ai_portal_queue_mmu_image_upscale_aiweb/3214b798-e1b4-4b00-b7af-72b5b0417420_raw_image_0.jpg",
76+
"metadata": {
77+
"req_key": "jimeng_vgfm_i2v_l20",
78+
"image_urls": [
79+
"https://h2.inkwai.com/bs2/upload-ylab-stunt/se/ai_portal_queue_mmu_image_upscale_aiweb/3214b798-e1b4-4b00-b7af-72b5b0417420_raw_image_0.jpg"
80+
],
81+
"aspect_ratio": "16:9"
82+
}
83+
}'
84+
```
85+
86+
#### Vidu 渠道示例
87+
88+
```bash
89+
curl https://你的newapi服务器地址/v1/video/generations \
90+
--request POST \
91+
--header 'Authorization: Bearer sk-xxxx' \
92+
--header 'Content-Type: application/json' \
93+
--data '{
94+
"model": "viduq1",
95+
"prompt": "一个穿着宇航服的宇航员在月球上行走, 高品质, 电影级",
96+
"size": "1920x1080",
97+
"image": "https://prod-ss-images.s3.cn-northwest-1.amazonaws.com.cn/vidu-maas/template/image2video.png",
98+
"duration": 5,
99+
"metadata": {
100+
"duration": 5,
101+
"seed": 0,
102+
"resolution": "1080p",
103+
"movement_amplitude": "auto",
104+
"bgm": false,
105+
"payload": "",
106+
"callback_url": "https://your-callback-url.com/webhook"
107+
}
108+
}'
109+
```
110+
111+
### 响应格式
112+
113+
#### 201 - 创建成功
114+
115+
```json
116+
{
117+
"id": "video_123",
118+
"object": "video",
119+
"model": "kling-v1",
120+
"created_at": 1640995200,
121+
"task_id": "abcd1234efgh",
122+
"status": "processing"
123+
}
124+
```
125+
126+
#### 响应字段说明
127+
128+
| 字段 | 类型 | 描述 |
129+
|------|------|------|
130+
| id | string | 视频任务ID |
131+
| object | string | 对象类型,固定为 "video" |
132+
| model | string | 使用的模型名称 |
133+
| created_at | integer | 创建时间戳 |
134+
| task_id | string | 任务ID,用于查询状态 |
135+
| status | string | 任务状态(processing: 处理中) |
136+
137+
## 错误响应
138+
139+
### 400 - 请求参数错误
140+
```json
141+
{
142+
"code": null,
143+
"message": "string",
144+
"param": "string",
145+
"type": "string"
146+
}
147+
```
148+
149+
### 401 - 未授权
150+
```json
151+
{
152+
"code": null,
153+
"message": "string",
154+
"param": "string",
155+
"type": "string"
156+
}
157+
```
158+
159+
### 403 - 无权限
160+
```json
161+
{
162+
"code": null,
163+
"message": "string",
164+
"param": "string",
165+
"type": "string"
166+
}
167+
```
168+
169+
### 500 - 服务器内部错误
170+
```json
171+
{
172+
"code": null,
173+
"message": "string",
174+
"param": "string",
175+
"type": "string"
176+
}
177+
```
178+
179+
## 支持的模型
180+
181+
### 可灵AI (Kling)
182+
- `kling-v1`: 文生视频模型
183+
- `kling-v2-master`: 图生视频模型
184+
185+
### 即梦 (Jimeng)
186+
- `jimeng_vgfm_t2v_l20`: 文生视频模型
187+
- `jimeng_vgfm_i2v_l20`: 图生视频模型
188+
189+
### Vidu
190+
- `viduq1`: Vidu高质量视频生成模型
191+
192+
## 最佳实践
193+
194+
1. **提示词优化**: 使用详细、具体的描述词,包含风格、质量要求
195+
2. **图片质量**: 图生视频时使用高分辨率、清晰的图片
196+
3. **参数调优**: 根据需求调整时长、分辨率等参数
197+
4. **错误处理**: 实现适当的重试机制和错误处理
198+
5. **异步处理**: 视频生成是异步任务,需要轮询查询状态

0 commit comments

Comments
 (0)