feat: support grok reference video mode
This commit is contained in:
+11
-2
@@ -434,7 +434,7 @@ async function runVideo(base, llm, params) {
|
||||
|
||||
// —— Grok 视频:独立新增接口,按 /v1/videos/generations + /v1/videos/{request_id} 调用 ——
|
||||
async function runGrokVideo(base, llm, params) {
|
||||
const model = params.model || "grok-imagine-video";
|
||||
let model = params.model || "grok-imagine-video";
|
||||
const prompt = (params.prompt || "").trim();
|
||||
if (!prompt) return { ok: false, error: "请填写 Grok 视频提示词" };
|
||||
|
||||
@@ -458,8 +458,17 @@ async function runGrokVideo(base, llm, params) {
|
||||
const img = await resolveMat(params.imageUrl || params.image);
|
||||
if (!img) return { ok: false, error: "Grok 图生视频需要首帧图:上传 / 手填公网URL / 连接上游文生图" };
|
||||
body.image = { image_url: img };
|
||||
} else if (mode === "reference") {
|
||||
const refs = Array.isArray(params.referenceImages) ? params.referenceImages : [];
|
||||
const resolved = (await Promise.all(refs.map((r) => resolveMat(r)))).filter(Boolean);
|
||||
if (!resolved.length) return { ok: false, error: "Grok 多参考图模式请至少提供 1 张参考图" };
|
||||
model = "grok-imagine-video";
|
||||
body.model = model;
|
||||
body.resolution = "720p";
|
||||
if (!body.aspect_ratio) body.aspect_ratio = params.aspectRatio || "16:9";
|
||||
body.reference_images = resolved.map((url) => ({ url }));
|
||||
} else if (mode !== "text") {
|
||||
return { ok: false, error: "Grok 视频新增接口只支持「文生视频」和「首帧图生视频」" };
|
||||
return { ok: false, error: "Grok 视频新增接口只支持「文生视频」「首帧图生视频」和「多参考图」" };
|
||||
}
|
||||
|
||||
const createUrl = joinUrl(base, params.endpointPath || "/v1/videos/generations");
|
||||
|
||||
Reference in New Issue
Block a user