https://api.pinniq.orghttps://docs.x.ai/developers/rest-api-reference/inference/videos#video-generationmetadata.url,当前 Grok 任务完成响应实测主要返回顶层 video_url。客户端应优先读取 video_url,并兼容 metadata.url。POST /v1/videos 创建任务。task_id。GET /v1/videos/{task_id} 轮询任务状态。status=completed 且 progress=100 时下载视频。| 方式 | 说明 | 是否需要鉴权 |
|---|---|---|
查询响应里的 video_url | 上游返回的 mp4 直链,当前 Grok 任务实测返回这个字段 | 通常不需要额外鉴权 |
/v1/videos/{task_id}/content | FriModel 平台代理下载地址,由 task_id 拼接得到 | 需要 Authorization: Bearer ... |
/content 下载,因为它只依赖平台任务 ID:pinniq.org 是控制台域名,不作为 API 调用入口。API 请求请使用 api.pinniq.org。| 模型 | 纯文字生成视频 | 图片生成视频 | 说明 |
|---|---|---|---|
grok-imagine-video | 支持 | 支持 | 适合纯文本或图生视频 |
grok-imagine-video-1.5-preview | 不支持 | 支持 | 必须传图片 |
grok-imagine-video。grok-imagine-video-1.5-preview 如果只传 prompt,可能返回 Text-to-video is not supported for this model.。grok-imagine-video。{
"id": "task_xxx",
"task_id": "task_xxx",
"object": "video",
"model": "grok-imagine-video",
"status": "queued",
"progress": 0,
"created_at": 1710000000,
"seconds": "4",
"size": "720x1280"
}duration=5 时,实际返回的 seconds 可能由上游调整,例如实测返回 "4"。客户端应以接口返回的 seconds 为准。multipart/form-data 上传图片,字段名使用 input_reference。grok-imagine-video 也可以用图片生成视频:seconds。JSON 请求建议传 duration。| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | grok-imagine-video 或 grok-imagine-video-1.5-preview |
prompt | string | 是 | 视频提示词 |
duration | int/string | 否 | JSON 请求中的视频秒数 |
seconds | int/string | 否 | multipart 表单中的视频秒数 |
input_reference | file/string | 图生视频必填 | multipart 文件、图片 URL 或 data URL |
image | string | 否 | 图片 URL 或 data URL,作为兼容字段 |
images | string[] | 否 | 多图兼容字段,当前 通常只取第一张 |
{
"id": "task_xxx",
"model": "grok-imagine-video",
"object": "video",
"progress": 68,
"status": "queued"
}{
"id": "task_xxx",
"model": "grok-imagine-video",
"object": "video",
"progress": 100,
"seconds": "4",
"status": "completed",
"video_url": "https://vidgen.x.ai/xai-vidgen-bucket/xai-video-xxx.mp4"
}| 字段 | 说明 |
|---|---|
id | 平台任务 ID |
task_id | 兼容字段。创建接口通常返回,查询接口可能省略 |
object | 固定为 video |
model | 模型名称 |
status | 任务状态 |
progress | 任务进度,0-100 |
seconds | 实际视频秒数 |
video_url | 当前 Grok 任务完成后的 mp4 直链 |
metadata.url | 兼容字段,部分通道或旧响应可能使用这个字段 |
error | 失败时的错误信息 |
status=completed 或 status=failed。| 状态 | 说明 |
|---|---|
queued | 已排队或处理中 |
in_progress | 生成中 |
completed | 已完成 |
failed | 失败 |
cancelled / canceled | 已取消 |
expired | 已过期 |
task_id 拼接:https://api.pinniq.org/v1/videos/{task_id}/contentHTTP 200
Content-Type: video/mp4video_url,也可以直接下载:video_url。metadata.url。/v1/videos/{task_id}/content。/content 下载视频。/content 下载失败,再尝试 video_url 或 metadata.url。id / task_id / status / progress。video_url。https://api.pinniq.org/v1/videos/{task_id}/contenttask_id 拼接得到。video_url 还是 /content?video_url。/content。/content 返回 401 或 404 怎么办?Authorization: Bearer ...。task_id 是否正确。/content 返回的是什么?Content-Type: video/mp4{
"error": {
"message": "Task not found",
"type": "invalid_request_error"
}
}create = POST /v1/videos
task_id = create.task_id or create.id
loop:
task = GET /v1/videos/{task_id}
if task.status == "completed":
download GET /v1/videos/{task_id}/content with Authorization
break
if task.status == "failed":
throw task.error
sleep 5 seconds