ToAPIsToAPIs
Grok Imagine Video (Official)

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

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

POST
/v1/videos/%7Bvideo_id%7D/extend

国内用户请注意: 中国大陆用户请使用 https://toapis.cn 作为接口地址(Base URL)。文档示例中的 https://toapis.com 请替换为 https://toapis.cn。

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

Path Parameters

video_idstring路径必填

原视频任务 ID

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

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

Authorizations

Authorizationstring请求头必填

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

获取 API Key:访问 API Key 管理页面 获取您的 API Key

使用时在请求头中添加:

Authorization: Bearer YOUR_API_KEY

Body

modelstring请求体必填默认值: grok-imagine-video-official

视频延长模型名称

示例:"grok-imagine-video-official"

promptstring请求体必填

视频延长的文本描述

durationinteger请求体默认值: 6

延长时长(秒)

支持范围:2–10 秒

video_urlsstring[]请求体

源视频 URL 列表。使用 POST /v1/videos/extend 且无任务 ID 时必填;路径中已带 video_id 时可选。

支持公网 http:///https:// URL。

计费说明:延长计费 = 生成的延长秒数 + 输入源视频时长 按秒计费。源视频时长由平台自动确定,请求中无需声明。

Response

idstring

唯一任务标识,用于查询任务状态

objectstring

对象类型,始终为 generation.task

modelstring

使用的模型名称

statusstring

任务状态

  • queued - 排队等待处理
  • in_progress - 处理中
  • completed - 已完成
  • failed - 失败
progressinteger

任务进度百分比(0-100)

created_atinteger

任务创建时间戳(Unix 时间戳)

metadataobject

任务元数据

请求示例

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
  }'
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"]
  }'
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']}")
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}`);

响应示例

{
  "id": "tsk_vid_01M59KTYQS81W0QENN56SEJ85S",
  "object": "generation.task",
  "model": "grok-imagine-video-official",
  "status": "queued",
  "progress": 0,
  "created_at": 1768380224,
  "metadata": {}
}