























@@ -25,6 +25,12 @@ const MINIMAX_MODEL_ALLOWED_DURATIONS: Readonly<Record<string, readonly number[]
2525"MiniMax-Hailuo-2.3": [6, 10],
2626"MiniMax-Hailuo-02": [6, 10],
2727};
28+const MINIMAX_MODEL_ALLOWED_RESOLUTIONS: Readonly<Record<string, readonly string[]>> = {
29+"MiniMax-Hailuo-2.3": ["768P", "1080P"],
30+"MiniMax-Hailuo-2.3-Fast": ["768P", "1080P"],
31+"MiniMax-Hailuo-02": ["768P", "1080P"],
32+};
33+const MINIMAX_RESOLUTION_ORDER = ["480P", "720P", "768P", "1080P"] as const;
28342935type MinimaxBaseResp = {
3036status_code?: number;
@@ -112,6 +118,43 @@ function resolveDurationSeconds(params: {
112118);
113119}
114120121+function resolveResolution(params: {
122+model: string;
123+resolution: string | undefined;
124+}): string | undefined {
125+const requested = normalizeOptionalString(params.resolution)?.toUpperCase();
126+if (!requested) {
127+return undefined;
128+}
129+const allowed = MINIMAX_MODEL_ALLOWED_RESOLUTIONS[params.model];
130+if (!allowed || allowed.length === 0 || allowed.includes(requested)) {
131+return requested;
132+}
133+const requestedIndex = MINIMAX_RESOLUTION_ORDER.indexOf(
134+requested as (typeof MINIMAX_RESOLUTION_ORDER)[number],
135+);
136+if (requestedIndex < 0) {
137+return undefined;
138+}
139+return allowed.reduce((best, current) => {
140+const currentIndex = MINIMAX_RESOLUTION_ORDER.indexOf(
141+current as (typeof MINIMAX_RESOLUTION_ORDER)[number],
142+);
143+const bestIndex = MINIMAX_RESOLUTION_ORDER.indexOf(
144+best as (typeof MINIMAX_RESOLUTION_ORDER)[number],
145+);
146+if (currentIndex < 0) {
147+return best;
148+}
149+if (bestIndex < 0) {
150+return current;
151+}
152+return Math.abs(currentIndex - requestedIndex) < Math.abs(bestIndex - requestedIndex)
153+ ? current
154+ : best;
155+});
156+}
157+115158async function pollMinimaxVideo(params: {
116159taskId: string;
117160headers: Headers;
@@ -246,6 +289,7 @@ function buildMinimaxVideoProvider(providerId: string): VideoGenerationProvider
246289maxVideos: 1,
247290maxDurationSeconds: 10,
248291supportedDurationSecondsByModel: MINIMAX_MODEL_ALLOWED_DURATIONS,
292+resolutions: ["768P", "1080P"],
249293supportsResolution: true,
250294supportsWatermark: false,
251295},
@@ -255,6 +299,7 @@ function buildMinimaxVideoProvider(providerId: string): VideoGenerationProvider
255299maxInputImages: 1,
256300maxDurationSeconds: 10,
257301supportedDurationSecondsByModel: MINIMAX_MODEL_ALLOWED_DURATIONS,
302+resolutions: ["768P", "1080P"],
258303supportsResolution: true,
259304supportsWatermark: false,
260305},
@@ -303,8 +348,12 @@ function buildMinimaxVideoProvider(providerId: string): VideoGenerationProvider
303348if (firstFrameImage) {
304349body.first_frame_image = firstFrameImage;
305350}
306-if (req.resolution) {
307-body.resolution = req.resolution;
351+const resolution = resolveResolution({
352+ model,
353+resolution: req.resolution,
354+});
355+if (resolution) {
356+body.resolution = resolution;
308357}
309358const durationSeconds = resolveDurationSeconds({
310359 model,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。