> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apimart.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Grok Imagine 1.5 视频生成

>  - 异步处理模式，返回任务ID用于后续查询
- 高质量AI视频生成，支持文生视频、图生视频
- 灵活的比例与质量选择，满足不同创作需求 

> [!NOTE]
>
> **模型名称**：本接口统一使用 `grok-imagine-1.5-video-ext`。

```bash cURL theme={null}
# model 请填写 "grok-imagine-1.5-video-ext"
curl --request POST \
  --url https://api.apimart.ai/v1/videos/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "grok-imagine-1.5-video-ext",
    "prompt": "一只狗在海滩上奔跑，阳光明媚，慢镜头",
    "size": "16:9",
    "duration": 6,
    "resolution": "720p"
  }'
```

```python Python theme={null}
import requests

url = "https://api.apimart.ai/v1/videos/generations"

payload = {
    "model": "grok-imagine-1.5-video-ext",
    "prompt": "一只狗在海滩上奔跑，阳光明媚，慢镜头",
    "size": "16:9",
    "duration": 6,
    "resolution": "720p"
}

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript JavaScript theme={null}
const url = "https://api.apimart.ai/v1/videos/generations";

const payload = {
  model: "grok-imagine-1.5-video-ext",
  prompt: "一只狗在海滩上奔跑，阳光明媚，慢镜头",
  size: "16:9",
  duration: 6,
  resolution: "720p"
};

const headers = {
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
};

fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(payload)
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
```

```json 200 theme={null}
{
  "code": 200,
  "data": [
    {
      "task_id": "task_01JNXXXXXXXXXXXXXXXXXX",
      "status": "submitted"
    }
  ]
}
```

```json 400 theme={null}
{
  "error": {
    "code": 400,
    "message": "请求参数无效",
    "type": "invalid_request_error"
  }
}
```

```json 401 theme={null}
{
  "error": {
    "code": 401,
    "message": "身份验证失败，请检查您的API密钥",
    "type": "authentication_error"
  }
}
```

```json 402 theme={null}
{
  "error": {
    "code": 402,
    "message": "账户余额不足，请充值后再试",
    "type": "payment_required"
  }
}
```

```json 403 theme={null}
{
  "error": {
    "code": 403,
    "message": "访问被禁止，您没有权限访问此资源",
    "type": "permission_error"
  }
}
```

```json 429 theme={null}
{
  "error": {
    "code": 429,
    "message": "请求过于频繁，请稍后再试",
    "type": "rate_limit_error"
  }
}
```

```json 500 theme={null}
{
  "error": {
    "code": 500,
    "message": "服务器内部错误，请稍后重试",
    "type": "server_error"
  }
}
```

```json 502 theme={null}
{
  "error": {
    "code": 502,
    "message": "网关错误，服务器暂时不可用",
    "type": "bad_gateway"
  }
}
```

## 认证

**Authorization** `string` *required*

所有接口均需要使用 Bearer Token 进行认证

获取 API Key：

访问 [API Key 管理页面](https://apimart.ai/keys) 获取您的 API Key

使用时在请求头中添加：

```
Authorization: Bearer YOUR_API_KEY
```

## 请求参数

**model** `string` *required* (default: grok-imagine-1.5-video-ext)

视频生成模型名称

支持的模型：

* `grok-imagine-1.5-video-ext` - Grok 视频生成

示例：`"grok-imagine-1.5-video-ext"`

> [!NOTE]
>
> 新请求请统一使用 `grok-imagine-1.5-video-ext`。

**nsfw\_check** `boolean` (default: false)

是否在提交视频任务前执行内容审核。

* `true`：使用 `omni-moderation-latest` 审核提示词和输入图片
* `false` 或不传：不发起审核请求，不增加审核成本与延迟（默认）

**prompt** `string` *required*

视频内容描述，支持中英文

**size** `string` (default: 16:9)

视频尺寸

可选值：

* `16:9` - 横屏（默认）
* `9:16` - 竖屏
* `1:1` - 正方形
* `3:2` - 横屏
* `2:3` - 竖版

**duration** `integer` (default: 6)

视频时长（秒）

取值范围：6-15（最短 6 秒，最长 15 秒）

**⚠️ 注意：** 必须输入纯数字（如 `6`），不要加引号，否则会报错

**resolution** `string` (default: 480p)

视频质量

可选值：

* `480p` - 标清（默认）
* `720p` - 高清

**image\_urls** `string[]`

参考图像的 URL 列表

**限制：**

* 最多 7 张图片
* 必须是公网可访问的 URL
* 不支持 base64 格式

> [!TIP]
>
> 上传参考图之后，宽高比会自动匹配参考图的宽高比

## 响应

**code** `integer`

响应状态码

**data** `object[]`

响应数据数组

**属性**

**task\_id** `string`

任务唯一标识符

**status** `string`

任务状态

* `submitted` - 已提交

> [!NOTE]
>
> **查询任务结果**
>
> 视频生成为异步任务，提交后会返回 `task_id`。使用 [获取任务状态](https://docs.apimart.ai/cn/api-reference/tasks/status.md) 接口查询生成进度和结果。

## 使用场景

### 场景 1：文生视频

```json theme={null}
{
  "model": "grok-imagine-1.5-video-ext",
  "prompt": "一只狗在海滩上奔跑，阳光明媚，慢镜头",
  "size": "16:9",
  "duration": 6
}
```

### 场景 2：图生视频

```json theme={null}
{
  "model": "grok-imagine-1.5-video-ext",
  "prompt": "让画面动起来，添加自然的动态效果",
  "image_urls": ["https://example.com/start.png"],
  "size": "16:9",
  "duration": 10,
  "resolution": "720p"
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.