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

# Grok Imagine Video 视频延长 (官方通道)

> 通过官方渠道延长已生成的 Grok Imagine 视频

<Note>
  **国内用户请注意：** 中国大陆用户请使用 `https://toapis.cn` 作为接口地址（Base URL）。文档示例中的 `https://toapis.com` 请替换为 `https://toapis.cn`。
</Note>

* 官方渠道 Grok Imagine 视频延长能力
* 将已有视频延长 2-10 秒
* 异步任务管理，通过任务 ID 查询结果

## Path Parameters

<ParamField path="video_id" type="string" required>
  原视频任务 ID

  即此前视频生成请求返回的任务 ID，该任务完成的视频将作为延长源。

  如需对任意视频 URL 延长而不关联源任务，使用 `POST /v1/videos/extend`，并在请求体中传 `video_urls` 代替路径参数。
</ParamField>

## Authorizations

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

  获取 API Key：访问 [API Key 管理页面](https://toapis.com/console/token) 获取您的 API Key

  使用时在请求头中添加：

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

## Body

<ParamField body="model" type="string" default="grok-imagine-video-official" required>
  视频延长模型名称

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

<ParamField body="prompt" type="string" required>
  视频延长的文本描述
</ParamField>

<ParamField body="duration" type="integer" default="6">
  延长时长（秒）

  支持范围：`2`–`10` 秒
</ParamField>

<ParamField body="video_urls" type="string[]">
  源视频 URL 列表。使用 `POST /v1/videos/extend` 且无任务 ID 时必填；路径中已带 `video_id` 时可选。

  支持公网 `http://`/`https://` URL 或平台 `asset://` 引用。
</ParamField>

<Note>
  **计费说明**：延长计费 = 生成的延长秒数 + **输入源视频时长** 按秒计费。源视频时长由平台自动确定，请求中无需声明。
</Note>

## Response

<ResponseField name="id" type="string">
  唯一任务标识，用于查询任务状态
</ResponseField>

<ResponseField name="object" type="string">
  对象类型，始终为 `generation.task`
</ResponseField>

<ResponseField name="model" type="string">
  使用的模型名称
</ResponseField>

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

  * `queued` - 排队等待处理
  * `in_progress` - 处理中
  * `completed` - 已完成
  * `failed` - 失败
</ResponseField>

<ResponseField name="progress" type="integer">
  任务进度百分比（0-100）
</ResponseField>

<ResponseField name="created_at" type="integer">
  任务创建时间戳（Unix 时间戳）
</ResponseField>

<ResponseField name="metadata" type="object">
  任务元数据
</ResponseField>

<RequestExample>
  ```bash cURL (按任务延长) theme={null}
  curl --request POST \
    --url https://toapis.com/v1/videos/tsk_vid_01M59KNFZA2N4QFP0TMGACYH98/extend \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "grok-imagine-video-official",
      "prompt": "继续场景，让狗跑向远方",
      "duration": 6
    }'
  ```

  ```bash cURL (按 URL 延长) theme={null}
  curl --request POST \
    --url https://toapis.com/v1/videos/extend \
    --header 'Authorization: Bearer <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "model": "grok-imagine-video-official",
      "prompt": "继续场景，让狗跑向远方",
      "duration": 6,
      "video_urls": ["https://example.com/source-video.mp4"]
    }'
  ```

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

  video_id = "tsk_vid_01M59KNFZA2N4QFP0TMGACYH98"

  response = requests.post(
      f"https://toapis.com/v1/videos/{video_id}/extend",
      headers={
          "Authorization": "Bearer your-ToAPIs-key",
          "Content-Type": "application/json"
      },
      json={
          "model": "grok-imagine-video-official",
          "prompt": "继续场景，让狗跑向远方",
          "duration": 6
      }
  )

  task = response.json()
  print(f"Task ID: {task['id']}")
  print(f"Status: {task['status']}")
  ```

  ```javascript JavaScript theme={null}
  const videoId = 'tsk_vid_01M59KNFZA2N4QFP0TMGACYH98';

  const response = await fetch(`https://toapis.com/v1/videos/${videoId}/extend`, {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer your-ToAPIs-key',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      model: 'grok-imagine-video-official',
      prompt: '继续场景，让狗跑向远方',
      duration: 6
    })
  });

  const task = await response.json();
  console.log(`Task ID: ${task.id}`);
  console.log(`Status: ${task.status}`);
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "tsk_vid_01M59KTYQS81W0QENN56SEJ85S",
    "object": "generation.task",
    "model": "grok-imagine-video-official",
    "status": "queued",
    "progress": 0,
    "created_at": 1768380224,
    "metadata": {}
  }
  ```
</ResponseExample>


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