Grok 生视频 API¶
本文说明如何通过 JarlessAPI 调用 Grok Imagine 生视频。创建是异步的。聊天配置见 Grok Build,生图见 Grok 生图 API。
基本信息¶
| 项目 | 说明 |
|---|---|
| Base URL | https://jarlessapi.com |
| 认证 | Authorization: Bearer <api_key> |
| 分组 | 必须使用 Grok 分组,且分组已开启生图权限 |
| 路径 | /v1/videos/generations、/v1/videos/{request_id}、/v1/videos/{request_id}/content |
以下 cURL 示例在 Bash 中执行(macOS / Linux / WSL / Git Bash)。
export BASE_URL="https://jarlessapi.com"
export API_KEY="sk-your-api-key"
查询和下载必须用创建时同一把 API Key,否则返回 Video request not found。
可用模型¶
| model | 用途 |
|---|---|
grok-imagine-video |
文生视频(推荐) |
grok-imagine-video-1.5 |
图生视频,必须带图 |
grok-imagine-video-1.5-preview |
1.5 preview |
resolution 可选 480p、720p、1080p。1080p 以 1.5 为准。
文生视频¶
POST /v1/videos/generations
curl "$BASE_URL/v1/videos/generations" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-video",
"prompt": "Slow cinematic push-in through a rainy cyberpunk night market, neon reflections on wet street, steam drifting",
"resolution": "480p",
"duration": 5
}'
已验证创建响应:
{
"request_id": "f9a1bd12-5616-9418-8e7e-6318c45ede65"
}
图生视频¶
grok-imagine-video-1.5 不带图会把错误原样交给上游,不要省略 image。
curl "$BASE_URL/v1/videos/generations" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-video-1.5",
"prompt": "镜头缓慢推进,雨丝和霓虹在动",
"resolution": "720p",
"duration": 6,
"image": { "url": "https://example.com/frame.png" }
}'
image / images / reference_images 格式与生图相同。
查状态¶
将 REQUEST_ID 设置为创建响应中的 request_id:
export REQUEST_ID="替换为刚才返回的 request_id"
curl "$BASE_URL/v1/videos/$REQUEST_ID" \
-H "Authorization: Bearer $API_KEY"
/v1/videos/generations/{id} 也可以。完成时已验证响应:
{
"model": "grok-imagine-video",
"progress": 100,
"status": "done",
"video": {
"duration": 5,
"respect_moderation": true,
"url": "https://..."
}
}
status=done 且 video.url 有值才算完成。
下载¶
curl -L "$BASE_URL/v1/videos/$REQUEST_ID/content" \
-H "Authorization: Bearer $API_KEY" \
-o out.mp4
已验证返回 Content-Type: video/mp4。
请求字段¶
| 字段 | 必填 | 说明 |
|---|---|---|
model |
是 | 见模型表 |
prompt |
是 | 提示词 |
resolution |
否 | 480p / 720p / 1080p |
duration |
否 | 秒,数字 |
image |
1.5 必填 | 参考图 URL 或 { "url": "..." } |
其他路径:
POST /v1/videos/editsPOST /v1/videos/extensions
常见错误¶
| 现象 | 原因 |
|---|---|
404 Videos API is not supported |
Key 不是 Grok 分组 |
404 Video request not found |
换了 Key,或任务不存在 |
503 grok_media_no_eligible_account |
没有可做媒体的 Grok 账号 |
| 1.5 创建失败 | 没传参考图 |