# 部署和排查教程

## 1. 上传到 GitHub

```bash
git add .
git commit -m "Use Agnes Video v2.0 API"
git push
```

## 2. Cloudflare Pages 配置

Build 设置：

```text
Framework preset: None
Build command: npm install
Build output directory: .
```

## 3. 添加环境变量

进入 Cloudflare Pages 项目：

```text
Settings > Variables and secrets
```

在 Production 里添加：

```text
AGNES_API_KEY
```

类型选择 Secret。

保存后去：

```text
Deployments > Retry deployment
```

必须重新部署，旧部署不会自动拿到新变量。

## 4. 检查变量是否生效

访问：

```text
https://你的域名/api/health
```

如果看到：

```json
"hasAgnesKey": true
```

说明变量已生效。

如果是 `false`：

- 变量可能只加到了 Preview，没有加 Production
- 变量名不是 `AGNES_API_KEY`
- 添加变量后没有重新部署
- 你访问的不是最新部署

## 5. v2.0 新接口说明

当前后端调用：

```http
POST https://apihub.agnes-ai.com/v1/videos
Authorization: Bearer AGNES_API_KEY
Content-Type: application/json
```

请求示例：

```json
{
  "model": "agnes-video-v2.0",
  "prompt": "日落海滩，海浪拍打沙滩，暖色调光线",
  "width": 1152,
  "height": 768,
  "num_frames": 121,
  "frame_rate": 24
}
```

查询：

```http
GET https://apihub.agnes-ai.com/v1/videos/{task_id}
```

完成后视频地址通常在：

```text
remixed_from_video_id
```
