JunFeiAI 视频接口文档

适用对象:需要通过 JunFeiAI API 调用 Grok 视频模型的下游系统。

最后更新:2026-06-21

1. 接入地址

场景Base URL说明
标准 API 入口https://junfeiai.com/v1常规请求入口
国内 API 代理入口https://junfeiai.hk-proxy.lingzhiwuxian.com/v1国内服务器建议优先使用
视频结果代理域名https://video.junfeiai.hk-proxy.lingzhiwuxian.com用于读取生成后的 MP4
文档域名https://doc.junfeiai.com只放接口文档,不用于 API 请求

如果你已经配置了短别名,例如 junfeiai.hkproxyvideo.junfeiai.hkproxy,可以把上面的长域名替换成你的短别名;未确认 DNS 前建议使用表格中的长域名。

2. 可用模型

当前建议只接入两个模型:

模型能力说明
grok-image-video文生视频、单图生视频、多参考图生视频通用模型,支持更多输入方式
grok-video-1.5单图生视频旗舰图生视频模型,通常成本更高

不建议下游直接接入 -4s/6s-8s/10s-15s 这类分段模型。下游只需要传 secondsduration 控制时长即可,服务端会按模型和时长计费。

3. 创建视频任务

接口:

POST /video/generations

完整地址:

https://junfeiai.com/v1/video/generations

国内代理地址:

https://junfeiai.hk-proxy.lingzhiwuxian.com/v1/video/generations

文生视频示例

curl -X POST "https://junfeiai.com/v1/video/generations" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-image-video",
    "prompt": "A small red ball bouncing once on a clean white tabletop, simple studio lighting, no text.",
    "seconds": "6",
    "size": "1280x720"
  }'

成功后返回任务 ID:

{
  "id": "task_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "task_id": "task_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "status": "queued",
  "model": "grok-image-video",
  "object": "video"
}

单图生视频示例

curl -X POST "https://junfeiai.com/v1/video/generations" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-video-1.5",
    "prompt": "Make the subject slowly turn toward the camera, cinematic lighting, no text.",
    "image": "https://example.com/input.png",
    "seconds": "6",
    "size": "1280x720"
  }'

有些客户端使用多图字段,可以传:

{
  "model": "grok-image-video",
  "prompt": "Create a smooth camera push-in, no text.",
  "images": [
    "https://example.com/reference-1.png",
    "https://example.com/reference-2.png"
  ],
  "seconds": "8",
  "size": "1280x720"
}

4. 请求参数

参数类型必填示例说明
modelstringgrok-image-video视频模型
promptstringA red ball bouncing...视频提示词
secondsstring"6"生成时长,推荐传字符串
durationinteger/string6兼容字段;和 seconds 二选一即可
sizestring1280x720画幅尺寸
imagestring图生视频必填https://.../input.png单图输入
imagesarray多参考图时使用["https://..."]多图输入

推荐时长:

常用画幅:

grok-video-1.5 通常只建议使用 16:9 或 9:16。

5. 查询任务

接口:

GET /video/generations/{task_id}

示例:

curl "https://junfeiai.com/v1/video/generations/task_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Authorization: Bearer YOUR_API_KEY"

任务完成后返回:

{
  "code": "success",
  "data": {
    "task_id": "task_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "status": "SUCCESS",
    "progress": "100%",
    "result_url": "https://video.junfeiai.hk-proxy.lingzhiwuxian.com/v1/videos/task_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/content"
  }
}

状态说明:

状态含义
QUEUED排队中
IN_PROGRESS生成中
SUCCESS生成成功
FAILURE生成失败

轮询建议:每 5 到 10 秒查询一次,不要高频请求。

6. 读取 MP4

任务成功后,读取 result_url 即可获得 MP4。该地址仍需要带你的 API Key:

curl -L "https://video.junfeiai.hk-proxy.lingzhiwuxian.com/v1/videos/task_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/content" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -o output.mp4

播放器或浏览器需要拖动进度条时,可以使用 Range 请求:

curl -L "https://video.junfeiai.hk-proxy.lingzhiwuxian.com/v1/videos/task_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/content" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Range: bytes=0-1023" \
  -o part.mp4

正常情况下:

7. Node.js 示例

const baseURL = "https://junfeiai.hk-proxy.lingzhiwuxian.com/v1";
const apiKey = "YOUR_API_KEY";

async function createVideo() {
  const response = await fetch(`${baseURL}/video/generations`, {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${apiKey}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      model: "grok-image-video",
      prompt: "A small red ball bouncing once on a clean white tabletop, no text.",
      seconds: "6",
      size: "1280x720"
    })
  });

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

async function waitVideo(taskId) {
  for (let i = 0; i < 60; i++) {
    const response = await fetch(`${baseURL}/video/generations/${taskId}`, {
      headers: { "Authorization": `Bearer ${apiKey}` }
    });
    const payload = await response.json();
    const data = payload.data || payload;
    if (data.status === "SUCCESS" && data.result_url) return data;
    if (data.status === "FAILURE") throw new Error(data.fail_reason || "video failed");
    await new Promise((resolve) => setTimeout(resolve, 10000));
  }
  throw new Error("video timeout");
}

const created = await createVideo();
const taskId = created.task_id || created.id;
const done = await waitVideo(taskId);
console.log(done.result_url);

8. 计费说明

视频模型通常按秒计费。下游只需要关心自己账户扣费结果,不需要直接对接上游的分段模型。

建议:

9. 常见错误

状态码原因处理
400请求体字段不符合模型要求检查 modelpromptsecondssize、图片字段
401API Key 无效或读取 MP4 时漏传 Key检查 Authorization
403余额不足或没有模型权限检查账户余额、分组和模型权限
404任务 ID 不存在或路径错误确认使用创建任务返回的 task_id
429轮询或创建任务过快降低并发,增加轮询间隔
502上游或视频代理读取异常稍后重试;持续出现请记录 task_id 联系管理员