fix: route runway video models through video branch
This commit is contained in:
parent
7e7685410f
commit
1eb23a015f
@ -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);
|
||||
|
||||
@ -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") {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user