已在线验证

Grok Video 3 API

NiuFLU 视频生成接口调用说明。调用方只需使用本站签发的 API Key,无需了解或选择上游渠道。

grok-video-3-t POST /v1/videos 异步任务

基本信息

Base URLhttps://www.niuflu.com/v1
Modelgrok-video-3-t
AuthorizationBearer YOUR_API_KEY
固定使用带 www 的地址 避免 HTTP 重定向导致客户端丢失 Authorization 请求头。

请求参数

参数必填类型说明
model是string固定为 grok-video-3-t
prompt是string视频生成提示词
mode是stringtext、frame 或 ref
images_url按模式string[]text 不传;frame 传 1 张;ref 传 1~7 张
aspect_ratio否string16:9、9:16、1:1;默认 9:16
duration否number6、10、12、16、20;默认 6
resolution否string480p、720p;默认 720p

图片 URL 必须是上游服务器可直接访问的公网 HTTPS 地址;duration 必须传数字。

文生视频

POST/v1/videos
创建请求只提交一次 收到任务 ID 后只做 GET 轮询。不要自动重试 POST,否则可能重复生成和扣费。
curl -X POST "https://www.niuflu.com/v1/videos" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-video-3-t",
    "prompt": "一只橘猫在雨后的城市街道缓慢行走,电影感镜头",
    "mode": "text",
    "aspect_ratio": "16:9",
    "duration": 6,
    "resolution": "720p"
  }'

创建成功

{
  "id": "task_xxxxxxxxx",
  "task_id": "task_xxxxxxxxx",
  "object": "video_task",
  "model": "grok-video-3-t",
  "status": "processing",
  "progress": 10
}

必须保存创建响应中的初始 id,下文称为 local_task_id。没有 id 时才回退读取创建响应的 task_id。

图生视频

单图首帧 · mode: frame

{
  "model": "grok-video-3-t",
  "prompt": "人物轻轻转头,镜头缓慢推进,保持自然光影",
  "mode": "frame",
  "images_url": ["https://example.com/first-frame.jpg"],
  "aspect_ratio": "9:16",
  "duration": 10,
  "resolution": "720p"
}

概念参考 · mode: ref

{
  "model": "grok-video-3-t",
  "prompt": "使用参考图中的人物与服装,生成电影感街景镜头",
  "mode": "ref",
  "images_url": [
    "https://example.com/character.jpg",
    "https://example.com/clothes.jpg"
  ],
  "aspect_ratio": "16:9",
  "duration": 10,
  "resolution": "720p"
}

查询任务

GET/v1/videos/{local_task_id}

每 5~10 秒查询一次创建响应中的初始 id:

curl "https://www.niuflu.com/v1/videos/task_xxxxxxxxx" \
  -H "Authorization: Bearer YOUR_API_KEY"
继续轮询queued / pending / processing / in_progress / running
成功succeeded / completed / success
失败failed / error / cancelled

处理中响应

{
  "id": "task_xxxxxxxxx",
  "status": "processing",
  "progress": 26,
  "completed": false,
  "failed": false
}

完成响应

{
  "id": "task_xxxxxxxxx",
  "status": "completed",
  "progress": 100,
  "completed": true,
  "failed": false,
  "video_url": "https://..."
}
不要更换任务 ID 查询响应可能带有上游 task_id 或 query_endpoint。不要用它覆盖 local_task_id,否则会得到 task_not_exist。

下载视频

GET/v1/videos/{local_task_id}/content
curl -L "https://www.niuflu.com/v1/videos/task_xxxxxxxxx/content" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -o grok-video.mp4

下载时继续使用同一个 API Key。不要直接在普通浏览器地址栏打开该地址,因为地址栏请求不会自动附带 Bearer Key。

Range 兼容状态 普通下载已验证可用;显式 Range 请求目前返回 HTTP 200 而不是 206。完整下载不受影响,需要任意拖动进度条的播放器仍需补齐 206 分段转发。

JavaScript 完整示例

展开代码
const apiBase = 'https://www.niuflu.com/v1';
const apiKey = process.env.NIUFLU_API_KEY;

const headers = {
  Authorization: `Bearer ${apiKey}`,
  'Content-Type': 'application/json',
};

// 创建只执行一次;不要对这个 POST 做自动重试。
const createResponse = await fetch(`${apiBase}/videos`, {
  method: 'POST',
  headers,
  body: JSON.stringify({
    model: 'grok-video-3-t',
    prompt: '一只橘猫在雨后的城市街道缓慢行走,电影感镜头',
    mode: 'text',
    aspect_ratio: '16:9',
    duration: 6,
    resolution: '720p',
  }),
});

if (!createResponse.ok) {
  throw new Error(`create failed: ${createResponse.status} ${await createResponse.text()}`);
}

const created = await createResponse.json();
const localTaskId = created.id ?? created.task_id;
if (!localTaskId) throw new Error('create response has no task id');

let task;
for (;;) {
  await new Promise((resolve) => setTimeout(resolve, 5000));
  const queryResponse = await fetch(
    `${apiBase}/videos/${encodeURIComponent(localTaskId)}`,
    { headers: { Authorization: `Bearer ${apiKey}` } },
  );

  if (!queryResponse.ok) {
    throw new Error(`query failed: ${queryResponse.status} ${await queryResponse.text()}`);
  }

  task = await queryResponse.json();
  const status = String(task.status ?? '').toLowerCase();
  if (task.failed || ['failed', 'error', 'cancelled'].includes(status)) {
    throw new Error(task.error ?? task.message ?? 'video generation failed');
  }
  if (task.completed || ['succeeded', 'completed', 'success'].includes(status)) break;
}

// 使用初始本地 ID,不要改用查询响应中的 task_id。
const contentUrl = `${apiBase}/videos/${encodeURIComponent(localTaskId)}/content`;
console.log({ localTaskId, contentUrl, progress: task.progress });

常见错误

错误原因与处理
invalid_api_platform: 48平台的视频路由配置异常。请联系 NiuFLU 管理员处理,无需更换接口或自行选择上游渠道。
HTTP 400检查是否缺少 mode,以及 duration 是否为允许的数字。文生视频不要传 images_url。
task_not_exist轮询时错误地改用了上游任务 ID。改回创建响应最初返回的 id。
HTTP 401API Key 无效、已禁用,或 Key 所属分组没有 Grok 模型权限。
重复生成 / 扣费客户端重试了创建 POST。创建只提交一次,后续只轮询 GET。

在线实测结果

2026-07-23 验证通过Grok Video 3 的任务创建、轮询和完整视频下载链路已打通。
  • POST /v1/videos 返回 HTTP 200
  • 模型 grok-video-3-t
  • 状态从 processing 变为 completed
  • 进度达到 100%
  • 内容类型为 video/mp4
  • MP4 文件头为有效 ftyp