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.hkproxy 或 video.junfeiai.hkproxy,可以把上面的长域名替换成你的短别名;未确认 DNS 前建议使用表格中的长域名。
2. 可用模型
当前建议只接入两个模型:
| 模型 | 能力 | 说明 |
|---|---|---|
grok-image-video | 文生视频、单图生视频、多参考图生视频 | 通用模型,支持更多输入方式 |
grok-video-1.5 | 单图生视频 | 旗舰图生视频模型,通常成本更高 |
不建议下游直接接入 -4s/6s、-8s/10s、-15s 这类分段模型。下游只需要传 seconds 或 duration 控制时长即可,服务端会按模型和时长计费。
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. 请求参数
| 参数 | 类型 | 必填 | 示例 | 说明 |
|---|---|---|---|---|
model | string | 是 | grok-image-video | 视频模型 |
prompt | string | 是 | A red ball bouncing... | 视频提示词 |
seconds | string | 否 | "6" | 生成时长,推荐传字符串 |
duration | integer/string | 否 | 6 | 兼容字段;和 seconds 二选一即可 |
size | string | 否 | 1280x720 | 画幅尺寸 |
image | string | 图生视频必填 | https://.../input.png | 单图输入 |
images | array | 多参考图时使用 | ["https://..."] | 多图输入 |
推荐时长:
68101215
常用画幅:
1280x720,对应 16:9720x1280,对应 9:161024x1024,对应 1:1
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
正常情况下:
- 完整读取返回
200,Content-Type: video/mp4 - Range 读取返回
206,Content-Type: video/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. 计费说明
视频模型通常按秒计费。下游只需要关心自己账户扣费结果,不需要直接对接上游的分段模型。
建议:
- 普通文生视频和多参考图:使用
grok-image-video - 单图高质量视频:使用
grok-video-1.5 - 用
seconds控制时长,不要把-15s、-8s/10s这些上游分段模型暴露给终端用户
9. 常见错误
| 状态码 | 原因 | 处理 |
|---|---|---|
400 | 请求体字段不符合模型要求 | 检查 model、prompt、seconds、size、图片字段 |
401 | API Key 无效或读取 MP4 时漏传 Key | 检查 Authorization |
403 | 余额不足或没有模型权限 | 检查账户余额、分组和模型权限 |
404 | 任务 ID 不存在或路径错误 | 确认使用创建任务返回的 task_id |
429 | 轮询或创建任务过快 | 降低并发,增加轮询间隔 |
502 | 上游或视频代理读取异常 | 稍后重试;持续出现请记录 task_id 联系管理员 |