fix: route runway video models through video branch
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
Your Name 2026-03-21 00:36:46 +08:00
parent 7e7685410f
commit 1eb23a015f
2 changed files with 20 additions and 9 deletions

View File

@ -7972,14 +7972,16 @@ export async function POST(request: Request) {
// ========== Gemini 处理结束 ==========
// ========== 阿里云千问图片生成独立处理 ==========
const isAlibabaLikeImageProvider = [
"alibaba-image",
"ruxa-image",
"fal-image",
"openai-image",
"midjourney",
"runway",
].includes((languageModel as any).provider);
const isAlibabaLikeImageProvider =
isImageGenerationModel &&
[
"alibaba-image",
"ruxa-image",
"fal-image",
"openai-image",
"midjourney",
"runway",
].includes((languageModel as any).provider);
if (isAlibabaLikeImageProvider && typeof (languageModel as any).doGenerate === "function") {
console.log("[Chat API] Using image generation provider:", (languageModel as any).provider);
console.log("[Chat API] Image params:", effectiveImageParams);

View File

@ -71,8 +71,9 @@ function joinEndpoint(baseURL: string, path: string) {
}
function buildHeaders(apiKey: string) {
const normalizedApiKey = normalizeRunwayCredentials(apiKey);
return {
Authorization: `Bearer ${String(apiKey || "").trim()}`,
Authorization: `Bearer ${normalizedApiKey}`,
"Content-Type": "application/json",
"X-Runway-Version": RUNWAY_VERSION,
};
@ -82,6 +83,14 @@ function normalizeText(value: string) {
return String(value || "").replace(/\u00a0/g, " ").trim().normalize("NFKC");
}
function normalizeRunwayCredentials(apiKey: string) {
const normalized = normalizeText(apiKey);
const stripped = normalized.replace(/^bearer\s+/i, "").replace(/^key\s+/i, "");
const kvMatch = stripped.match(/^(?:runway[_-]?api[_-]?key|api[_-]?key|token)\s*[::]\s*(.+)$/i);
const candidate = kvMatch?.[1] ? kvMatch[1] : stripped;
return candidate.trim().replace(/[^\x20-\x7E]/g, "");
}
function normalizeImageSizeLabel(imageSize?: string): "1K" | "2K" | "4K" {
const normalized = String(imageSize || "").trim().toUpperCase();
if (normalized === "1K" || normalized === "2K" || normalized === "4K") {