# Midjourney Video API

{% hint style="danger" %}
此文档已停止维护，最新文档地址：<https://docs.ttapi.io>
{% endhint %}

{% hint style="info" %}
最多可以 **同时执行 10 个生成队列**，如需更多作业队列请 [联系我们](https://ttapi.io/contact)
{% endhint %}

## 生成视频

{% hint style="info" %}
单次生成视频长度，与延续视频长度目前固定为5s。
{% endhint %}

<mark style="color:green;">`POST`</mark>  `https://api.ttapi.io/midjourney/video/submit`

> 根据图像与描述词生成四个视频，该接口与midjourney生成图像接口交互方式一致，为[异步任务](/faq/midjourney/jie-kou-wen-ti-jie-da.md#api-jiao-hu-shuo-ming-shen-me-shi-yi-bu-hui-tiao)。

**Headers**

| Name         | Value                |
| ------------ | -------------------- |
| TT-API-KEY   | 用于请求授权 TT-API 的API密钥 |
| Content-Type | application-json     |

**Body**

<table><thead><tr><th width="182">参数</th><th width="122">类型</th><th width="101">是否必须</th><th>描述</th></tr></thead><tbody><tr><td><code>prompt</code></td><td>string</td><td>是</td><td>用于生成视频的提示词</td></tr><tr><td><code>imageUrl</code></td><td>string</td><td>是</td><td>视频起始帧图片地址，必须是可以<strong>网络访问的图片地址</strong></td></tr><tr><td><code>endingUrl</code></td><td>string</td><td>否</td><td>视频结束帧图片地址，必须是可以<strong>网络访问的图片地址</strong></td></tr><tr><td><code>mode</code></td><td>string</td><td>否</td><td>生成视频的速率模式，<strong>目前只支持fast模式</strong>，可选值范围：<code>fast</code></td></tr><tr><td><code>manual</code></td><td>string</td><td>否</td><td>视频模式<br>可选值 <code>low</code> 低运动 <code>high</code>高运动<br>默认为<code>low</code></td></tr><tr><td>resolution</td><td>string</td><td>否</td><td>视频分辨率<br>可选值 <code>hd</code> <code>sd</code><br>默认为 <code>sd</code><br><strong>不同分辨率消耗quota不同</strong></td></tr><tr><td><code>bs</code></td><td>int</td><td>否</td><td>批量生成视频数量<br>可选值  1、2、4<br>默认为4</td></tr><tr><td><code>hookUrl</code></td><td>boolean</td><td>否</td><td>回调地址，任务完成或失败将通过请地址进行通知。如果未设置，则需要请求<a href="#huo-qu-ren-wu-zhuang-tai-fetch">fetch</a> 接口进行查询。</td></tr></tbody></table>

{% hint style="info" %}
如果 hookUrl 不为空，系统会向您设置的 hookUrl 发送一个 [json响应](#yi-bu-hui-tiao-json-jie-gou)。
{% endhint %}

#### 请求示例

{% tabs %}
{% tab title="Python" %}

```
import requests

endpoint = "https://api.ttapi.io/midjourney/video/submit"

headers = {
    "TT-API-KEY": your_key
}

data = {
    "prompt": "hyperrealistic album cover: Black sacral Ocean. Sunken prayer canoe. Ghost Canoe Horizon",
    "imageUrl": "https://unlimbot.hb.ru-msk.vkcloud-storage.ru/AQADJvYxG8ZHiEt-.jpeg",
    "mode": "fast",
    "manual": "high",
    "hookUrl": "https://webhook-test.com/1cb411db3bc4bfa7729c7df3ca2c1a5e"
}

response = requests.post(endpoint, headers=headers, json=data)

print(response.status_code)
print(response.json())
```

{% endtab %}

{% tab title="Node" %}

```
const axios = require('axios');

let config = {
  method: 'post',
  url: 'https://api.ttapi.io/midjourney/video/submit',
  headers: { 
    'TT-API-KEY': 'your_key'
  },
  data : {
    "prompt": "hyperrealistic album cover: Black sacral Ocean. Sunken prayer canoe. Ghost Canoe Horizon",
    "imageUrl": "https://unlimbot.hb.ru-msk.vkcloud-storage.ru/AQADJvYxG8ZHiEt-.jpeg",
    "mode": "fast",
    "manual": "high",
    "hookUrl": "https://webhook-test.com/1cb411db3bc4bfa7729c7df3ca2c1a5e"
  }
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.status));
})
.catch(function (error) {
  console.log(error);
});
```

{% endtab %}
{% endtabs %}

#### 响应示例

{% tabs %}
{% tab title="200" %}

```
{
    "status": "SUCCESS",
    "message": "success",
    "data": {
        "jobId": "943583cb-08f4-4077-ad1e-f1bfc6c1191a"
    }
}
```

{% endtab %}

{% tab title="400" %}

```
{
  "status": "FAILED",
  "message": "",
  "data": null
}
```

{% endtab %}
{% endtabs %}

## 视频延伸

<mark style="color:green;">`POST`</mark>  `https://api.ttapi.io/midjourney/video/extend`

{% hint style="info" %}
延伸视频会同步父级任务的分辨率
{% endhint %}

> 根据上一条视频结果延伸生成四个视频\
> 该接口与midjourney生成图像接口交互方式一致，为[异步任务](/faq/midjourney/jie-kou-wen-ti-jie-da.md#api-jiao-hu-shuo-ming-shen-me-shi-yi-bu-hui-tiao)。

**Headers**

| Name         | Value                |
| ------------ | -------------------- |
| TT-API-KEY   | 用于请求授权 TT-API 的API密钥 |
| Content-Type | application-json     |

**Body**

<table><thead><tr><th width="182">参数</th><th width="122">类型</th><th width="101">是否必须</th><th>描述</th></tr></thead><tbody><tr><td><code>jobId</code></td><td>string</td><td>是</td><td>上一条任务的jobId，注意上一条任务必须为完成状态才能进行视频延续</td></tr><tr><td><code>index</code></td><td>int</td><td>是</td><td>选择延续的视频<br>在上一条任务重的四个视频中选择一个延续<br>0代表第一个，1代表第二个，以此类推<br>可选值范围<code>0-3</code></td></tr><tr><td><code>manual</code></td><td>string</td><td>否</td><td>视频模式<br>可选值 <code>low</code> 低运动 <code>high</code>高运动<br>默认为<code>low</code></td></tr><tr><td><code>animateMode</code></td><td>string</td><td>否</td><td><p>动画模式<br>可选 <code>auto</code>、<code>manual</code></p><p>默认为<code>auto</code></p></td></tr><tr><td><code>bs</code></td><td>int</td><td>否</td><td>批量生成视频数量<br>可选值  1、2、4<br>默认为4</td></tr><tr><td><code>hookUrl</code></td><td>boolean</td><td>否</td><td>回调地址，任务完成或失败将通过请地址进行通知。如果未设置，则需要请求<a href="#huo-qu-ren-wu-zhuang-tai-fetch">fetch</a> 接口进行查询。</td></tr></tbody></table>

{% hint style="info" %}
如果 hookUrl 不为空，系统会向您设置的 hookUrl 发送一个 [json响应](#yi-bu-hui-tiao-json-jie-gou)。
{% endhint %}

#### 请求示例

{% tabs %}
{% tab title="Python" %}

```
import requests

endpoint = "https://api.ttapi.io/midjourney/video/extend"

headers = {
    "TT-API-KEY": your_key
}

data = {
    "jobId": "9fd71109-f508-4f0e-a26c-d776d6b38b58",
    "index": 0
}

response = requests.post(endpoint, headers=headers, json=data)

print(response.status_code)
print(response.json())
```

{% endtab %}

{% tab title="Node" %}

```
const axios = require('axios');

let config = {
  method: 'post',
  url: 'https://api.ttapi.io/midjourney/video/extend',
  headers: { 
    'TT-API-KEY': 'your_key'
  },
  data : {
    "jobId": "9fd71109-f508-4f0e-a26c-d776d6b38b58",
    "index": 0
  }
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.status));
})
.catch(function (error) {
  console.log(error);
});
```

{% endtab %}
{% endtabs %}

#### 响应示例

{% tabs %}
{% tab title="200" %}

```
{
    "status": "SUCCESS",
    "message": "success",
    "data": {
        "jobId": "943583cb-08f4-4077-ad1e-f1bfc6c1191a"
    }
}
```

{% endtab %}
{% endtabs %}

## 获取任务状态 - fetch

<mark style="color:red;">`GET`</mark> `https://api.ttapi.io/midjourney/video/fetch`

> 查询任务结果，**该接口不消耗quota，免费使用**

**Headers**

| Name         | Value                |
| ------------ | -------------------- |
| TT-API-KEY   | 用于请求授权 TT-API 的API密钥 |
| Content-Type | application-json     |

**Query参数**

<table><thead><tr><th width="155">参数</th><th width="122">类型</th><th width="101">是否必须</th><th>描述</th></tr></thead><tbody><tr><td><code>jobId</code></td><td>string</td><td>是</td><td>生成接口同步返回的jobId</td></tr></tbody></table>

#### 请求示例

{% tabs %}
{% tab title="Python" %}

```
import requests

endpoint = "https://api.ttapi.io/midjourney/video/fetch"

headers = {
    "TT-API-KEY": your_key
}

data = {
   "jobId": "afa774a3-1aee-5aba-4510-14818d6875e4"
}

response = requests.post(endpoint, headers=headers, json=data)

print(response.status_code)
print(response.json())
```

{% endtab %}

{% tab title="Node" %}

<pre><code>const axios = require('axios');

let config = {
  method: 'post',
  url: 'https://api.ttapi.io/midjourney/video/fetch',
  headers: { 
    'TT-API-KEY': 'your_key'
  },
  data : {
<strong>    "jobId" => "afa774a3-1aee-5aba-4510-14818d6875e4"
</strong>  }
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.status));
})
.catch(function (error) {
  console.log(error);
});
</code></pre>

{% endtab %}
{% endtabs %}

#### 响应示例

**返回结果与**[**异步回调**](#yi-bu-hui-tiao-json-jie-gou)**数据结构一致**

## 异步回调 JSON 结构

{% tabs %}
{% tab title="SUCCESS" %}

```
{
  "status": "SUCCESS",
  "message": "success",
  "jobId": "943583cb-08f4-4077-ad1e-f1bfc6c1191a",
  "data": {
    "action": "generate",
    "jobId": "943583cb-08f4-4077-ad1e-f1bfc6c1191a",
    "progress": "100",
    "prompt": "hyperrealistic album cover: Black sacral Ocean. Sunken prayer canoe. Ghost Canoe Horizon",
    "quota": "30",
    "videos": [
      "https://cdn.midjourney.com/video/780b1227-227a-418c-998e-3eb90eb4824a/0.mp4",
      "https://cdn.midjourney.com/video/780b1227-227a-418c-998e-3eb90eb4824a/1.mp4",
      "https://cdn.midjourney.com/video/780b1227-227a-418c-998e-3eb90eb4824a/2.mp4",
      "https://cdn.midjourney.com/video/780b1227-227a-418c-998e-3eb90eb4824a/3.mp4"
    ],
    "hookUrl": "https://webhook-test.com/1cb411db3bc4bfa7729c7df3ca2c1a5e"
  }
}
```

{% endtab %}

{% tab title="PENDING\_QUEUE" %}

```
{
    "status": "PENDING_QUEUE",
    "message": "",
    "jobId": "d379237c-2594-42e0-ba81-1e7e34bccf30",
    "data": {
        "action": "generate",
        "jobId": "d379237c-2594-42e0-ba81-1e7e34bccf30",
        "progress": null,
        "prompt": "Make the person stand up, move and sit",
        "quota": "0",
        "videos": null,
        "hookUrl": "https://webhook-test.com/ed9731f4026f04e7c0cfa99e41d2b2fc"
    }
}
```

{% endtab %}

{% tab title="ON\_QUEUE" %}

```
{
    "status": "ON_QUEUE",
    "message": "",
    "jobId": "d379237c-2594-42e0-ba81-1e7e34bccf30",
    "data": {
        "action": "generate",
        "jobId": "d379237c-2594-42e0-ba81-1e7e34bccf30",
        "progress": null,
        "prompt": "Make the person stand up, move and sit",
        "quota": "0",
        "videos": null,
        "hookUrl": "https://webhook-test.com/ed9731f4026f04e7c0cfa99e41d2b2fc"
    }
}
```

{% endtab %}

{% tab title="FAILED" %}

```
{
    "status": "FAILED",
    "message": "job timeout",
    "jobId": "d379237c-2594-42e0-ba81-1e7e34bccf30",
    "data": {
        "action": "generate",
        "jobId": "d379237c-2594-42e0-ba81-1e7e34bccf30",
        "progress": null,
        "prompt": "Make the person stand up, move and sit",
        "quota": "0",
        "videos": null,
        "hookUrl": "https://webhook-test.com/ed9731f4026f04e7c0cfa99e41d2b2fc"
    }
}
```

{% endtab %}
{% endtabs %}

## 返回JSON结构详解

| name   | value                                                                                   |
| ------ | --------------------------------------------------------------------------------------- |
| status | <p>PENDING\_QUEUE //排队中</p><p>ON\_QUEUE  //执行中</p><p>SUCCESS   //成功<br>FAILED  //失败</p> |
| videos | 生成的视频文件，midjourney的官方cdn地址，注意：存在有效期，使用请自行转存                                             |
| quota  | 实际消耗额度                                                                                  |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-zh.mjapiapp.com/api/midjourney-video-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
