章鱼哥AI接口文档

Grok

涵盖标准、Fast 与 Lite 的文字和图片视频生成接口。

本系列支持的端点
  • Grok创建POST https://zexapi.com/v1/videos
POSThttps://zexapi.com/v1/videos
鉴权 Authorization: Bearer YOUR_API_KEY

使用 API Key 进行 Bearer 鉴权。JSON 请求设置 Content-Type: application/json;Multipart 请求由客户端自动生成 boundary。

当前价格目录未列 Grok,本页仅作接口参考,不代表型号现已开放。

Grok 视频生成接口文档

接口地址

POST /v1/videos

功能说明

支持 Grok Imagine Video 1.5 系列模型的文生视频、首帧/首尾帧视频和多参考内容视频生成。

当前可用模型与能力

模型名文生视频首帧/首尾帧多参考图时长说明
grok-imagine-video-1.5支持支持首帧和首尾帧最多 7 张图片4~15 秒
grok-imagine-video-1.5-fast支持支持首帧,最长 15 秒支持;多图模式最长 10 秒4~15 秒,受模式限制
grok-imagine-video-1.5-lite支持支持首帧,最长 15 秒不支持多图4~15 秒,受模式限制
fast 和 lite 的首帧模式只传 1 张图片并设置 first_last_frame: true。标准版传 2 张图片时可作为首尾帧。Lite 不支持多图输入。

模式判定

模式传参方式
文生视频不传 images,也可传空数组 []
首帧images 传 1 张图片,并传 first_last_frame: true
首尾帧仅标准版支持;images 依次传首帧、尾帧,并传 first_last_frame: true
参考模式传入参考素材,且不传 first_last_frame 或传 false
first_last_frame 只决定图片是首/尾帧还是普通参考图:
true:首帧或首尾帧模式;第 1 张图是首帧,第 2 张图是尾帧。
false 或不传:参考模式;图片按传入顺序作为参考内容。

请求方式

支持以下两种方式,任选其一:
方式Content-Type参考素材字段
JSONapplication/json图片使用 images
表单multipart/form-data本地图片或图片 URL 使用可重复的 input_reference 字段
Grok 接口只接收图片参考内容。不要把 Markdown 链接(例如 [图片](https://...))原样写入数组,只填写实际的 https://... 图片直链。

请求头

参数名类型必填说明
Authorizationstring是Bearer YOUR_API_KEY
Content-Typestring是application/json 或 multipart/form-data,须与请求体一致

JSON 请求体说明

参数名类型必填说明
modelstring是Grok 模型名称,见上方模型表
promptstring是视频生成提示词
imagesstring[]否图片 URL 或完整 Base64 data URI;文生视频不传或传 []
aspect_ratiostring否视频宽高比,例如 16:9、9:16、21:9
resolutionstring否输出分辨率,例如 720p;可用值以模型服务端配置为准
secondsstring是输出时长,字符串形式,如 "9";范围 4~15
first_last_frameboolean否true 表示首帧/首尾帧模式;不传或 false 表示参考模式

参考素材格式

{
  "images": [
    "https://example.com/ref.png"
  ]
}
所有 URL 必须是无需登录、可由服务器直接下载文件内容的公网直链。

表单字段说明

参数名类型必填说明
modelstring是Grok 模型名称
promptstring是视频生成提示词
input_reference可重复字段否本地图片、图片公网直链或图片 Base64;每张图片重复传一次
aspect_ratiostring否视频宽高比
resolutionstring否输出分辨率,可用值以服务端配置为准
secondsstring是输出时长,范围 4~15
first_last_frameboolean/string否true 为首帧/首尾帧模式;不传或 false 为参考模式

input_reference 的传法

方式示例
本地文件-F "input_reference=@/path/to/ref.jpg"
公网 URL-F "input_reference=https://example.com/ref.jpg"
图片 Base64-F "input_reference=data:image/jpeg;base64,/9j/..."

请求示例

文生视频(JSON)

curl -X POST "https://xxxxx.com/v1/videos" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine-video-1.5",
    "prompt": "一支具有电影质感的未来科技产品广告",
    "aspect_ratio": "16:9",
    "resolution": "720p",
    "seconds": "9"
  }'

标准版首尾帧(JSON)

curl -X POST "https://xxxxx.com/v1/videos" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine-video-1.5",
    "prompt": "让两个画面之间自然、连贯地过渡",
    "images": [
      "https://example.com/first.webp",
      "https://example.com/last.webp"
    ],
    "aspect_ratio": "21:9",
    "resolution": "720p",
    "seconds": "9",
    "first_last_frame": true
  }'

标准版多参考图(JSON,最多 7 张)

curl -X POST "https://xxxxx.com/v1/videos" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine-video-1.5",
    "prompt": "参考产品、场景和人物形象制作一支广告",
    "images": [
      "https://example.com/product.png",
      "https://example.com/scene.png",
      "https://example.com/person.png"
    ],
    "aspect_ratio": "16:9",
    "resolution": "720p",
    "seconds": "12"
  }'

Fast 首帧视频(JSON,最长 15 秒)

