# 图生视频（Midjourney）
> 走 `/mj/submit/video`，把一张首帧动画成短片
> 不支持纯文生视频，必须提供首帧
> 完成后用 `/mj/task/{id}/fetch` 取视频地址
`POST /mj/submit/video`
## 认证
- `Authorization` (string / 必填) — 所有接口均使用 Bearer Token 进行认证。 获取 API Key：[访问控制台](https://api.oairoute.com/keys) 创建。 请求时在请求头中添加： ```http Authorization: Bearer YOUR_OAIRoute_KEY ```
## 请求参数
- `videoType` (string / 必填) — 视频类型，`vid_1.1_i2v_480` 或 `vid_1.1_i2v_720`。
- `image` (string / 必填) — 首帧图片，公网 URL 或 Base64 data URI。
- `motion` (string / 必填) — 运动幅度，`low` 或 `high`。
- `prompt` (string / 可选) — 视频描述。
- `endImage` (string / 可选) — 尾帧图片，传了之后生成首尾帧过渡的视频。
- `loop` (boolean / 可选) — 是否循环，默认 `false`。
- `batchSize` (integer / 可选) — 生成条数，取值 `1`、`2`、`4`，默认 `4`。
- `action` (string / 可选) — 扩展视频时填 `extend`。
- `index` (integer / 可选) — 视频索引 `0` 到 `3`，`action` 不为空时必填。
- `taskId` (string / 可选) — 父任务 ID，`action` 不为空时必填。
- `notifyHook` (string / 可选) — 回调地址。
## 分辨率与时长
| `videoType` | 分辨率 | 用途 |
|---|---|---|
| `vid_1.1_i2v_480` | 480p | 草稿、预览 |
| `vid_1.1_i2v_720` | 720p | 成片交付 |
单段视频约 5 秒。需要更长时用 `action: "extend"` 在已有结果上续接。
## 扩展已有视频
传 `action: "extend"` 时必须同时给出 `taskId` 与 `index`：`taskId` 是原视频任务，`index` 指定续接第几条（0 到 3）。
## 错误码
| HTTP | 含义 |
|---|---|
| 200 | 请求已受理，看 `code` 判断是否成功 |
| 401 | Token 缺失或无效 |
| 429 | 触发限流 |
常见失败：`image` 未传或不可访问；`batchSize` 传了 `3`；`action` 为 `extend` 但缺 `index` 或 `taskId`。
更多状态码与重试建议见[错误码与限流](../../../support/errors.html)，常见报错的排查步骤见[常见问题](../../../support/faq.html)。
## 使用示例
### 首帧生成
给一张图与运动幅度，生成约 5 秒短片。`batchSize` 为 `4` 时一次出四条，按条计费。
### 首尾帧过渡
同时传 `image` 与 `endImage`，模型在两张图之间补出运动。
### 续接视频
用 `action: "extend"` 在原视频后面接着生成。
**首帧生成{Image to video}::cURL**
```
curl --request POST \
  --url 'https://api.oairoute.com/mj/submit/video' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "prompt": "run cat",
  "videoType": "vid_1.1_i2v_480",
  "image": "https://example.com/cat.jpg",
  "motion": "low",
  "batchSize": 1
}'
```
**首帧生成{Image to video}::Python**
```
import requests

res = requests.post(
    "https://api.oairoute.com/mj/submit/video",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "prompt": "run cat",
        "videoType": "vid_1.1_i2v_480",
        "image": "https://example.com/cat.jpg",
        "motion": "low",
        "batchSize": 1,
    },
)
print(res.json())
```
**首帧生成{Image to video}::JavaScript**
```
const res = await fetch("https://api.oairoute.com/mj/submit/video", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    prompt: "run cat",
    videoType: "vid_1.1_i2v_480",
    image: "https://example.com/cat.jpg",
    motion: "low",
    batchSize: 1,
  }),
});
console.log(await res.json());
```
**首尾帧过渡{Start-end frames}::cURL**
```
curl --request POST \
  --url 'https://api.oairoute.com/mj/submit/video' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "videoType": "vid_1.1_i2v_720",
  "image": "https://example.com/start.jpg",
  "endImage": "https://example.com/end.jpg",
  "motion": "high",
  "batchSize": 1
}'
```
**首尾帧过渡{Start-end frames}::Python**
```
import requests

res = requests.post(
    "https://api.oairoute.com/mj/submit/video",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "videoType": "vid_1.1_i2v_720",
        "image": "https://example.com/start.jpg",
        "endImage": "https://example.com/end.jpg",
        "motion": "high",
        "batchSize": 1,
    },
)
print(res.json())
```
**首尾帧过渡{Start-end frames}::JavaScript**
```
const res = await fetch("https://api.oairoute.com/mj/submit/video", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    videoType: "vid_1.1_i2v_720",
    image: "https://example.com/start.jpg",
    endImage: "https://example.com/end.jpg",
    motion: "high",
    batchSize: 1,
  }),
});
console.log(await res.json());
```
**续接视频{Extend}::cURL**
```
curl --request POST \
  --url 'https://api.oairoute.com/mj/submit/video' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "videoType": "vid_1.1_i2v_480",
  "image": "https://example.com/cat.jpg",
  "motion": "low",
  "action": "extend",
  "taskId": "1320098173412580",
  "index": 0
}'
```
**续接视频{Extend}::Python**
```
import requests

res = requests.post(
    "https://api.oairoute.com/mj/submit/video",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "videoType": "vid_1.1_i2v_480",
        "image": "https://example.com/cat.jpg",
        "motion": "low",
        "action": "extend",
        "taskId": "1320098173412580",
        "index": 0,
    },
)
print(res.json())
```
**续接视频{Extend}::JavaScript**
```
const res = await fetch("https://api.oairoute.com/mj/submit/video", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    videoType: "vid_1.1_i2v_480",
    image: "https://example.com/cat.jpg",
    motion: "low",
    action: "extend",
    taskId: "1320098173412580",
    index: 0,
  }),
});
console.log(await res.json());
```
**200 首帧生成{Image to video}**
```
{
  "code": 1,
  "description": "提交成功",
  "result": "1320098173412580"
}
```
**200 首尾帧过渡{Start-end frames}**
```
{
  "code": 1,
  "description": "提交成功",
  "result": "1320098173412581"
}
```
**200 续接视频{Extend}**
```
{
  "code": 1,
  "description": "提交成功",
  "result": "1320098173412582"
}
```
