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

# Grok Imagine 1.0 视频生成

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

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

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

  url = "https://xcompute.us/v1/videos/generations"

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

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

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

  print(response.json())
  ```

  ```javascript JavaScript theme={null} theme={null}
  const url = "https://xcompute.us/v1/videos/generations";

  const payload = {
    model: "grok-imagine-1.0-video-apimart",
    prompt: "一只狗在海滩上奔跑，阳光明媚，慢镜头",
    size: "16:9",
    duration: 6,
    quality: "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));
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null} theme={null}
  {
    "code": 200,
    "data": {
      "id": "task_01JNXXXXXXXXXXXXXXXXXX",
      "status": "submitted",
      "progress": 0,
      "created": 1710000000,
      "type": "video"
    }
  }
  ```
</ResponseExample>

## 认证

<ParamField header="Authorization" type="string" required>
  所有接口均需要使用 Bearer Token 进行认证

  获取 API Key：

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

  使用时在请求头中添加：

  ```
  Authorization: Bearer YOUR_API_KEY
  ```
</ParamField>

## 请求参数

<ParamField body="model" type="string" default="grok-imagine-1.0-video-apimart" required>
  视频生成模型名称

  支持的模型：

  * `grok-imagine-1.0-video-apimart` - Grok 视频生成

  示例：`"grok-imagine-1.0-video-apimart"`
</ParamField>

<ParamField body="prompt" type="string" required>
  视频内容描述，支持中英文
</ParamField>

<ParamField body="size" type="string" default="16:9">
  视频尺寸

  可选值：

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

<ParamField body="duration" type="integer" default={6}>
  视频时长（秒）

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

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

<ParamField body="quality" type="string" default="480p">
  视频质量

  可选值：

  * `480p` - 标清（默认）
  * `720p` - 高清
</ParamField>

<ParamField body="image_urls" type="string[]">
  参考图像的 URL 列表

  **限制：**

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

  <Tip>上传参考图之后，宽高比会自动匹配参考图的宽高比</Tip>
</ParamField>

## 响应

<ResponseField name="code" type="integer">
  响应状态码
</ResponseField>

<ResponseField name="data" type="object">
  返回数据对象

  <Expandable title="属性">
    <ResponseField name="id" type="string">
      任务唯一标识符
    </ResponseField>

    <ResponseField name="status" type="string">
      任务状态

      * `submitted` - 已提交
    </ResponseField>
  </Expandable>
</ResponseField>

<Note>
  **查询任务结果**

  视频生成为异步任务，提交后会返回 `id` (即 `task_id`)。使用 [获取任务状态](/cn/api-reference/tasks/status) 接口查询生成进度和结果。
</Note>

## 使用场景

### 场景 1：文生视频

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

### 场景 2：图生视频

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