Skip to content

Grok Imagine Video

grok-imagine-video-1.5-preview 使用 OpenAI 兼容的视频任务接口。该模型是图生视频模型,请求必须带至少一张参考图。

接口地址

能力方法路径
创建视频任务POST/v1/videos
查询视频任务GET/v1/videos/{video_id}
下载视频文件GET/v1/videos/{video_id}/content

支持模型

模型说明
grok-imagine-video-1.5-previewGrok Imagine 1.5 预览版图生视频模型,必须提供图片输入

实际可用模型以账户权限和平台配置为准。

支持模式

模式输入方式
图生视频JSON 请求中使用 input_referenceimageimage_url
多图参考input_reference 数组,或 multipart 中重复传 input_reference[]
文件上传multipart/form-data,字段名为 input_reference[]

该模型不支持纯文生视频请求。

请求参数

参数类型必填说明
modelstring固定使用 grok-imagine-video-1.5-preview
promptstring视频生成描述
secondsstring 或 integer视频时长,支持 610121620,默认 6
sizestring视频尺寸,默认 720x1280
resolution_namestring清晰度,可选 480p720p;不传时根据 size 自动选择
presetstring风格预设,可选 customnormalfunspicy,默认 custom
input_referencestring、object 或 arrayJSON 请求中的参考图输入,支持图片 URL 或 data URI
imagestring 或 object单张参考图,等价于单图 input_reference
image_urlstring单张参考图 URL,等价于单图 input_reference
input_reference[]file[]multipart/form-data 请求中的参考图文件字段,最多使用前 7 张

input_referenceimageimage_urlinput_reference[] 至少提供一种。grok-imagine-video-1.5-preview 不支持纯文生视频请求。

支持尺寸

size比例默认清晰度
720x12809:16720p
1280x72016:9720p
1024x10241:1720p
1024x17929:16720p
1792x102416:9720p

调用示例

JSON 请求

bash
curl -X POST https://cubicspaces.cloud/v1/videos \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "grok-imagine-video-1.5-preview",
    "prompt": "A gentle cinematic camera push over the reference image, soft light, realistic motion",
    "seconds": "6",
    "size": "720x1280",
    "preset": "custom",
    "input_reference": {
      "image_url": "https://example.com/reference.png"
    }
  }'

也可以直接传单张图片 URL:

json
{
  "model": "grok-imagine-video-1.5-preview",
  "prompt": "Make the product slowly rotate in a clean studio scene",
  "seconds": "10",
  "size": "1280x720",
  "image_url": "https://example.com/product.png"
}

文件上传

使用 multipart/form-data 时,参考图字段名为 input_reference[]

bash
curl -X POST https://cubicspaces.cloud/v1/videos \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "model=grok-imagine-video-1.5-preview" \
  -F "prompt=A cinematic product shot with a slow dolly move" \
  -F "seconds=6" \
  -F "size=720x1280" \
  -F "preset=custom" \
  -F "input_reference[]=@reference.png"

多张参考图可以重复传 input_reference[],系统最多使用前 7 张。

返回和查询

创建成功后会返回异步视频任务对象:

json
{
  "id": "video_xxx",
  "object": "video",
  "created_at": 1770000000,
  "status": "queued",
  "model": "grok-imagine-video-1.5-preview",
  "progress": 0,
  "prompt": "A gentle cinematic camera push over the reference image",
  "seconds": "6",
  "size": "720x1280",
  "quality": "standard"
}

保存 id,用于后续查询任务和下载视频。

查询任务:

bash
curl https://cubicspaces.cloud/v1/videos/video_xxx \
  -H "Authorization: Bearer YOUR_API_KEY"

生成中:

json
{
  "id": "video_xxx",
  "object": "video",
  "status": "queued",
  "model": "grok-imagine-video-1.5-preview",
  "progress": 35,
  "seconds": "6",
  "size": "720x1280",
  "quality": "standard"
}

完成后:

json
{
  "id": "video_xxx",
  "object": "video",
  "status": "completed",
  "model": "grok-imagine-video-1.5-preview",
  "progress": 100,
  "completed_at": 1770000060,
  "seconds": "6",
  "size": "720x1280",
  "quality": "standard"
}

获取视频内容

任务完成后调用 /content 下载最终 MP4:

bash
curl -L https://cubicspaces.cloud/v1/videos/video_xxx/content \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -o grok-video.mp4

SDK 示例

python
import time
import requests

base_url = "https://cubicspaces.cloud/v1"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
}

task = requests.post(
    f"{base_url}/videos",
    headers=headers,
    json={
        "model": "grok-imagine-video-1.5-preview",
        "prompt": "A gentle cinematic camera push over the reference image",
        "seconds": "6",
        "size": "720x1280",
        "input_reference": {
            "image_url": "https://example.com/reference.png"
        },
    },
).json()

video_id = task["id"]

while True:
    current = requests.get(f"{base_url}/videos/{video_id}", headers=headers).json()
    if current["status"] == "completed":
        break
    if current["status"] == "failed":
        raise RuntimeError(current.get("error", {}).get("message", "video failed"))
    time.sleep(5)

content = requests.get(f"{base_url}/videos/{video_id}/content", headers=headers).content
with open("grok-video.mp4", "wb") as f:
    f.write(content)
js
import fs from "node:fs/promises";

const baseURL = "https://cubicspaces.cloud/v1";
const headers = {
  Authorization: "Bearer YOUR_API_KEY",
  "Content-Type": "application/json"
};

const taskResponse = await fetch(`${baseURL}/videos`, {
  method: "POST",
  headers,
  body: JSON.stringify({
    model: "grok-imagine-video-1.5-preview",
    prompt: "A gentle cinematic camera push over the reference image",
    seconds: "6",
    size: "720x1280",
    input_reference: {
      image_url: "https://example.com/reference.png"
    }
  })
});
const task = await taskResponse.json();

while (true) {
  const currentResponse = await fetch(`${baseURL}/videos/${task.id}`, { headers });
  const current = await currentResponse.json();
  if (current.status === "completed") break;
  if (current.status === "failed") {
    throw new Error(current.error?.message || "video failed");
  }
  await new Promise((resolve) => setTimeout(resolve, 5000));
}

const response = await fetch(`${baseURL}/videos/${task.id}/content`, { headers });
await fs.writeFile("grok-video.mp4", Buffer.from(await response.arrayBuffer()));

常见错误

错误说明
Model 'grok-imagine-video-1.5-preview' requires at least one input image未提供参考图
seconds must be one of [6, 10, 12, 16, 20]seconds 不在支持范围内
size must be one of [...]size 不在支持尺寸范围内
resolution_name must be one of [480p, 720p]清晰度参数不支持

注意事项

  • grok-imagine-video-1.5-preview 必须带参考图,不要发送纯文生视频请求。
  • JSON 请求可以使用公网图片 URL 或 data:image/...;base64,...
  • 上传本地文件时使用 multipart/form-data,字段名为 input_reference[]
  • 视频任务是异步任务,请先保存 id,再轮询查询接口。
  • 任务完成后通过 /v1/videos/{video_id}/content 下载 MP4 文件。