curl -X POST "https://xxxxx.com/v1/videos" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine-video-1.5-fast",
    "prompt": "从首帧开始,镜头缓慢推进,产品表面出现流动高光",
    "images": [
      "https://example.com/first.png"
    ],
    "aspect_ratio": "16:9",
    "resolution": "720p",
    "seconds": "15",
    "first_last_frame": true
  }'

Fast 多图参考(JSON,最长 10 秒)

curl -X POST "https://xxxxx.com/v1/videos" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine-video-1.5-fast",
    "prompt": "综合参考图中的产品和场景生成广告",
    "images": [
      "https://example.com/product.png",
      "https://example.com/scene.png"
    ],
    "aspect_ratio": "16:9",
    "resolution": "720p",
    "seconds": "10",
    "first_last_frame": false
  }'

Lite 首帧视频(JSON,最长 15 秒)

curl -X POST "https://xxxxx.com/v1/videos" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine-video-1.5-lite",
    "prompt": "人物从静止逐渐转身并看向镜头",
    "images": [
      "https://example.com/first.png"
    ],
    "aspect_ratio": "9:16",
    "resolution": "720p",
    "seconds": "15",
    "first_last_frame": true
  }'

本地图片(表单)

curl -X POST "https://xxxxx.com/v1/videos" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "model=grok-imagine-video-1.5" \
  -F "prompt=参考这些图片制作广告" \
  -F "input_reference=@/path/to/product.png" \
  -F "input_reference=@/path/to/scene.png" \
  -F "aspect_ratio=16:9" \
  -F "resolution=720p" \
  -F "seconds=10"

响应参数

任务处理中

{
  "id": "task_xxxxxxxxxxxxx",
  "object": "video",
  "model": "grok-imagine-video-1.5",
  "status": "in_progress",
  "progress": 10,
  "created_at": 1791320000
}
完成态视频地址位于顶层 url 和 video_url,两者值相同。
参数名类型说明
idstring任务 ID
objectstring固定值 video
modelstring实际使用的模型名称
statusstringqueued、in_progress、completed 或 failed
progressnumber任务进度,0~100
created_atnumber创建时间戳(秒)
completed_atnumber完成时间戳(秒,仅完成态)
urlstring生成视频直链(仅完成态)
video_urlstring与 url 同值(仅完成态)
errorobject失败信息,通常包含 code、message

提交成功

{
  "id": "task_xxxxxxxxxxxxx",
  "object": "video",
  "model": "grok-imagine-video-1.5",
  "status": "queued",
  "progress": 0,
  "created_at": 1791320000
}

任务完成

{
  "id": "task_xxxxxxxxxxxxx",
  "object": "video",
  "model": "grok-imagine-video-1.5",
  "status": "completed",
  "progress": 100,
  "created_at": 1791320000,
  "completed_at": 1791320060,
  "url": "https://example.com/output.mp4",
  "video_url": "https://example.com/output.mp4"
}

任务失败

{
  "id": "task_xxxxxxxxxxxxx",
  "object": "video",
  "model": "grok-imagine-video-1.5",
  "status": "failed",
  "progress": 0,
  "created_at": 1791320000,
  "error": {
    "code": "invalid_request",
    "message": "请求参数不符合模型能力限制"
  }
}

查询任务状态

GET /v1/videos/{task_id}
curl -X GET "https://xxxxx.com/v1/videos/task_xxxxxxxxxxxxx" \
  -H "Authorization: Bearer YOUR_API_KEY"
queued / in_progress 时继续轮询;completed 时读取顶层 url 或 video_url;failed 时读取 error.message。

注意事项

1.
seconds 必须使用字符串,支持 "4"~"15"。
2.
标准版参考图最多 7 张;首尾帧模式最多传 2 张图片。
3.
fast 多图参考模式最长 10 秒;首帧模式可到 15 秒。
4.
lite 仅支持文生视频或单张首帧图生视频,不支持多图输入和尾帧模式。
5.
首帧/首尾帧必须显式传 first_last_frame: true;不传或传 false 会按普通参考模式处理。
6.
Grok 参考内容只支持图片:JSON 使用 images,表单使用可重复的 input_reference。
7.
JSON 与表单二选一。JSON 不能直接携带本地文件;本地文件请使用 multipart/form-data。
8.
接口为异步接口,提交成功不代表视频已经生成完成。

接口地址

POST /v1/videos

视频调试参数说明

先选择生成方式,再选择型号。参考图片与首尾帧为独立用法,切换用法后显示对应素材输入。JSON 使用 images 数组;表单使用重复的 input_reference 文件字段。

请求示例:文生视频(表单上传)

curl --request POST 'https://zexapi.com/v1/videos' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --form-string 'model=grok-imagine-video-1.5' \
  --form-string 'prompt=生成自然连贯的视频' \
  --form-string 'seconds=10'

请求示例:首帧 / 首尾帧(表单上传)

curl --request POST 'https://zexapi.com/v1/videos' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --form-string 'model=grok-imagine-video-1.5' \
  --form-string 'prompt=生成自然连贯的视频' \
  --form-string 'seconds=10' \
  --form-string 'first_last_frame=true' \
  --form 'input_reference=@/path/to/reference.png'