@ai-sdk/minimax 2.0.11 → 2.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +104 -38
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/minimax-video-model-options.ts +4 -3
- package/src/minimax-video-model.ts +128 -45
- package/src/minimax-video-settings.ts +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @ai-sdk/minimax
|
|
2
2
|
|
|
3
|
+
## 2.0.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2c90e90: fix(provider/minimax): send a default `16:9` ratio for MiniMax-H3 text-to-video
|
|
8
|
+
|
|
9
|
+
## 2.0.12
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 658d7d9: Add model-aware MiniMax 480P and 768P video resolutions, duration limits, and reference-input validation.
|
|
14
|
+
- 658d7d9: Map MiniMax 480P and 768P frame sizes onto their named video resolution tiers, so a typed top-level `resolution` can reach them.
|
|
15
|
+
- Updated dependencies [cc23556]
|
|
16
|
+
- @ai-sdk/provider-utils@4.0.50
|
|
17
|
+
- @ai-sdk/anthropic@3.0.115
|
|
18
|
+
|
|
3
19
|
## 2.0.11
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ declare const minimaxLanguageModelOptions: z.ZodObject<{
|
|
|
13
13
|
}, z.core.$strip>;
|
|
14
14
|
type MiniMaxLanguageModelOptions = z.infer<typeof minimaxLanguageModelOptions>;
|
|
15
15
|
|
|
16
|
-
type MiniMaxVideoModelId = 'MiniMax-H3' | (string & {});
|
|
16
|
+
type MiniMaxVideoModelId = 'MiniMax-H3' | 'MiniMax-H3-Max' | (string & {});
|
|
17
17
|
|
|
18
18
|
interface MiniMaxProviderSettings {
|
|
19
19
|
/**
|
|
@@ -75,6 +75,8 @@ declare const minimax: MiniMaxProvider;
|
|
|
75
75
|
*/
|
|
76
76
|
declare const minimaxVideoProviderOptions: z.ZodObject<{
|
|
77
77
|
resolution: z.ZodOptional<z.ZodEnum<{
|
|
78
|
+
"480P": "480P";
|
|
79
|
+
"768P": "768P";
|
|
78
80
|
"2K": "2K";
|
|
79
81
|
}>>;
|
|
80
82
|
ratio: z.ZodOptional<z.ZodEnum<{
|
package/dist/index.js
CHANGED
|
@@ -39,7 +39,7 @@ var minimaxVideoRatios = [
|
|
|
39
39
|
"3:4",
|
|
40
40
|
"9:16"
|
|
41
41
|
];
|
|
42
|
-
var minimaxVideoResolutions = ["2K"];
|
|
42
|
+
var minimaxVideoResolutions = ["480P", "768P", "2K"];
|
|
43
43
|
var minimaxVideoProviderOptions = z.object({
|
|
44
44
|
/**
|
|
45
45
|
* Output resolution.
|
|
@@ -72,23 +72,40 @@ var minimaxVideoModelOptionsSchema = lazySchema(
|
|
|
72
72
|
|
|
73
73
|
// src/minimax-video-model.ts
|
|
74
74
|
var DEFAULT_RESOLUTION = "2K";
|
|
75
|
+
var DEFAULT_ASPECT_RATIO = "16:9";
|
|
75
76
|
var DEFAULT_POLL_INTERVAL_MS = 1e4;
|
|
76
77
|
var DEFAULT_POLL_TIMEOUT_MS = 6e5;
|
|
77
|
-
var
|
|
78
|
+
var DEFAULT_DURATION_SECONDS = 5;
|
|
78
79
|
var MAX_DURATION_SECONDS = 15;
|
|
79
80
|
var MAX_REFERENCE_IMAGES = 9;
|
|
80
81
|
var MAX_REFERENCE_VIDEOS = 3;
|
|
81
82
|
var MAX_REFERENCE_AUDIOS = 3;
|
|
82
83
|
var allowedRatios = new Set(minimaxVideoRatios);
|
|
83
84
|
var allowedResolutions = new Set(minimaxVideoResolutions);
|
|
85
|
+
var modelResolutionSettings = {
|
|
86
|
+
"MiniMax-H3": { supported: ["768P", "2K"], default: DEFAULT_RESOLUTION },
|
|
87
|
+
"MiniMax-H3-Max": { supported: ["480P", "768P"], default: "768P" }
|
|
88
|
+
};
|
|
84
89
|
var RESOLUTION_MAP = {
|
|
85
|
-
//
|
|
90
|
+
// 480P — square, landscape, portrait
|
|
91
|
+
"480x480": "480P",
|
|
92
|
+
"1120x480": "480P",
|
|
93
|
+
"854x480": "480P",
|
|
94
|
+
"640x480": "480P",
|
|
95
|
+
"480x854": "480P",
|
|
96
|
+
"480x640": "480P",
|
|
97
|
+
// 768P — square, landscape, portrait
|
|
98
|
+
"768x768": "768P",
|
|
99
|
+
"1792x768": "768P",
|
|
100
|
+
"1366x768": "768P",
|
|
101
|
+
"1024x768": "768P",
|
|
102
|
+
"768x1366": "768P",
|
|
103
|
+
"768x1024": "768P",
|
|
104
|
+
// 2K — square, landscape, portrait
|
|
86
105
|
"2048x2048": "2K",
|
|
87
|
-
// Landscape
|
|
88
106
|
"2560x1080": "2K",
|
|
89
107
|
"2560x1440": "2K",
|
|
90
108
|
"2048x1536": "2K",
|
|
91
|
-
// Portrait
|
|
92
109
|
"1440x2560": "2K",
|
|
93
110
|
"1536x2048": "2K"
|
|
94
111
|
};
|
|
@@ -118,7 +135,7 @@ var MiniMaxVideoModel = class {
|
|
|
118
135
|
return this.config.provider;
|
|
119
136
|
}
|
|
120
137
|
async doGenerate(options) {
|
|
121
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
138
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
122
139
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
123
140
|
const warnings = [];
|
|
124
141
|
const minimaxOptions = await parseProviderOptions({
|
|
@@ -130,31 +147,43 @@ var MiniMaxVideoModel = class {
|
|
|
130
147
|
warnings.push({
|
|
131
148
|
type: "unsupported",
|
|
132
149
|
feature: "fps",
|
|
133
|
-
details:
|
|
150
|
+
details: `${this.modelId} does not support a custom frame rate.`
|
|
134
151
|
});
|
|
135
152
|
}
|
|
136
153
|
if (options.seed != null) {
|
|
137
154
|
warnings.push({
|
|
138
155
|
type: "unsupported",
|
|
139
156
|
feature: "seed",
|
|
140
|
-
details:
|
|
157
|
+
details: `${this.modelId} does not support a seed.`
|
|
141
158
|
});
|
|
142
159
|
}
|
|
143
160
|
if (options.n != null && options.n > 1) {
|
|
144
161
|
warnings.push({
|
|
145
162
|
type: "unsupported",
|
|
146
163
|
feature: "n",
|
|
147
|
-
details:
|
|
164
|
+
details: `${this.modelId} generates a single video per call. Only 1 video will be generated.`
|
|
148
165
|
});
|
|
149
166
|
}
|
|
150
167
|
if (options.generateAudio != null) {
|
|
151
168
|
warnings.push({
|
|
152
169
|
type: "unsupported",
|
|
153
170
|
feature: "generateAudio",
|
|
154
|
-
details:
|
|
171
|
+
details: `The ${this.modelId} API does not expose an audio parameter. The generateAudio option was ignored.`
|
|
155
172
|
});
|
|
156
173
|
}
|
|
174
|
+
const resolutionSettings = modelResolutionSettings[this.modelId];
|
|
175
|
+
const supportedResolutions = (_d = resolutionSettings == null ? void 0 : resolutionSettings.supported) != null ? _d : minimaxVideoResolutions;
|
|
176
|
+
const supportedResolutionSet = new Set(supportedResolutions);
|
|
177
|
+
const supportedResolutionNames = supportedResolutions.map((resolution2) => `"${resolution2}"`).join(" or ");
|
|
157
178
|
let resolution = minimaxOptions == null ? void 0 : minimaxOptions.resolution;
|
|
179
|
+
if (resolution != null && !supportedResolutionSet.has(resolution)) {
|
|
180
|
+
warnings.push({
|
|
181
|
+
type: "unsupported",
|
|
182
|
+
feature: "resolution",
|
|
183
|
+
details: `${this.modelId} supports ${supportedResolutionNames}. The provider resolution "${resolution}" was ignored.`
|
|
184
|
+
});
|
|
185
|
+
resolution = void 0;
|
|
186
|
+
}
|
|
158
187
|
if (options.resolution != null) {
|
|
159
188
|
const mapped = resolveTopLevelResolution(options.resolution);
|
|
160
189
|
if (resolution != null) {
|
|
@@ -162,38 +191,44 @@ var MiniMaxVideoModel = class {
|
|
|
162
191
|
warnings.push({
|
|
163
192
|
type: "unsupported",
|
|
164
193
|
feature: "resolution",
|
|
165
|
-
details: `Unrecognized resolution "${options.resolution}".
|
|
194
|
+
details: `Unrecognized resolution "${options.resolution}". ${this.modelId} supports ${supportedResolutionNames}, so providerOptions.minimax.resolution ("${resolution}") was used instead.`
|
|
195
|
+
});
|
|
196
|
+
} else if (mapped !== resolution) {
|
|
197
|
+
warnings.push({
|
|
198
|
+
type: "unsupported",
|
|
199
|
+
feature: "resolution",
|
|
200
|
+
details: `The resolution "${options.resolution}" selects ${mapped}, but providerOptions.minimax.resolution ("${resolution}") was used instead.`
|
|
166
201
|
});
|
|
167
202
|
}
|
|
168
|
-
} else if (mapped != null) {
|
|
203
|
+
} else if (mapped != null && supportedResolutionSet.has(mapped)) {
|
|
169
204
|
resolution = mapped;
|
|
170
205
|
} else {
|
|
171
206
|
warnings.push({
|
|
172
207
|
type: "unsupported",
|
|
173
208
|
feature: "resolution",
|
|
174
|
-
details: `Unrecognized resolution "${options.resolution}".
|
|
209
|
+
details: mapped == null ? `Unrecognized resolution "${options.resolution}". ${this.modelId} supports ${supportedResolutionNames}.` : `${this.modelId} does not support the resolution "${mapped}". It supports ${supportedResolutionNames}.`
|
|
175
210
|
});
|
|
176
211
|
}
|
|
177
212
|
}
|
|
178
|
-
resolution != null ? resolution : resolution = DEFAULT_RESOLUTION;
|
|
213
|
+
resolution != null ? resolution : resolution = (_e = resolutionSettings == null ? void 0 : resolutionSettings.default) != null ? _e : DEFAULT_RESOLUTION;
|
|
179
214
|
const content = [
|
|
180
|
-
{ type: "text", text: (
|
|
215
|
+
{ type: "text", text: (_f = options.prompt) != null ? _f : "" }
|
|
181
216
|
];
|
|
182
217
|
let sentImageCount = 0;
|
|
183
218
|
const sentReferenceVideoUrls = [];
|
|
184
|
-
const firstFrameImage = (
|
|
219
|
+
const firstFrameImage = (_h = (_g = options.frameImages) == null ? void 0 : _g.find(
|
|
185
220
|
(frame) => frame.frameType === "first_frame"
|
|
186
|
-
)) == null ? void 0 :
|
|
221
|
+
)) == null ? void 0 : _h.image;
|
|
187
222
|
let firstFrame = firstFrameImage != null ? firstFrameImage : options.image;
|
|
188
|
-
let lastFrame = (
|
|
223
|
+
let lastFrame = (_j = (_i = options.frameImages) == null ? void 0 : _i.find(
|
|
189
224
|
(frame) => frame.frameType === "last_frame"
|
|
190
|
-
)) == null ? void 0 :
|
|
225
|
+
)) == null ? void 0 : _j.image;
|
|
191
226
|
const firstFrameMediaType = firstFrame != null ? nonImageFrameMediaType(firstFrame) : void 0;
|
|
192
227
|
if (firstFrame != null && firstFrameMediaType != null) {
|
|
193
228
|
warnings.push({
|
|
194
229
|
type: "unsupported",
|
|
195
230
|
feature: firstFrameImage != null ? "frameImages" : "image",
|
|
196
|
-
details: firstFrameMediaType === "video" ?
|
|
231
|
+
details: firstFrameMediaType === "video" ? `${this.modelId} does not accept a video as a frame image. The video was ignored.` : `${this.modelId} only accepts an image as a frame image; the "${firstFrame.mediaType}" file was ignored.`
|
|
197
232
|
});
|
|
198
233
|
firstFrame = void 0;
|
|
199
234
|
}
|
|
@@ -202,7 +237,7 @@ var MiniMaxVideoModel = class {
|
|
|
202
237
|
warnings.push({
|
|
203
238
|
type: "unsupported",
|
|
204
239
|
feature: "frameImages",
|
|
205
|
-
details:
|
|
240
|
+
details: `${this.modelId} requires a first_frame when a last_frame is provided. The last_frame was ignored.`
|
|
206
241
|
});
|
|
207
242
|
lastFrame = void 0;
|
|
208
243
|
} else {
|
|
@@ -211,16 +246,31 @@ var MiniMaxVideoModel = class {
|
|
|
211
246
|
warnings.push({
|
|
212
247
|
type: "unsupported",
|
|
213
248
|
feature: "frameImages",
|
|
214
|
-
details: lastFrameMediaType === "video" ?
|
|
249
|
+
details: lastFrameMediaType === "video" ? `${this.modelId} does not accept a video as a frame image. The last_frame video was ignored.` : `${this.modelId} only accepts an image as a frame image; the "${lastFrame.mediaType}" last_frame was ignored.`
|
|
215
250
|
});
|
|
216
251
|
lastFrame = void 0;
|
|
217
252
|
}
|
|
218
253
|
}
|
|
219
254
|
}
|
|
220
255
|
const usesFrameImages = firstFrame != null || lastFrame != null;
|
|
221
|
-
const referenceFiles = (
|
|
222
|
-
const referenceAudioUrls = (
|
|
223
|
-
const
|
|
256
|
+
const referenceFiles = (_k = options.inputReferences) != null ? _k : [];
|
|
257
|
+
const referenceAudioUrls = (_l = minimaxOptions == null ? void 0 : minimaxOptions.referenceAudioUrls) != null ? _l : [];
|
|
258
|
+
const supportsReferences = this.modelId !== "MiniMax-H3-Max";
|
|
259
|
+
if (!supportsReferences && referenceFiles.length > 0) {
|
|
260
|
+
warnings.push({
|
|
261
|
+
type: "unsupported",
|
|
262
|
+
feature: "inputReferences",
|
|
263
|
+
details: "MiniMax-H3-Max does not support reference-to-video inputs. The references were ignored."
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
if (!supportsReferences && referenceAudioUrls.length > 0) {
|
|
267
|
+
warnings.push({
|
|
268
|
+
type: "unsupported",
|
|
269
|
+
feature: "referenceAudioUrls",
|
|
270
|
+
details: "MiniMax-H3-Max does not support reference audio. The audio was ignored."
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
const usesReferences = supportsReferences && (referenceFiles.length > 0 || referenceAudioUrls.length > 0);
|
|
224
274
|
if (usesFrameImages) {
|
|
225
275
|
if (firstFrame != null) {
|
|
226
276
|
content.push({
|
|
@@ -327,6 +377,7 @@ var MiniMaxVideoModel = class {
|
|
|
327
377
|
}
|
|
328
378
|
}
|
|
329
379
|
}
|
|
380
|
+
const isTextToVideo = content.length === 1;
|
|
330
381
|
let ratio = minimaxOptions == null ? void 0 : minimaxOptions.ratio;
|
|
331
382
|
if (ratio == null && options.aspectRatio != null) {
|
|
332
383
|
if (allowedRatios.has(options.aspectRatio)) {
|
|
@@ -335,42 +386,57 @@ var MiniMaxVideoModel = class {
|
|
|
335
386
|
warnings.push({
|
|
336
387
|
type: "unsupported",
|
|
337
388
|
feature: "aspectRatio",
|
|
338
|
-
details: `MiniMax-H3 does not support the aspect ratio "${options.aspectRatio}". Using the provider default (adaptive).`
|
|
389
|
+
details: isTextToVideo ? `MiniMax-H3 does not support the aspect ratio "${options.aspectRatio}". Using the default (${DEFAULT_ASPECT_RATIO}).` : `MiniMax-H3 does not support the aspect ratio "${options.aspectRatio}". Using the provider default (adaptive).`
|
|
339
390
|
});
|
|
391
|
+
if (isTextToVideo) {
|
|
392
|
+
ratio = DEFAULT_ASPECT_RATIO;
|
|
393
|
+
}
|
|
340
394
|
}
|
|
341
395
|
}
|
|
396
|
+
if (ratio === "adaptive" && isTextToVideo) {
|
|
397
|
+
warnings.push({
|
|
398
|
+
type: "unsupported",
|
|
399
|
+
feature: "aspectRatio",
|
|
400
|
+
details: `MiniMax-H3 text-to-video does not support the adaptive aspect ratio. Using the default (${DEFAULT_ASPECT_RATIO}).`
|
|
401
|
+
});
|
|
402
|
+
ratio = DEFAULT_ASPECT_RATIO;
|
|
403
|
+
}
|
|
342
404
|
if (usesFrameImages && ratio != null) {
|
|
343
405
|
warnings.push({
|
|
344
406
|
type: "unsupported",
|
|
345
407
|
feature: "aspectRatio",
|
|
346
|
-
details:
|
|
408
|
+
details: `${this.modelId} derives the aspect ratio from the frame image; the requested ratio was ignored.`
|
|
347
409
|
});
|
|
348
410
|
ratio = void 0;
|
|
349
411
|
}
|
|
350
|
-
|
|
412
|
+
if (ratio == null && isTextToVideo) {
|
|
413
|
+
ratio = DEFAULT_ASPECT_RATIO;
|
|
414
|
+
}
|
|
415
|
+
const minDurationSeconds = this.modelId === "MiniMax-H3" ? 4 : 5;
|
|
416
|
+
let duration = (_m = options.duration) != null ? _m : DEFAULT_DURATION_SECONDS;
|
|
351
417
|
if (options.duration != null) {
|
|
352
418
|
if (!Number.isInteger(duration)) {
|
|
353
419
|
duration = Math.round(duration);
|
|
354
420
|
warnings.push({
|
|
355
421
|
type: "unsupported",
|
|
356
422
|
feature: "duration",
|
|
357
|
-
details:
|
|
423
|
+
details: `${this.modelId} requires a whole number of seconds. The requested duration of ${options.duration} was rounded to ${duration}.`
|
|
358
424
|
});
|
|
359
425
|
}
|
|
360
426
|
if (duration > MAX_DURATION_SECONDS) {
|
|
361
427
|
warnings.push({
|
|
362
428
|
type: "unsupported",
|
|
363
429
|
feature: "duration",
|
|
364
|
-
details:
|
|
430
|
+
details: `${this.modelId} supports at most ${MAX_DURATION_SECONDS} seconds. The requested duration of ${options.duration} was clamped to ${MAX_DURATION_SECONDS}.`
|
|
365
431
|
});
|
|
366
432
|
duration = MAX_DURATION_SECONDS;
|
|
367
|
-
} else if (duration <
|
|
433
|
+
} else if (duration < minDurationSeconds) {
|
|
368
434
|
warnings.push({
|
|
369
435
|
type: "unsupported",
|
|
370
436
|
feature: "duration",
|
|
371
|
-
details:
|
|
437
|
+
details: `${this.modelId} requires at least ${minDurationSeconds} seconds. The requested duration of ${options.duration} was clamped to ${minDurationSeconds}.`
|
|
372
438
|
});
|
|
373
|
-
duration =
|
|
439
|
+
duration = minDurationSeconds;
|
|
374
440
|
}
|
|
375
441
|
}
|
|
376
442
|
const body = {
|
|
@@ -407,8 +473,8 @@ var MiniMaxVideoModel = class {
|
|
|
407
473
|
message: `No task_id returned from the MiniMax API. Response: ${JSON.stringify(createResponse)}`
|
|
408
474
|
});
|
|
409
475
|
}
|
|
410
|
-
const pollIntervalMs = (
|
|
411
|
-
const pollTimeoutMs = (
|
|
476
|
+
const pollIntervalMs = (_n = minimaxOptions == null ? void 0 : minimaxOptions.pollIntervalMs) != null ? _n : DEFAULT_POLL_INTERVAL_MS;
|
|
477
|
+
const pollTimeoutMs = (_o = minimaxOptions == null ? void 0 : minimaxOptions.pollTimeoutMs) != null ? _o : DEFAULT_POLL_TIMEOUT_MS;
|
|
412
478
|
const startTime = Date.now();
|
|
413
479
|
let responseHeaders;
|
|
414
480
|
while (true) {
|
|
@@ -436,7 +502,7 @@ var MiniMaxVideoModel = class {
|
|
|
436
502
|
const task = statusResponse.task;
|
|
437
503
|
switch (task.status) {
|
|
438
504
|
case "succeeded": {
|
|
439
|
-
const url = (
|
|
505
|
+
const url = (_p = task.content) == null ? void 0 : _p.url;
|
|
440
506
|
if (!url) {
|
|
441
507
|
throw new AISDKError({
|
|
442
508
|
name: "MINIMAX_VIDEO_GENERATION_ERROR",
|
|
@@ -482,7 +548,7 @@ var MiniMaxVideoModel = class {
|
|
|
482
548
|
case "failed": {
|
|
483
549
|
throw new AISDKError({
|
|
484
550
|
name: "MINIMAX_VIDEO_GENERATION_FAILED",
|
|
485
|
-
message: `MiniMax video generation failed${((
|
|
551
|
+
message: `MiniMax video generation failed${((_q = task.error) == null ? void 0 : _q.message) ? `: ${task.error.message}` : ""}${((_r = task.error) == null ? void 0 : _r.code) != null ? ` (${task.error.code})` : ""}. Task ID: ${taskId}`
|
|
486
552
|
});
|
|
487
553
|
}
|
|
488
554
|
case "cancelled": {
|
|
@@ -546,7 +612,7 @@ var minimaxVideoFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
546
612
|
});
|
|
547
613
|
|
|
548
614
|
// src/version.ts
|
|
549
|
-
var VERSION = true ? "2.0.
|
|
615
|
+
var VERSION = true ? "2.0.13" : "0.0.0-test";
|
|
550
616
|
|
|
551
617
|
// src/minimax-provider.ts
|
|
552
618
|
var defaultBaseURL = "https://api.minimax.io/anthropic/v1";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/minimax-provider.ts","../src/minimax-video-model.ts","../src/minimax-video-model-options.ts","../src/version.ts"],"sourcesContent":["import {\n NoSuchModelError,\n type Experimental_VideoModelV3,\n type LanguageModelV3,\n type ProviderV3,\n} from '@ai-sdk/provider';\nimport {\n generateId,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { AnthropicMessagesLanguageModel } from '@ai-sdk/anthropic/internal';\nimport type { MiniMaxChatModelId } from './minimax-chat-options';\nimport { MiniMaxVideoModel } from './minimax-video-model';\nimport type { MiniMaxVideoModelId } from './minimax-video-settings';\nimport { VERSION } from './version';\n\nexport interface MiniMaxProviderSettings {\n /**\n * MiniMax API key. Default value is taken from the `MINIMAX_API_KEY`\n * environment variable.\n */\n apiKey?: string;\n /**\n * Base URL for the API calls. Defaults to MiniMax's Anthropic-compatible\n * endpoint (`https://api.minimax.io/anthropic/v1`).\n */\n baseURL?: string;\n /**\n * Use a different URL prefix for video generation API calls.\n * The default prefix is `https://api.minimax.io`.\n */\n videoBaseURL?: string;\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface MiniMaxProvider extends ProviderV3 {\n /**\n * Creates a MiniMax model for text generation.\n */\n (modelId: MiniMaxChatModelId): LanguageModelV3;\n\n /**\n * Creates a MiniMax language model for text generation.\n */\n languageModel(modelId: MiniMaxChatModelId): LanguageModelV3;\n\n /**\n * Creates a MiniMax chat model for text generation.\n */\n chat(modelId: MiniMaxChatModelId): LanguageModelV3;\n\n /**\n * Creates a MiniMax video model for video generation.\n */\n video(modelId: MiniMaxVideoModelId): Experimental_VideoModelV3;\n\n /**\n * Creates a MiniMax video model for video generation.\n */\n videoModel(modelId: MiniMaxVideoModelId): Experimental_VideoModelV3;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nconst defaultBaseURL = 'https://api.minimax.io/anthropic/v1';\nconst defaultVideoBaseURL = 'https://api.minimax.io';\n\nexport function createMiniMax(\n options: MiniMaxProviderSettings = {},\n): MiniMaxProvider {\n const baseURL =\n withoutTrailingSlash(options.baseURL ?? defaultBaseURL) ?? defaultBaseURL;\n\n const videoBaseURL =\n withoutTrailingSlash(options.videoBaseURL ?? defaultVideoBaseURL) ??\n defaultVideoBaseURL;\n\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n 'anthropic-version': '2023-06-01',\n 'x-api-key': loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'MINIMAX_API_KEY',\n description: 'MiniMax API key',\n }),\n ...options.headers,\n },\n `ai-sdk/minimax/${VERSION}`,\n );\n\n const createChatModel = (modelId: MiniMaxChatModelId) =>\n new AnthropicMessagesLanguageModel(modelId, {\n provider: 'minimax.messages',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n generateId,\n supportedUrls: () => ({}),\n });\n\n const getVideoHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'MINIMAX_API_KEY',\n description: 'MiniMax API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk/minimax/${VERSION}`,\n );\n\n const createVideoModel = (modelId: MiniMaxVideoModelId) =>\n new MiniMaxVideoModel(modelId, {\n provider: 'minimax.video',\n baseURL: videoBaseURL,\n headers: getVideoHeaders,\n fetch: options.fetch,\n });\n\n const provider = (modelId: MiniMaxChatModelId) => createChatModel(modelId);\n\n provider.specificationVersion = 'v3' as const;\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.video = createVideoModel;\n provider.videoModel = createVideoModel;\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n return provider;\n}\n\nexport const minimax = createMiniMax();\n","import {\n AISDKError,\n type Experimental_VideoModelV3,\n type Experimental_VideoModelV3File,\n type SharedV3Warning,\n} from '@ai-sdk/provider';\nimport {\n combineHeaders,\n convertImageModelFileToDataUri,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n delay,\n getFromApi,\n parseProviderOptions,\n postJsonToApi,\n resolve,\n type FetchFunction,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport {\n minimaxVideoModelOptionsSchema,\n minimaxVideoRatios,\n minimaxVideoResolutions,\n type MiniMaxVideoModelOptions,\n} from './minimax-video-model-options';\nimport type { MiniMaxVideoModelId } from './minimax-video-settings';\n\ninterface MiniMaxVideoModelConfig {\n provider: string;\n // API root without a version suffix, e.g. `https://api.minimax.io`.\n baseURL: string;\n headers: Resolvable<Record<string, string | undefined>>;\n fetch?: FetchFunction;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\ntype MiniMaxVideoDoGenerateOptions = Parameters<\n Experimental_VideoModelV3['doGenerate']\n>[0];\n\nconst DEFAULT_RESOLUTION = '2K';\nconst DEFAULT_POLL_INTERVAL_MS = 10_000;\nconst DEFAULT_POLL_TIMEOUT_MS = 600_000;\nconst MIN_DURATION_SECONDS = 5;\nconst MAX_DURATION_SECONDS = 15;\nconst MAX_REFERENCE_IMAGES = 9;\nconst MAX_REFERENCE_VIDEOS = 3;\nconst MAX_REFERENCE_AUDIOS = 3;\n\nconst allowedRatios = new Set<string>(minimaxVideoRatios);\nconst allowedResolutions = new Set<string>(minimaxVideoResolutions);\n\n// The top-level `resolution` is `{width}x{height}`, but the API takes a named\n// tier, so map the canonical 2K frame sizes onto the single tier H3 supports.\n// Anything else can't be honored and warns.\n// One canonical frame size per ratio H3 supports, so a caller who pairs a\n// resolution with any supported ratio resolves to the tier instead of being\n// told 2K is unsupported.\nconst RESOLUTION_MAP: Record<string, string> = {\n // Square\n '2048x2048': '2K',\n // Landscape\n '2560x1080': '2K',\n '2560x1440': '2K',\n '2048x1536': '2K',\n // Portrait\n '1440x2560': '2K',\n '1536x2048': '2K',\n};\n\n// A caller may pass the named tier itself rather than a frame size — `2K` is\n// what the MiniMax API takes, so it is the natural thing to send. Accept it\n// case-insensitively instead of reporting it as unrecognized.\nfunction resolveTopLevelResolution(resolution: string): string | undefined {\n const named = resolution.toUpperCase();\n return allowedResolutions.has(named) ? named : RESOLUTION_MAP[resolution];\n}\n\n// The `type` half of a `type/subtype` media type, e.g. `image` for `image/png`.\nfunction getTopLevelMediaType(mediaType: string): string {\n const slashIndex = mediaType.indexOf('/');\n return slashIndex === -1 ? mediaType : mediaType.substring(0, slashIndex);\n}\n\n// Frame images must be images. Returns the offending top-level media type when\n// a frame is something else, so it can be rejected the way a reference input of\n// the wrong kind is. A frame with no media type is left alone: the core emits\n// URL inputs without one, and unlike a reference there is no routing decision\n// riding on it.\nfunction nonImageFrameMediaType(\n file: Experimental_VideoModelV3File,\n): string | undefined {\n if (file.mediaType == null) {\n return undefined;\n }\n\n const topLevelMediaType = getTopLevelMediaType(file.mediaType);\n return topLevelMediaType === 'image' ? undefined : topLevelMediaType;\n}\n\nexport class MiniMaxVideoModel implements Experimental_VideoModelV3 {\n readonly specificationVersion = 'v3';\n readonly maxVideosPerCall = 1;\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: MiniMaxVideoModelId,\n private config: MiniMaxVideoModelConfig,\n ) {}\n\n async doGenerate(\n options: MiniMaxVideoDoGenerateOptions,\n ): Promise<Awaited<ReturnType<Experimental_VideoModelV3['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const warnings: SharedV3Warning[] = [];\n\n const minimaxOptions = (await parseProviderOptions({\n provider: 'minimax',\n providerOptions: options.providerOptions,\n schema: minimaxVideoModelOptionsSchema,\n })) as MiniMaxVideoModelOptions | undefined;\n\n if (options.fps != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'fps',\n details: 'MiniMax-H3 does not support a custom frame rate.',\n });\n }\n\n if (options.seed != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'seed',\n details: 'MiniMax-H3 does not support a seed.',\n });\n }\n\n if (options.n != null && options.n > 1) {\n warnings.push({\n type: 'unsupported',\n feature: 'n',\n details:\n 'MiniMax-H3 generates a single video per call. Only 1 video will be generated.',\n });\n }\n\n if (options.generateAudio != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'generateAudio',\n details:\n 'The MiniMax-H3 API does not expose an audio parameter. The generateAudio option was ignored.',\n });\n }\n\n // Resolution: the API takes a named tier, so an explicit provider option\n // wins and a top-level value is resolved to a tier.\n let resolution: string | undefined = minimaxOptions?.resolution;\n if (options.resolution != null) {\n const mapped = resolveTopLevelResolution(options.resolution);\n if (resolution != null) {\n // The provider option is already a tier, so the only way the two can\n // disagree is a top-level value that maps to no tier at all.\n if (mapped == null) {\n warnings.push({\n type: 'unsupported',\n feature: 'resolution',\n details:\n `Unrecognized resolution \"${options.resolution}\". MiniMax-H3 only supports \"2K\", ` +\n `so providerOptions.minimax.resolution (\"${resolution}\") was used instead.`,\n });\n }\n } else if (mapped != null) {\n resolution = mapped;\n } else {\n warnings.push({\n type: 'unsupported',\n feature: 'resolution',\n details:\n `Unrecognized resolution \"${options.resolution}\". MiniMax-H3 only ` +\n 'supports \"2K\".',\n });\n }\n }\n resolution ??= DEFAULT_RESOLUTION;\n\n // `convertImageModelFileToDataUri` passes `url` files through unchanged and\n // encodes inline data as a data URI. MiniMax `mm_file://…` handles survive\n // that pass-through, but not the core `generateVideo` path: it base64-decodes\n // any string that is not `http(s)://` or `data:`, so `mm_file://` only\n // reaches the API through `providerOptions.minimax.referenceAudioUrls`,\n // which is forwarded raw — not through `image`, `frameImages`, or\n // `inputReferences`.\n const content: Array<Record<string, unknown>> = [\n { type: 'text', text: options.prompt ?? '' },\n ];\n\n // The inputs that actually make it into `content` below, after the caps and\n // rejections H3 imposes. Reported as `providerMetadata.minimax\n // .resolvedInputs`: the warnings say an input was dropped, but not how many\n // survived, which callers that meter usage need. Accumulated at the push\n // sites rather than re-derived, so the two cannot disagree.\n let sentImageCount = 0;\n const sentReferenceVideoUrls: string[] = [];\n\n // Resolve first/last frame inputs. A standalone `image` is treated as the\n // first frame (image-to-video). The core sets `image` to the `first_frame`\n // frame image when there is one, so the frame-image entry is tracked\n // separately to report which input a warning came from.\n const firstFrameImage = options.frameImages?.find(\n frame => frame.frameType === 'first_frame',\n )?.image;\n let firstFrame = firstFrameImage ?? options.image;\n let lastFrame = options.frameImages?.find(\n frame => frame.frameType === 'last_frame',\n )?.image;\n\n // Reject unusable frames before deciding the generation mode.\n const firstFrameMediaType =\n firstFrame != null ? nonImageFrameMediaType(firstFrame) : undefined;\n if (firstFrame != null && firstFrameMediaType != null) {\n warnings.push({\n type: 'unsupported',\n feature: firstFrameImage != null ? 'frameImages' : 'image',\n details:\n firstFrameMediaType === 'video'\n ? 'MiniMax-H3 does not accept a video as a frame image. The video was ignored.'\n : `MiniMax-H3 only accepts an image as a frame image; the \"${firstFrame.mediaType}\" file was ignored.`,\n });\n firstFrame = undefined;\n }\n\n if (lastFrame != null) {\n if (firstFrame == null) {\n warnings.push({\n type: 'unsupported',\n feature: 'frameImages',\n details:\n 'MiniMax-H3 requires a first_frame when a last_frame is provided. The last_frame was ignored.',\n });\n lastFrame = undefined;\n } else {\n const lastFrameMediaType = nonImageFrameMediaType(lastFrame);\n if (lastFrameMediaType != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'frameImages',\n details:\n lastFrameMediaType === 'video'\n ? 'MiniMax-H3 does not accept a video as a frame image. The last_frame video was ignored.'\n : `MiniMax-H3 only accepts an image as a frame image; the \"${lastFrame.mediaType}\" last_frame was ignored.`,\n });\n lastFrame = undefined;\n }\n }\n }\n\n const usesFrameImages = firstFrame != null || lastFrame != null;\n\n const referenceFiles = options.inputReferences ?? [];\n const referenceAudioUrls = minimaxOptions?.referenceAudioUrls ?? [];\n const usesReferences =\n referenceFiles.length > 0 || referenceAudioUrls.length > 0;\n\n if (usesFrameImages) {\n if (firstFrame != null) {\n content.push({\n type: 'image_url',\n image_url: { url: convertImageModelFileToDataUri(firstFrame) },\n role: 'first_frame',\n });\n sentImageCount++;\n }\n\n if (lastFrame != null) {\n content.push({\n type: 'image_url',\n image_url: { url: convertImageModelFileToDataUri(lastFrame) },\n role: 'last_frame',\n });\n sentImageCount++;\n }\n\n // Frame images and reference inputs are mutually exclusive.\n if (usesReferences) {\n warnings.push({\n type: 'unsupported',\n feature: 'inputReferences',\n details:\n 'MiniMax-H3 cannot combine frame images with reference inputs. The references were ignored.',\n });\n }\n } else if (usesReferences) {\n const referenceImages: Experimental_VideoModelV3File[] = [];\n const referenceVideos: Experimental_VideoModelV3File[] = [];\n\n for (const file of referenceFiles) {\n const topLevelMediaType =\n file.mediaType != null\n ? getTopLevelMediaType(file.mediaType)\n : undefined;\n\n if (topLevelMediaType === 'video') {\n referenceVideos.push(file);\n } else if (topLevelMediaType === 'image') {\n referenceImages.push(file);\n } else if (topLevelMediaType == null) {\n // Only URL references can omit a media type.\n // Fall back to an image and warn\n warnings.push({\n type: 'unsupported',\n feature: 'inputReferences',\n details:\n 'MiniMax-H3 requires an explicit mediaType to route URL references as ' +\n 'video or image. Pass { data: url, mediaType: \"video/mp4\" } for video ' +\n 'references. The reference was treated as an image.',\n });\n referenceImages.push(file);\n } else {\n warnings.push({\n type: 'unsupported',\n feature: 'inputReferences',\n details:\n `MiniMax-H3 only accepts image and video references; the \"${file.mediaType}\" ` +\n 'reference was ignored. Pass reference audio via ' +\n 'providerOptions.minimax.referenceAudioUrls.',\n });\n }\n }\n\n for (const image of referenceImages.slice(0, MAX_REFERENCE_IMAGES)) {\n content.push({\n type: 'image_url',\n image_url: { url: convertImageModelFileToDataUri(image) },\n role: 'reference_image',\n });\n sentImageCount++;\n }\n if (referenceImages.length > MAX_REFERENCE_IMAGES) {\n warnings.push({\n type: 'unsupported',\n feature: 'inputReferences',\n details: `MiniMax-H3 accepts at most ${MAX_REFERENCE_IMAGES} reference images. Extra images were ignored.`,\n });\n }\n\n for (const video of referenceVideos.slice(0, MAX_REFERENCE_VIDEOS)) {\n const url = convertImageModelFileToDataUri(video);\n content.push({\n type: 'video_url',\n video_url: { url },\n role: 'reference_video',\n });\n // Inline files become data URIs, which are not worth echoing back.\n if (video.type === 'url') {\n sentReferenceVideoUrls.push(url);\n }\n }\n if (referenceVideos.length > MAX_REFERENCE_VIDEOS) {\n warnings.push({\n type: 'unsupported',\n feature: 'inputReferences',\n details: `MiniMax-H3 accepts at most ${MAX_REFERENCE_VIDEOS} reference videos. Extra videos were ignored.`,\n });\n }\n\n // Reference audio must accompany at least one reference image or video.\n if (referenceAudioUrls.length > 0) {\n if (referenceImages.length === 0 && referenceVideos.length === 0) {\n warnings.push({\n type: 'unsupported',\n feature: 'referenceAudioUrls',\n details:\n 'MiniMax-H3 reference audio must be paired with at least one reference image or video. The audio was ignored.',\n });\n } else {\n for (const url of referenceAudioUrls.slice(0, MAX_REFERENCE_AUDIOS)) {\n content.push({\n type: 'audio_url',\n audio_url: { url },\n role: 'reference_audio',\n });\n }\n if (referenceAudioUrls.length > MAX_REFERENCE_AUDIOS) {\n warnings.push({\n type: 'unsupported',\n feature: 'referenceAudioUrls',\n details: `MiniMax-H3 accepts at most ${MAX_REFERENCE_AUDIOS} reference audios. Extra audios were ignored.`,\n });\n }\n }\n }\n }\n\n // Aspect ratio. In frame-image mode the ratio follows the supplied image,\n // so an explicit ratio is ignored.\n let ratio = minimaxOptions?.ratio as string | undefined;\n if (ratio == null && options.aspectRatio != null) {\n if (allowedRatios.has(options.aspectRatio)) {\n ratio = options.aspectRatio;\n } else {\n warnings.push({\n type: 'unsupported',\n feature: 'aspectRatio',\n details:\n `MiniMax-H3 does not support the aspect ratio \"${options.aspectRatio}\". ` +\n 'Using the provider default (adaptive).',\n });\n }\n }\n if (usesFrameImages && ratio != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'aspectRatio',\n details:\n 'MiniMax-H3 derives the aspect ratio from the frame image; the requested ratio was ignored.',\n });\n ratio = undefined;\n }\n\n // H3 takes an integer between 5 and 15, so round before clamping: a\n // fractional duration is rejected by the API just as an out-of-range one is.\n let duration = options.duration ?? MIN_DURATION_SECONDS;\n if (options.duration != null) {\n if (!Number.isInteger(duration)) {\n duration = Math.round(duration);\n warnings.push({\n type: 'unsupported',\n feature: 'duration',\n details: `MiniMax-H3 requires a whole number of seconds. The requested duration of ${options.duration} was rounded to ${duration}.`,\n });\n }\n\n if (duration > MAX_DURATION_SECONDS) {\n warnings.push({\n type: 'unsupported',\n feature: 'duration',\n details: `MiniMax-H3 supports at most ${MAX_DURATION_SECONDS} seconds. The requested duration of ${options.duration} was clamped to ${MAX_DURATION_SECONDS}.`,\n });\n duration = MAX_DURATION_SECONDS;\n } else if (duration < MIN_DURATION_SECONDS) {\n warnings.push({\n type: 'unsupported',\n feature: 'duration',\n details: `MiniMax-H3 requires at least ${MIN_DURATION_SECONDS} seconds. The requested duration of ${options.duration} was clamped to ${MIN_DURATION_SECONDS}.`,\n });\n duration = MIN_DURATION_SECONDS;\n }\n }\n\n const body: Record<string, unknown> = {\n model: this.modelId,\n content,\n resolution,\n duration,\n };\n if (ratio != null) {\n body.ratio = ratio;\n }\n if (minimaxOptions?.aigcWatermark != null) {\n body.aigc_watermark = minimaxOptions.aigcWatermark;\n }\n\n const baseURL = this.config.baseURL;\n\n const { value: createResponse } = await postJsonToApi({\n url: `${baseURL}/v2/video_generation`,\n headers: combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n ),\n body,\n failedResponseHandler: minimaxVideoFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n minimaxCreateVideoResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const taskId = createResponse.task_id;\n if (!taskId) {\n throw new AISDKError({\n name: 'MINIMAX_VIDEO_GENERATION_ERROR',\n message: `No task_id returned from the MiniMax API. Response: ${JSON.stringify(createResponse)}`,\n });\n }\n\n const pollIntervalMs =\n minimaxOptions?.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;\n const pollTimeoutMs =\n minimaxOptions?.pollTimeoutMs ?? DEFAULT_POLL_TIMEOUT_MS;\n const startTime = Date.now();\n let responseHeaders: Record<string, string> | undefined;\n\n while (true) {\n await delay(pollIntervalMs, { abortSignal: options.abortSignal });\n\n if (Date.now() - startTime > pollTimeoutMs) {\n throw new AISDKError({\n name: 'MINIMAX_VIDEO_GENERATION_TIMEOUT',\n message: `MiniMax video generation timed out after ${pollTimeoutMs}ms. Task ID: ${taskId}`,\n });\n }\n\n const { value: statusResponse, responseHeaders: pollHeaders } =\n await getFromApi({\n url: `${baseURL}/v2/query/video_generation/${taskId}`,\n headers: combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n ),\n successfulResponseHandler: createJsonResponseHandler(\n minimaxVideoStatusResponseSchema,\n ),\n failedResponseHandler: minimaxVideoFailedResponseHandler,\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n responseHeaders = pollHeaders;\n const task = statusResponse.task;\n\n switch (task.status) {\n case 'succeeded': {\n const url = task.content?.url;\n if (!url) {\n throw new AISDKError({\n name: 'MINIMAX_VIDEO_GENERATION_ERROR',\n message: `MiniMax video generation completed but no video URL was returned. Task ID: ${taskId}`,\n });\n }\n\n return {\n videos: [\n {\n type: 'url' as const,\n url,\n mediaType: 'video/mp4',\n },\n ],\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n providerMetadata: {\n minimax: {\n taskId,\n videoUrl: url,\n resolvedInputs: {\n imageCount: sentImageCount,\n referenceVideoUrls: sentReferenceVideoUrls,\n },\n ...(task.duration != null ? { duration: task.duration } : {}),\n ...(task.ratio != null ? { ratio: task.ratio } : {}),\n ...(task.resolution != null\n ? { resolution: task.resolution }\n : {}),\n ...(task.usage != null\n ? {\n usage: {\n totalSeconds: task.usage.total_seconds,\n inputSeconds: task.usage.input_seconds,\n outputSeconds: task.usage.output_seconds,\n },\n }\n : {}),\n },\n },\n };\n }\n\n case 'failed': {\n throw new AISDKError({\n name: 'MINIMAX_VIDEO_GENERATION_FAILED',\n message: `MiniMax video generation failed${\n task.error?.message ? `: ${task.error.message}` : ''\n }${task.error?.code != null ? ` (${task.error.code})` : ''}. Task ID: ${taskId}`,\n });\n }\n\n case 'cancelled': {\n throw new AISDKError({\n name: 'MINIMAX_VIDEO_GENERATION_CANCELLED',\n message: `MiniMax video generation was cancelled. Task ID: ${taskId}`,\n });\n }\n\n case 'expired': {\n throw new AISDKError({\n name: 'MINIMAX_VIDEO_GENERATION_EXPIRED',\n message: `MiniMax video generation request expired. Task ID: ${taskId}`,\n });\n }\n\n // 'queued' | 'running' | unknown → keep polling.\n default:\n break;\n }\n }\n }\n}\n\nconst minimaxCreateVideoResponseSchema = z.object({\n task_id: z.string().nullish(),\n});\n\nconst minimaxVideoStatusResponseSchema = z.object({\n task: z.object({\n id: z.string().nullish(),\n status: z.string().nullish(),\n content: z\n .object({\n url: z.string().nullish(),\n })\n .nullish(),\n resolution: z.string().nullish(),\n duration: z.number().nullish(),\n ratio: z.string().nullish(),\n usage: z\n .object({\n total_seconds: z.number().nullish(),\n input_seconds: z.number().nullish(),\n output_seconds: z.number().nullish(),\n })\n .nullish(),\n error: z\n .object({\n code: z.union([z.string(), z.number()]).nullish(),\n message: z.string().nullish(),\n })\n .nullish(),\n }),\n});\n\nconst minimaxVideoErrorSchema = z.object({\n type: z.string().nullish(),\n error: z\n .object({\n type: z.string().nullish(),\n message: z.string().nullish(),\n http_code: z.union([z.string(), z.number()]).nullish(),\n })\n .nullish(),\n request_id: z.string().nullish(),\n});\n\nconst minimaxVideoFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: minimaxVideoErrorSchema,\n errorToMessage: data =>\n data.error?.message ?? 'MiniMax video generation error',\n});\n","import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n/**\n * Aspect ratios supported by the MiniMax-H3 video model.\n */\nexport const minimaxVideoRatios = [\n 'adaptive',\n '21:9',\n '16:9',\n '4:3',\n '1:1',\n '3:4',\n '9:16',\n] as const;\n\n/**\n * Output resolutions supported by the MiniMax-H3 video model.\n */\nexport const minimaxVideoResolutions = ['2K'] as const;\n\n/**\n * Provider options for MiniMax video generation.\n */\nexport const minimaxVideoProviderOptions = z.object({\n /**\n * Output resolution.\n */\n resolution: z.enum(minimaxVideoResolutions).optional(),\n\n /**\n * Aspect ratio of the generated video. Overrides the top-level `aspectRatio`.\n */\n ratio: z.enum(minimaxVideoRatios).optional(),\n\n /**\n * Reference audio URLs for reference-to-video generation.\n */\n referenceAudioUrls: z.array(z.string()).optional(),\n\n /**\n * Whether to embed an AIGC watermark in the output. Defaults to `false`.\n */\n aigcWatermark: z.boolean().optional(),\n\n /**\n * Interval in milliseconds between task status polls. Default: 10000.\n */\n pollIntervalMs: z.number().int().positive().optional(),\n\n /**\n * Maximum time in milliseconds to poll before timing out. Default: 600000.\n */\n pollTimeoutMs: z.number().int().positive().optional(),\n});\n\nexport type MiniMaxVideoModelOptions = z.infer<\n typeof minimaxVideoProviderOptions\n>;\n\nexport const minimaxVideoModelOptionsSchema = lazySchema(() =>\n zodSchema(minimaxVideoProviderOptions),\n);\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAIK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,sCAAsC;;;ACb/C;AAAA,EACE;AAAA,OAIK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,KAAAA,UAAS;;;ACnBlB,SAAS,YAAY,iBAAiB;AACtC,SAAS,SAAS;AAKX,IAAM,qBAAqB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAKO,IAAM,0BAA0B,CAAC,IAAI;AAKrC,IAAM,8BAA8B,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA,EAIlD,Y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AAAA,QACzB,aAAa;AAAA,MACf,CAAC;AAAA,MACD,GAAG,QAAQ;AAAA,IACb;AAAA,IACA,kBAAkB,OAAO;AAAA,EAC3B;AAEF,QAAM,kBAAkB,CAAC,YACvB,IAAI,+BAA+B,SAAS;AAAA,IAC1C,UAAU;AAAA,IACV;AAAA,IACA,SAAS;AAAA,IACT,OAAO,QAAQ;AAAA,IACf;AAAA,IACA,eAAe,OAAO,CAAC;AAAA,EACzB,CAAC;AAEH,QAAM,kBAAkB,MACtB;AAAA,IACE;AAAA,MACE,eAAe,UAAU,WAAW;AAAA,QAClC,QAAQ,QAAQ;AAAA,QAChB,yBAAyB;AAAA,QACzB,aAAa;AAAA,MACf,CAAC,CAAC;AAAA,MACF,GAAG,QAAQ;AAAA,IACb;AAAA,IACA,kBAAkB,OAAO;AAAA,EAC3B;AAEF,QAAM,mBAAmB,CAAC,YACxB,IAAI,kBAAkB,SAAS;AAAA,IAC7B,UAAU;AAAA,IACV,SAAS;AAAA,IACT,SAAS;AAAA,IACT,OAAO,QAAQ;AAAA,EACjB,CAAC;AAEH,QAAM,WAAW,CAAC,YAAgC,gBAAgB,OAAO;AAEzE,WAAS,uBAAuB;AAChC,WAAS,gBAAgB;AACzB,WAAS,OAAO;AAChB,WAAS,QAAQ;AACjB,WAAS,aAAa;AAEtB,WAAS,iBAAiB,CAAC,YAAoB;AAC7C,UAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,iBAAiB,CAAC;AAAA,EACrE;AACA,WAAS,qBAAqB,SAAS;AACvC,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AAEA,SAAO;AACT;AAEO,IAAM,UAAU,cAAc;","names":["z","z"]}
|
|
1
|
+
{"version":3,"sources":["../src/minimax-provider.ts","../src/minimax-video-model.ts","../src/minimax-video-model-options.ts","../src/version.ts"],"sourcesContent":["import {\n NoSuchModelError,\n type Experimental_VideoModelV3,\n type LanguageModelV3,\n type ProviderV3,\n} from '@ai-sdk/provider';\nimport {\n generateId,\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { AnthropicMessagesLanguageModel } from '@ai-sdk/anthropic/internal';\nimport type { MiniMaxChatModelId } from './minimax-chat-options';\nimport { MiniMaxVideoModel } from './minimax-video-model';\nimport type { MiniMaxVideoModelId } from './minimax-video-settings';\nimport { VERSION } from './version';\n\nexport interface MiniMaxProviderSettings {\n /**\n * MiniMax API key. Default value is taken from the `MINIMAX_API_KEY`\n * environment variable.\n */\n apiKey?: string;\n /**\n * Base URL for the API calls. Defaults to MiniMax's Anthropic-compatible\n * endpoint (`https://api.minimax.io/anthropic/v1`).\n */\n baseURL?: string;\n /**\n * Use a different URL prefix for video generation API calls.\n * The default prefix is `https://api.minimax.io`.\n */\n videoBaseURL?: string;\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n}\n\nexport interface MiniMaxProvider extends ProviderV3 {\n /**\n * Creates a MiniMax model for text generation.\n */\n (modelId: MiniMaxChatModelId): LanguageModelV3;\n\n /**\n * Creates a MiniMax language model for text generation.\n */\n languageModel(modelId: MiniMaxChatModelId): LanguageModelV3;\n\n /**\n * Creates a MiniMax chat model for text generation.\n */\n chat(modelId: MiniMaxChatModelId): LanguageModelV3;\n\n /**\n * Creates a MiniMax video model for video generation.\n */\n video(modelId: MiniMaxVideoModelId): Experimental_VideoModelV3;\n\n /**\n * Creates a MiniMax video model for video generation.\n */\n videoModel(modelId: MiniMaxVideoModelId): Experimental_VideoModelV3;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: string): never;\n}\n\nconst defaultBaseURL = 'https://api.minimax.io/anthropic/v1';\nconst defaultVideoBaseURL = 'https://api.minimax.io';\n\nexport function createMiniMax(\n options: MiniMaxProviderSettings = {},\n): MiniMaxProvider {\n const baseURL =\n withoutTrailingSlash(options.baseURL ?? defaultBaseURL) ?? defaultBaseURL;\n\n const videoBaseURL =\n withoutTrailingSlash(options.videoBaseURL ?? defaultVideoBaseURL) ??\n defaultVideoBaseURL;\n\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n 'anthropic-version': '2023-06-01',\n 'x-api-key': loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'MINIMAX_API_KEY',\n description: 'MiniMax API key',\n }),\n ...options.headers,\n },\n `ai-sdk/minimax/${VERSION}`,\n );\n\n const createChatModel = (modelId: MiniMaxChatModelId) =>\n new AnthropicMessagesLanguageModel(modelId, {\n provider: 'minimax.messages',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n generateId,\n supportedUrls: () => ({}),\n });\n\n const getVideoHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'MINIMAX_API_KEY',\n description: 'MiniMax API key',\n })}`,\n ...options.headers,\n },\n `ai-sdk/minimax/${VERSION}`,\n );\n\n const createVideoModel = (modelId: MiniMaxVideoModelId) =>\n new MiniMaxVideoModel(modelId, {\n provider: 'minimax.video',\n baseURL: videoBaseURL,\n headers: getVideoHeaders,\n fetch: options.fetch,\n });\n\n const provider = (modelId: MiniMaxChatModelId) => createChatModel(modelId);\n\n provider.specificationVersion = 'v3' as const;\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.video = createVideoModel;\n provider.videoModel = createVideoModel;\n\n provider.embeddingModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'embeddingModel' });\n };\n provider.textEmbeddingModel = provider.embeddingModel;\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n return provider;\n}\n\nexport const minimax = createMiniMax();\n","import {\n AISDKError,\n type Experimental_VideoModelV3,\n type Experimental_VideoModelV3File,\n type SharedV3Warning,\n} from '@ai-sdk/provider';\nimport {\n combineHeaders,\n convertImageModelFileToDataUri,\n createJsonErrorResponseHandler,\n createJsonResponseHandler,\n delay,\n getFromApi,\n parseProviderOptions,\n postJsonToApi,\n resolve,\n type FetchFunction,\n type Resolvable,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport {\n minimaxVideoModelOptionsSchema,\n minimaxVideoRatios,\n minimaxVideoResolutions,\n type MiniMaxVideoModelOptions,\n} from './minimax-video-model-options';\nimport type { MiniMaxVideoModelId } from './minimax-video-settings';\n\ninterface MiniMaxVideoModelConfig {\n provider: string;\n // API root without a version suffix, e.g. `https://api.minimax.io`.\n baseURL: string;\n headers: Resolvable<Record<string, string | undefined>>;\n fetch?: FetchFunction;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\ntype MiniMaxVideoDoGenerateOptions = Parameters<\n Experimental_VideoModelV3['doGenerate']\n>[0];\n\nconst DEFAULT_RESOLUTION = '2K';\nconst DEFAULT_ASPECT_RATIO = '16:9';\nconst DEFAULT_POLL_INTERVAL_MS = 10_000;\nconst DEFAULT_POLL_TIMEOUT_MS = 600_000;\nconst DEFAULT_DURATION_SECONDS = 5;\nconst MAX_DURATION_SECONDS = 15;\nconst MAX_REFERENCE_IMAGES = 9;\nconst MAX_REFERENCE_VIDEOS = 3;\nconst MAX_REFERENCE_AUDIOS = 3;\n\nconst allowedRatios = new Set<string>(minimaxVideoRatios);\nconst allowedResolutions = new Set<string>(minimaxVideoResolutions);\nconst modelResolutionSettings: Record<\n string,\n { supported: readonly string[]; default: string }\n> = {\n 'MiniMax-H3': { supported: ['768P', '2K'], default: DEFAULT_RESOLUTION },\n 'MiniMax-H3-Max': { supported: ['480P', '768P'], default: '768P' },\n};\n\n// The top-level `resolution` is `{width}x{height}`, but the API takes a named\n// tier, so map canonical frame sizes onto the tiers. One frame size per ratio\n// per tier, so a caller who pairs a resolution with any supported ratio\n// resolves to the tier instead of being told the resolution is unsupported.\n// MiniMax does not publish tier dimensions, so this is a closed table rather\n// than a rule: 480P and 768P rows are named for the shorter side, the 2K rows\n// for the longer one. A frame size not listed here warns.\nconst RESOLUTION_MAP: Record<string, string> = {\n // 480P — square, landscape, portrait\n '480x480': '480P',\n '1120x480': '480P',\n '854x480': '480P',\n '640x480': '480P',\n '480x854': '480P',\n '480x640': '480P',\n // 768P — square, landscape, portrait\n '768x768': '768P',\n '1792x768': '768P',\n '1366x768': '768P',\n '1024x768': '768P',\n '768x1366': '768P',\n '768x1024': '768P',\n // 2K — square, landscape, portrait\n '2048x2048': '2K',\n '2560x1080': '2K',\n '2560x1440': '2K',\n '2048x1536': '2K',\n '1440x2560': '2K',\n '1536x2048': '2K',\n};\n\n// A caller may pass a named tier itself rather than a frame size. Normalize it\n// case-insensitively to the exact casing expected by the MiniMax API.\nfunction resolveTopLevelResolution(resolution: string): string | undefined {\n const named = resolution.toUpperCase();\n return allowedResolutions.has(named) ? named : RESOLUTION_MAP[resolution];\n}\n\n// The `type` half of a `type/subtype` media type, e.g. `image` for `image/png`.\nfunction getTopLevelMediaType(mediaType: string): string {\n const slashIndex = mediaType.indexOf('/');\n return slashIndex === -1 ? mediaType : mediaType.substring(0, slashIndex);\n}\n\n// Frame images must be images. Returns the offending top-level media type when\n// a frame is something else, so it can be rejected the way a reference input of\n// the wrong kind is. A frame with no media type is left alone: the core emits\n// URL inputs without one, and unlike a reference there is no routing decision\n// riding on it.\nfunction nonImageFrameMediaType(\n file: Experimental_VideoModelV3File,\n): string | undefined {\n if (file.mediaType == null) {\n return undefined;\n }\n\n const topLevelMediaType = getTopLevelMediaType(file.mediaType);\n return topLevelMediaType === 'image' ? undefined : topLevelMediaType;\n}\n\nexport class MiniMaxVideoModel implements Experimental_VideoModelV3 {\n readonly specificationVersion = 'v3';\n readonly maxVideosPerCall = 1;\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: MiniMaxVideoModelId,\n private config: MiniMaxVideoModelConfig,\n ) {}\n\n async doGenerate(\n options: MiniMaxVideoDoGenerateOptions,\n ): Promise<Awaited<ReturnType<Experimental_VideoModelV3['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const warnings: SharedV3Warning[] = [];\n\n const minimaxOptions = (await parseProviderOptions({\n provider: 'minimax',\n providerOptions: options.providerOptions,\n schema: minimaxVideoModelOptionsSchema,\n })) as MiniMaxVideoModelOptions | undefined;\n\n if (options.fps != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'fps',\n details: `${this.modelId} does not support a custom frame rate.`,\n });\n }\n\n if (options.seed != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'seed',\n details: `${this.modelId} does not support a seed.`,\n });\n }\n\n if (options.n != null && options.n > 1) {\n warnings.push({\n type: 'unsupported',\n feature: 'n',\n details: `${this.modelId} generates a single video per call. Only 1 video will be generated.`,\n });\n }\n\n if (options.generateAudio != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'generateAudio',\n details: `The ${this.modelId} API does not expose an audio parameter. The generateAudio option was ignored.`,\n });\n }\n\n const resolutionSettings = modelResolutionSettings[this.modelId];\n const supportedResolutions =\n resolutionSettings?.supported ?? minimaxVideoResolutions;\n const supportedResolutionSet = new Set<string>(supportedResolutions);\n const supportedResolutionNames = supportedResolutions\n .map(resolution => `\"${resolution}\"`)\n .join(' or ');\n\n // Resolution: the API takes a named tier, so an explicit provider option\n // wins and a top-level value is resolved to a tier.\n let resolution: string | undefined = minimaxOptions?.resolution;\n if (resolution != null && !supportedResolutionSet.has(resolution)) {\n warnings.push({\n type: 'unsupported',\n feature: 'resolution',\n details: `${this.modelId} supports ${supportedResolutionNames}. The provider resolution \"${resolution}\" was ignored.`,\n });\n resolution = undefined;\n }\n\n if (options.resolution != null) {\n const mapped = resolveTopLevelResolution(options.resolution);\n if (resolution != null) {\n // The provider option is already a tier and wins, so say so whenever\n // the top-level value is dropped — it either names no tier, or names a\n // different one now that every tier has frame sizes.\n if (mapped == null) {\n warnings.push({\n type: 'unsupported',\n feature: 'resolution',\n details:\n `Unrecognized resolution \"${options.resolution}\". ${this.modelId} supports ${supportedResolutionNames}, ` +\n `so providerOptions.minimax.resolution (\"${resolution}\") was used instead.`,\n });\n } else if (mapped !== resolution) {\n warnings.push({\n type: 'unsupported',\n feature: 'resolution',\n details:\n `The resolution \"${options.resolution}\" selects ${mapped}, but ` +\n `providerOptions.minimax.resolution (\"${resolution}\") was used instead.`,\n });\n }\n } else if (mapped != null && supportedResolutionSet.has(mapped)) {\n resolution = mapped;\n } else {\n warnings.push({\n type: 'unsupported',\n feature: 'resolution',\n details:\n mapped == null\n ? `Unrecognized resolution \"${options.resolution}\". ${this.modelId} supports ${supportedResolutionNames}.`\n : `${this.modelId} does not support the resolution \"${mapped}\". It supports ${supportedResolutionNames}.`,\n });\n }\n }\n resolution ??= resolutionSettings?.default ?? DEFAULT_RESOLUTION;\n\n // `convertImageModelFileToDataUri` passes `url` files through unchanged and\n // encodes inline data as a data URI. MiniMax `mm_file://…` handles survive\n // that pass-through, but not the core `generateVideo` path: it base64-decodes\n // any string that is not `http(s)://` or `data:`, so `mm_file://` only\n // reaches the API through `providerOptions.minimax.referenceAudioUrls`,\n // which is forwarded raw — not through `image`, `frameImages`, or\n // `inputReferences`.\n const content: Array<Record<string, unknown>> = [\n { type: 'text', text: options.prompt ?? '' },\n ];\n\n // The inputs that actually make it into `content` below, after the caps and\n // rejections H3 imposes. Reported as `providerMetadata.minimax\n // .resolvedInputs`: the warnings say an input was dropped, but not how many\n // survived, which callers that meter usage need. Accumulated at the push\n // sites rather than re-derived, so the two cannot disagree.\n let sentImageCount = 0;\n const sentReferenceVideoUrls: string[] = [];\n\n // Resolve first/last frame inputs. A standalone `image` is treated as the\n // first frame (image-to-video). The core sets `image` to the `first_frame`\n // frame image when there is one, so the frame-image entry is tracked\n // separately to report which input a warning came from.\n const firstFrameImage = options.frameImages?.find(\n frame => frame.frameType === 'first_frame',\n )?.image;\n let firstFrame = firstFrameImage ?? options.image;\n let lastFrame = options.frameImages?.find(\n frame => frame.frameType === 'last_frame',\n )?.image;\n\n // Reject unusable frames before deciding the generation mode.\n const firstFrameMediaType =\n firstFrame != null ? nonImageFrameMediaType(firstFrame) : undefined;\n if (firstFrame != null && firstFrameMediaType != null) {\n warnings.push({\n type: 'unsupported',\n feature: firstFrameImage != null ? 'frameImages' : 'image',\n details:\n firstFrameMediaType === 'video'\n ? `${this.modelId} does not accept a video as a frame image. The video was ignored.`\n : `${this.modelId} only accepts an image as a frame image; the \"${firstFrame.mediaType}\" file was ignored.`,\n });\n firstFrame = undefined;\n }\n\n if (lastFrame != null) {\n if (firstFrame == null) {\n warnings.push({\n type: 'unsupported',\n feature: 'frameImages',\n details: `${this.modelId} requires a first_frame when a last_frame is provided. The last_frame was ignored.`,\n });\n lastFrame = undefined;\n } else {\n const lastFrameMediaType = nonImageFrameMediaType(lastFrame);\n if (lastFrameMediaType != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'frameImages',\n details:\n lastFrameMediaType === 'video'\n ? `${this.modelId} does not accept a video as a frame image. The last_frame video was ignored.`\n : `${this.modelId} only accepts an image as a frame image; the \"${lastFrame.mediaType}\" last_frame was ignored.`,\n });\n lastFrame = undefined;\n }\n }\n }\n\n const usesFrameImages = firstFrame != null || lastFrame != null;\n\n const referenceFiles = options.inputReferences ?? [];\n const referenceAudioUrls = minimaxOptions?.referenceAudioUrls ?? [];\n const supportsReferences = this.modelId !== 'MiniMax-H3-Max';\n\n if (!supportsReferences && referenceFiles.length > 0) {\n warnings.push({\n type: 'unsupported',\n feature: 'inputReferences',\n details:\n 'MiniMax-H3-Max does not support reference-to-video inputs. The references were ignored.',\n });\n }\n\n if (!supportsReferences && referenceAudioUrls.length > 0) {\n warnings.push({\n type: 'unsupported',\n feature: 'referenceAudioUrls',\n details:\n 'MiniMax-H3-Max does not support reference audio. The audio was ignored.',\n });\n }\n\n const usesReferences =\n supportsReferences &&\n (referenceFiles.length > 0 || referenceAudioUrls.length > 0);\n\n if (usesFrameImages) {\n if (firstFrame != null) {\n content.push({\n type: 'image_url',\n image_url: { url: convertImageModelFileToDataUri(firstFrame) },\n role: 'first_frame',\n });\n sentImageCount++;\n }\n\n if (lastFrame != null) {\n content.push({\n type: 'image_url',\n image_url: { url: convertImageModelFileToDataUri(lastFrame) },\n role: 'last_frame',\n });\n sentImageCount++;\n }\n\n // Frame images and reference inputs are mutually exclusive.\n if (usesReferences) {\n warnings.push({\n type: 'unsupported',\n feature: 'inputReferences',\n details:\n 'MiniMax-H3 cannot combine frame images with reference inputs. The references were ignored.',\n });\n }\n } else if (usesReferences) {\n const referenceImages: Experimental_VideoModelV3File[] = [];\n const referenceVideos: Experimental_VideoModelV3File[] = [];\n\n for (const file of referenceFiles) {\n const topLevelMediaType =\n file.mediaType != null\n ? getTopLevelMediaType(file.mediaType)\n : undefined;\n\n if (topLevelMediaType === 'video') {\n referenceVideos.push(file);\n } else if (topLevelMediaType === 'image') {\n referenceImages.push(file);\n } else if (topLevelMediaType == null) {\n // Only URL references can omit a media type.\n // Fall back to an image and warn\n warnings.push({\n type: 'unsupported',\n feature: 'inputReferences',\n details:\n 'MiniMax-H3 requires an explicit mediaType to route URL references as ' +\n 'video or image. Pass { data: url, mediaType: \"video/mp4\" } for video ' +\n 'references. The reference was treated as an image.',\n });\n referenceImages.push(file);\n } else {\n warnings.push({\n type: 'unsupported',\n feature: 'inputReferences',\n details:\n `MiniMax-H3 only accepts image and video references; the \"${file.mediaType}\" ` +\n 'reference was ignored. Pass reference audio via ' +\n 'providerOptions.minimax.referenceAudioUrls.',\n });\n }\n }\n\n for (const image of referenceImages.slice(0, MAX_REFERENCE_IMAGES)) {\n content.push({\n type: 'image_url',\n image_url: { url: convertImageModelFileToDataUri(image) },\n role: 'reference_image',\n });\n sentImageCount++;\n }\n if (referenceImages.length > MAX_REFERENCE_IMAGES) {\n warnings.push({\n type: 'unsupported',\n feature: 'inputReferences',\n details: `MiniMax-H3 accepts at most ${MAX_REFERENCE_IMAGES} reference images. Extra images were ignored.`,\n });\n }\n\n for (const video of referenceVideos.slice(0, MAX_REFERENCE_VIDEOS)) {\n const url = convertImageModelFileToDataUri(video);\n content.push({\n type: 'video_url',\n video_url: { url },\n role: 'reference_video',\n });\n // Inline files become data URIs, which are not worth echoing back.\n if (video.type === 'url') {\n sentReferenceVideoUrls.push(url);\n }\n }\n if (referenceVideos.length > MAX_REFERENCE_VIDEOS) {\n warnings.push({\n type: 'unsupported',\n feature: 'inputReferences',\n details: `MiniMax-H3 accepts at most ${MAX_REFERENCE_VIDEOS} reference videos. Extra videos were ignored.`,\n });\n }\n\n // Reference audio must accompany at least one reference image or video.\n if (referenceAudioUrls.length > 0) {\n if (referenceImages.length === 0 && referenceVideos.length === 0) {\n warnings.push({\n type: 'unsupported',\n feature: 'referenceAudioUrls',\n details:\n 'MiniMax-H3 reference audio must be paired with at least one reference image or video. The audio was ignored.',\n });\n } else {\n for (const url of referenceAudioUrls.slice(0, MAX_REFERENCE_AUDIOS)) {\n content.push({\n type: 'audio_url',\n audio_url: { url },\n role: 'reference_audio',\n });\n }\n if (referenceAudioUrls.length > MAX_REFERENCE_AUDIOS) {\n warnings.push({\n type: 'unsupported',\n feature: 'referenceAudioUrls',\n details: `MiniMax-H3 accepts at most ${MAX_REFERENCE_AUDIOS} reference audios. Extra audios were ignored.`,\n });\n }\n }\n }\n }\n\n // Aspect ratio. In frame-image mode the ratio follows the supplied image,\n // so an explicit ratio is ignored.\n const isTextToVideo = content.length === 1;\n let ratio = minimaxOptions?.ratio as string | undefined;\n if (ratio == null && options.aspectRatio != null) {\n if (allowedRatios.has(options.aspectRatio)) {\n ratio = options.aspectRatio;\n } else {\n warnings.push({\n type: 'unsupported',\n feature: 'aspectRatio',\n details: isTextToVideo\n ? `MiniMax-H3 does not support the aspect ratio \"${options.aspectRatio}\". Using the default (${DEFAULT_ASPECT_RATIO}).`\n : `MiniMax-H3 does not support the aspect ratio \"${options.aspectRatio}\". Using the provider default (adaptive).`,\n });\n if (isTextToVideo) {\n ratio = DEFAULT_ASPECT_RATIO;\n }\n }\n }\n if (ratio === 'adaptive' && isTextToVideo) {\n warnings.push({\n type: 'unsupported',\n feature: 'aspectRatio',\n details:\n 'MiniMax-H3 text-to-video does not support the adaptive aspect ratio. ' +\n `Using the default (${DEFAULT_ASPECT_RATIO}).`,\n });\n ratio = DEFAULT_ASPECT_RATIO;\n }\n if (usesFrameImages && ratio != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'aspectRatio',\n details: `${this.modelId} derives the aspect ratio from the frame image; the requested ratio was ignored.`,\n });\n ratio = undefined;\n }\n if (ratio == null && isTextToVideo) {\n ratio = DEFAULT_ASPECT_RATIO;\n }\n\n // Both H3 models take an integer duration, but H3 starts at 4 seconds while\n // H3-Max starts at 5. Round before clamping because the API rejects both\n // fractional and out-of-range values.\n const minDurationSeconds = this.modelId === 'MiniMax-H3' ? 4 : 5;\n let duration = options.duration ?? DEFAULT_DURATION_SECONDS;\n if (options.duration != null) {\n if (!Number.isInteger(duration)) {\n duration = Math.round(duration);\n warnings.push({\n type: 'unsupported',\n feature: 'duration',\n details: `${this.modelId} requires a whole number of seconds. The requested duration of ${options.duration} was rounded to ${duration}.`,\n });\n }\n\n if (duration > MAX_DURATION_SECONDS) {\n warnings.push({\n type: 'unsupported',\n feature: 'duration',\n details: `${this.modelId} supports at most ${MAX_DURATION_SECONDS} seconds. The requested duration of ${options.duration} was clamped to ${MAX_DURATION_SECONDS}.`,\n });\n duration = MAX_DURATION_SECONDS;\n } else if (duration < minDurationSeconds) {\n warnings.push({\n type: 'unsupported',\n feature: 'duration',\n details: `${this.modelId} requires at least ${minDurationSeconds} seconds. The requested duration of ${options.duration} was clamped to ${minDurationSeconds}.`,\n });\n duration = minDurationSeconds;\n }\n }\n\n const body: Record<string, unknown> = {\n model: this.modelId,\n content,\n resolution,\n duration,\n };\n if (ratio != null) {\n body.ratio = ratio;\n }\n if (minimaxOptions?.aigcWatermark != null) {\n body.aigc_watermark = minimaxOptions.aigcWatermark;\n }\n\n const baseURL = this.config.baseURL;\n\n const { value: createResponse } = await postJsonToApi({\n url: `${baseURL}/v2/video_generation`,\n headers: combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n ),\n body,\n failedResponseHandler: minimaxVideoFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n minimaxCreateVideoResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const taskId = createResponse.task_id;\n if (!taskId) {\n throw new AISDKError({\n name: 'MINIMAX_VIDEO_GENERATION_ERROR',\n message: `No task_id returned from the MiniMax API. Response: ${JSON.stringify(createResponse)}`,\n });\n }\n\n const pollIntervalMs =\n minimaxOptions?.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;\n const pollTimeoutMs =\n minimaxOptions?.pollTimeoutMs ?? DEFAULT_POLL_TIMEOUT_MS;\n const startTime = Date.now();\n let responseHeaders: Record<string, string> | undefined;\n\n while (true) {\n await delay(pollIntervalMs, { abortSignal: options.abortSignal });\n\n if (Date.now() - startTime > pollTimeoutMs) {\n throw new AISDKError({\n name: 'MINIMAX_VIDEO_GENERATION_TIMEOUT',\n message: `MiniMax video generation timed out after ${pollTimeoutMs}ms. Task ID: ${taskId}`,\n });\n }\n\n const { value: statusResponse, responseHeaders: pollHeaders } =\n await getFromApi({\n url: `${baseURL}/v2/query/video_generation/${taskId}`,\n headers: combineHeaders(\n await resolve(this.config.headers),\n options.headers,\n ),\n successfulResponseHandler: createJsonResponseHandler(\n minimaxVideoStatusResponseSchema,\n ),\n failedResponseHandler: minimaxVideoFailedResponseHandler,\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n responseHeaders = pollHeaders;\n const task = statusResponse.task;\n\n switch (task.status) {\n case 'succeeded': {\n const url = task.content?.url;\n if (!url) {\n throw new AISDKError({\n name: 'MINIMAX_VIDEO_GENERATION_ERROR',\n message: `MiniMax video generation completed but no video URL was returned. Task ID: ${taskId}`,\n });\n }\n\n return {\n videos: [\n {\n type: 'url' as const,\n url,\n mediaType: 'video/mp4',\n },\n ],\n warnings,\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n },\n providerMetadata: {\n minimax: {\n taskId,\n videoUrl: url,\n resolvedInputs: {\n imageCount: sentImageCount,\n referenceVideoUrls: sentReferenceVideoUrls,\n },\n ...(task.duration != null ? { duration: task.duration } : {}),\n ...(task.ratio != null ? { ratio: task.ratio } : {}),\n ...(task.resolution != null\n ? { resolution: task.resolution }\n : {}),\n ...(task.usage != null\n ? {\n usage: {\n totalSeconds: task.usage.total_seconds,\n inputSeconds: task.usage.input_seconds,\n outputSeconds: task.usage.output_seconds,\n },\n }\n : {}),\n },\n },\n };\n }\n\n case 'failed': {\n throw new AISDKError({\n name: 'MINIMAX_VIDEO_GENERATION_FAILED',\n message: `MiniMax video generation failed${\n task.error?.message ? `: ${task.error.message}` : ''\n }${task.error?.code != null ? ` (${task.error.code})` : ''}. Task ID: ${taskId}`,\n });\n }\n\n case 'cancelled': {\n throw new AISDKError({\n name: 'MINIMAX_VIDEO_GENERATION_CANCELLED',\n message: `MiniMax video generation was cancelled. Task ID: ${taskId}`,\n });\n }\n\n case 'expired': {\n throw new AISDKError({\n name: 'MINIMAX_VIDEO_GENERATION_EXPIRED',\n message: `MiniMax video generation request expired. Task ID: ${taskId}`,\n });\n }\n\n // 'queued' | 'running' | unknown → keep polling.\n default:\n break;\n }\n }\n }\n}\n\nconst minimaxCreateVideoResponseSchema = z.object({\n task_id: z.string().nullish(),\n});\n\nconst minimaxVideoStatusResponseSchema = z.object({\n task: z.object({\n id: z.string().nullish(),\n status: z.string().nullish(),\n content: z\n .object({\n url: z.string().nullish(),\n })\n .nullish(),\n resolution: z.string().nullish(),\n duration: z.number().nullish(),\n ratio: z.string().nullish(),\n usage: z\n .object({\n total_seconds: z.number().nullish(),\n input_seconds: z.number().nullish(),\n output_seconds: z.number().nullish(),\n })\n .nullish(),\n error: z\n .object({\n code: z.union([z.string(), z.number()]).nullish(),\n message: z.string().nullish(),\n })\n .nullish(),\n }),\n});\n\nconst minimaxVideoErrorSchema = z.object({\n type: z.string().nullish(),\n error: z\n .object({\n type: z.string().nullish(),\n message: z.string().nullish(),\n http_code: z.union([z.string(), z.number()]).nullish(),\n })\n .nullish(),\n request_id: z.string().nullish(),\n});\n\nconst minimaxVideoFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: minimaxVideoErrorSchema,\n errorToMessage: data =>\n data.error?.message ?? 'MiniMax video generation error',\n});\n","import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n/**\n * Aspect ratios supported by the MiniMax video models.\n */\nexport const minimaxVideoRatios = [\n 'adaptive',\n '21:9',\n '16:9',\n '4:3',\n '1:1',\n '3:4',\n '9:16',\n] as const;\n\n/**\n * Output resolutions supported by MiniMax video models. Availability depends\n * on the selected model.\n */\nexport const minimaxVideoResolutions = ['480P', '768P', '2K'] as const;\n\n/**\n * Provider options for MiniMax video generation.\n */\nexport const minimaxVideoProviderOptions = z.object({\n /**\n * Output resolution.\n */\n resolution: z.enum(minimaxVideoResolutions).optional(),\n\n /**\n * Aspect ratio of the generated video. Overrides the top-level `aspectRatio`.\n */\n ratio: z.enum(minimaxVideoRatios).optional(),\n\n /**\n * Reference audio URLs for reference-to-video generation.\n */\n referenceAudioUrls: z.array(z.string()).optional(),\n\n /**\n * Whether to embed an AIGC watermark in the output. Defaults to `false`.\n */\n aigcWatermark: z.boolean().optional(),\n\n /**\n * Interval in milliseconds between task status polls. Default: 10000.\n */\n pollIntervalMs: z.number().int().positive().optional(),\n\n /**\n * Maximum time in milliseconds to poll before timing out. Default: 600000.\n */\n pollTimeoutMs: z.number().int().positive().optional(),\n});\n\nexport type MiniMaxVideoModelOptions = z.infer<\n typeof minimaxVideoProviderOptions\n>;\n\nexport const minimaxVideoModelOptionsSchema = lazySchema(() =>\n zodSchema(minimaxVideoProviderOptions),\n);\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAIK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,sCAAsC;;;ACb/C;AAAA,EACE;AAAA,OAIK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,KAAAA,UAAS;;;ACnBlB,SAAS,YAAY,iBAAiB;AACtC,SAAS,SAAS;AAKX,IAAM,qBAAqB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAMO,IAAM,0BAA0B,CAAC,QAAQ,QAAQ,IAAI;AAKrD,IAAM,8BAA8B,EAAE,OAAO;AAAA;AAAA;AAAA;AAAA,EAIlD,YAAY,EAAE,KAAK,uBAAuB,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA,EAKrD,OAAO,EAAE,KAAK,kBAAkB,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA,EAK3C,oBAAoB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA,EAKjD,eAAe,EAAE,QAAQ,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA,EAKpC,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS;AAAA;AAAA;AAAA;AAAA,EAKrD,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS;AACtD,CAAC;AAMM,IAAM,iCAAiC;AAAA,EAAW,MACvD,UAAU,2BAA2B;AACvC;;;ADpBA,IAAM,qBAAqB;AAC3B,IAAM,uBAAuB;AAC7B,IAAM,2BAA2B;A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AA,EACrE;AACA,WAAS,qBAAqB,SAAS;AACvC,WAAS,aAAa,CAAC,YAAoB;AACzC,UAAM,IAAI,iBAAiB,EAAE,SAAS,WAAW,aAAa,CAAC;AAAA,EACjE;AAEA,SAAO;AACT;AAEO,IAAM,UAAU,cAAc;","names":["z","resolution","z"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/minimax",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"@ai-sdk/anthropic": "3.0.115",
|
|
28
29
|
"@ai-sdk/provider": "3.0.15",
|
|
29
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
30
|
-
"@ai-sdk/anthropic": "3.0.114"
|
|
30
|
+
"@ai-sdk/provider-utils": "4.0.50"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "22.19.19",
|
|
@@ -2,7 +2,7 @@ import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';
|
|
|
2
2
|
import { z } from 'zod/v4';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Aspect ratios supported by the MiniMax
|
|
5
|
+
* Aspect ratios supported by the MiniMax video models.
|
|
6
6
|
*/
|
|
7
7
|
export const minimaxVideoRatios = [
|
|
8
8
|
'adaptive',
|
|
@@ -15,9 +15,10 @@ export const minimaxVideoRatios = [
|
|
|
15
15
|
] as const;
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* Output resolutions supported by
|
|
18
|
+
* Output resolutions supported by MiniMax video models. Availability depends
|
|
19
|
+
* on the selected model.
|
|
19
20
|
*/
|
|
20
|
-
export const minimaxVideoResolutions = ['2K'] as const;
|
|
21
|
+
export const minimaxVideoResolutions = ['480P', '768P', '2K'] as const;
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Provider options for MiniMax video generation.
|
|
@@ -42,9 +42,10 @@ type MiniMaxVideoDoGenerateOptions = Parameters<
|
|
|
42
42
|
>[0];
|
|
43
43
|
|
|
44
44
|
const DEFAULT_RESOLUTION = '2K';
|
|
45
|
+
const DEFAULT_ASPECT_RATIO = '16:9';
|
|
45
46
|
const DEFAULT_POLL_INTERVAL_MS = 10_000;
|
|
46
47
|
const DEFAULT_POLL_TIMEOUT_MS = 600_000;
|
|
47
|
-
const
|
|
48
|
+
const DEFAULT_DURATION_SECONDS = 5;
|
|
48
49
|
const MAX_DURATION_SECONDS = 15;
|
|
49
50
|
const MAX_REFERENCE_IMAGES = 9;
|
|
50
51
|
const MAX_REFERENCE_VIDEOS = 3;
|
|
@@ -52,28 +53,47 @@ const MAX_REFERENCE_AUDIOS = 3;
|
|
|
52
53
|
|
|
53
54
|
const allowedRatios = new Set<string>(minimaxVideoRatios);
|
|
54
55
|
const allowedResolutions = new Set<string>(minimaxVideoResolutions);
|
|
56
|
+
const modelResolutionSettings: Record<
|
|
57
|
+
string,
|
|
58
|
+
{ supported: readonly string[]; default: string }
|
|
59
|
+
> = {
|
|
60
|
+
'MiniMax-H3': { supported: ['768P', '2K'], default: DEFAULT_RESOLUTION },
|
|
61
|
+
'MiniMax-H3-Max': { supported: ['480P', '768P'], default: '768P' },
|
|
62
|
+
};
|
|
55
63
|
|
|
56
64
|
// The top-level `resolution` is `{width}x{height}`, but the API takes a named
|
|
57
|
-
// tier, so map
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
//
|
|
65
|
+
// tier, so map canonical frame sizes onto the tiers. One frame size per ratio
|
|
66
|
+
// per tier, so a caller who pairs a resolution with any supported ratio
|
|
67
|
+
// resolves to the tier instead of being told the resolution is unsupported.
|
|
68
|
+
// MiniMax does not publish tier dimensions, so this is a closed table rather
|
|
69
|
+
// than a rule: 480P and 768P rows are named for the shorter side, the 2K rows
|
|
70
|
+
// for the longer one. A frame size not listed here warns.
|
|
62
71
|
const RESOLUTION_MAP: Record<string, string> = {
|
|
63
|
-
//
|
|
72
|
+
// 480P — square, landscape, portrait
|
|
73
|
+
'480x480': '480P',
|
|
74
|
+
'1120x480': '480P',
|
|
75
|
+
'854x480': '480P',
|
|
76
|
+
'640x480': '480P',
|
|
77
|
+
'480x854': '480P',
|
|
78
|
+
'480x640': '480P',
|
|
79
|
+
// 768P — square, landscape, portrait
|
|
80
|
+
'768x768': '768P',
|
|
81
|
+
'1792x768': '768P',
|
|
82
|
+
'1366x768': '768P',
|
|
83
|
+
'1024x768': '768P',
|
|
84
|
+
'768x1366': '768P',
|
|
85
|
+
'768x1024': '768P',
|
|
86
|
+
// 2K — square, landscape, portrait
|
|
64
87
|
'2048x2048': '2K',
|
|
65
|
-
// Landscape
|
|
66
88
|
'2560x1080': '2K',
|
|
67
89
|
'2560x1440': '2K',
|
|
68
90
|
'2048x1536': '2K',
|
|
69
|
-
// Portrait
|
|
70
91
|
'1440x2560': '2K',
|
|
71
92
|
'1536x2048': '2K',
|
|
72
93
|
};
|
|
73
94
|
|
|
74
|
-
// A caller may pass
|
|
75
|
-
//
|
|
76
|
-
// case-insensitively instead of reporting it as unrecognized.
|
|
95
|
+
// A caller may pass a named tier itself rather than a frame size. Normalize it
|
|
96
|
+
// case-insensitively to the exact casing expected by the MiniMax API.
|
|
77
97
|
function resolveTopLevelResolution(resolution: string): string | undefined {
|
|
78
98
|
const named = resolution.toUpperCase();
|
|
79
99
|
return allowedResolutions.has(named) ? named : RESOLUTION_MAP[resolution];
|
|
@@ -130,7 +150,7 @@ export class MiniMaxVideoModel implements Experimental_VideoModelV3 {
|
|
|
130
150
|
warnings.push({
|
|
131
151
|
type: 'unsupported',
|
|
132
152
|
feature: 'fps',
|
|
133
|
-
details:
|
|
153
|
+
details: `${this.modelId} does not support a custom frame rate.`,
|
|
134
154
|
});
|
|
135
155
|
}
|
|
136
156
|
|
|
@@ -138,7 +158,7 @@ export class MiniMaxVideoModel implements Experimental_VideoModelV3 {
|
|
|
138
158
|
warnings.push({
|
|
139
159
|
type: 'unsupported',
|
|
140
160
|
feature: 'seed',
|
|
141
|
-
details:
|
|
161
|
+
details: `${this.modelId} does not support a seed.`,
|
|
142
162
|
});
|
|
143
163
|
}
|
|
144
164
|
|
|
@@ -146,8 +166,7 @@ export class MiniMaxVideoModel implements Experimental_VideoModelV3 {
|
|
|
146
166
|
warnings.push({
|
|
147
167
|
type: 'unsupported',
|
|
148
168
|
feature: 'n',
|
|
149
|
-
details:
|
|
150
|
-
'MiniMax-H3 generates a single video per call. Only 1 video will be generated.',
|
|
169
|
+
details: `${this.modelId} generates a single video per call. Only 1 video will be generated.`,
|
|
151
170
|
});
|
|
152
171
|
}
|
|
153
172
|
|
|
@@ -155,41 +174,67 @@ export class MiniMaxVideoModel implements Experimental_VideoModelV3 {
|
|
|
155
174
|
warnings.push({
|
|
156
175
|
type: 'unsupported',
|
|
157
176
|
feature: 'generateAudio',
|
|
158
|
-
details:
|
|
159
|
-
'The MiniMax-H3 API does not expose an audio parameter. The generateAudio option was ignored.',
|
|
177
|
+
details: `The ${this.modelId} API does not expose an audio parameter. The generateAudio option was ignored.`,
|
|
160
178
|
});
|
|
161
179
|
}
|
|
162
180
|
|
|
181
|
+
const resolutionSettings = modelResolutionSettings[this.modelId];
|
|
182
|
+
const supportedResolutions =
|
|
183
|
+
resolutionSettings?.supported ?? minimaxVideoResolutions;
|
|
184
|
+
const supportedResolutionSet = new Set<string>(supportedResolutions);
|
|
185
|
+
const supportedResolutionNames = supportedResolutions
|
|
186
|
+
.map(resolution => `"${resolution}"`)
|
|
187
|
+
.join(' or ');
|
|
188
|
+
|
|
163
189
|
// Resolution: the API takes a named tier, so an explicit provider option
|
|
164
190
|
// wins and a top-level value is resolved to a tier.
|
|
165
191
|
let resolution: string | undefined = minimaxOptions?.resolution;
|
|
192
|
+
if (resolution != null && !supportedResolutionSet.has(resolution)) {
|
|
193
|
+
warnings.push({
|
|
194
|
+
type: 'unsupported',
|
|
195
|
+
feature: 'resolution',
|
|
196
|
+
details: `${this.modelId} supports ${supportedResolutionNames}. The provider resolution "${resolution}" was ignored.`,
|
|
197
|
+
});
|
|
198
|
+
resolution = undefined;
|
|
199
|
+
}
|
|
200
|
+
|
|
166
201
|
if (options.resolution != null) {
|
|
167
202
|
const mapped = resolveTopLevelResolution(options.resolution);
|
|
168
203
|
if (resolution != null) {
|
|
169
|
-
// The provider option is already a tier, so
|
|
170
|
-
//
|
|
204
|
+
// The provider option is already a tier and wins, so say so whenever
|
|
205
|
+
// the top-level value is dropped — it either names no tier, or names a
|
|
206
|
+
// different one now that every tier has frame sizes.
|
|
171
207
|
if (mapped == null) {
|
|
172
208
|
warnings.push({
|
|
173
209
|
type: 'unsupported',
|
|
174
210
|
feature: 'resolution',
|
|
175
211
|
details:
|
|
176
|
-
`Unrecognized resolution "${options.resolution}".
|
|
212
|
+
`Unrecognized resolution "${options.resolution}". ${this.modelId} supports ${supportedResolutionNames}, ` +
|
|
177
213
|
`so providerOptions.minimax.resolution ("${resolution}") was used instead.`,
|
|
178
214
|
});
|
|
215
|
+
} else if (mapped !== resolution) {
|
|
216
|
+
warnings.push({
|
|
217
|
+
type: 'unsupported',
|
|
218
|
+
feature: 'resolution',
|
|
219
|
+
details:
|
|
220
|
+
`The resolution "${options.resolution}" selects ${mapped}, but ` +
|
|
221
|
+
`providerOptions.minimax.resolution ("${resolution}") was used instead.`,
|
|
222
|
+
});
|
|
179
223
|
}
|
|
180
|
-
} else if (mapped != null) {
|
|
224
|
+
} else if (mapped != null && supportedResolutionSet.has(mapped)) {
|
|
181
225
|
resolution = mapped;
|
|
182
226
|
} else {
|
|
183
227
|
warnings.push({
|
|
184
228
|
type: 'unsupported',
|
|
185
229
|
feature: 'resolution',
|
|
186
230
|
details:
|
|
187
|
-
|
|
188
|
-
|
|
231
|
+
mapped == null
|
|
232
|
+
? `Unrecognized resolution "${options.resolution}". ${this.modelId} supports ${supportedResolutionNames}.`
|
|
233
|
+
: `${this.modelId} does not support the resolution "${mapped}". It supports ${supportedResolutionNames}.`,
|
|
189
234
|
});
|
|
190
235
|
}
|
|
191
236
|
}
|
|
192
|
-
resolution ??= DEFAULT_RESOLUTION;
|
|
237
|
+
resolution ??= resolutionSettings?.default ?? DEFAULT_RESOLUTION;
|
|
193
238
|
|
|
194
239
|
// `convertImageModelFileToDataUri` passes `url` files through unchanged and
|
|
195
240
|
// encodes inline data as a data URI. MiniMax `mm_file://…` handles survive
|
|
@@ -231,8 +276,8 @@ export class MiniMaxVideoModel implements Experimental_VideoModelV3 {
|
|
|
231
276
|
feature: firstFrameImage != null ? 'frameImages' : 'image',
|
|
232
277
|
details:
|
|
233
278
|
firstFrameMediaType === 'video'
|
|
234
|
-
?
|
|
235
|
-
:
|
|
279
|
+
? `${this.modelId} does not accept a video as a frame image. The video was ignored.`
|
|
280
|
+
: `${this.modelId} only accepts an image as a frame image; the "${firstFrame.mediaType}" file was ignored.`,
|
|
236
281
|
});
|
|
237
282
|
firstFrame = undefined;
|
|
238
283
|
}
|
|
@@ -242,8 +287,7 @@ export class MiniMaxVideoModel implements Experimental_VideoModelV3 {
|
|
|
242
287
|
warnings.push({
|
|
243
288
|
type: 'unsupported',
|
|
244
289
|
feature: 'frameImages',
|
|
245
|
-
details:
|
|
246
|
-
'MiniMax-H3 requires a first_frame when a last_frame is provided. The last_frame was ignored.',
|
|
290
|
+
details: `${this.modelId} requires a first_frame when a last_frame is provided. The last_frame was ignored.`,
|
|
247
291
|
});
|
|
248
292
|
lastFrame = undefined;
|
|
249
293
|
} else {
|
|
@@ -254,8 +298,8 @@ export class MiniMaxVideoModel implements Experimental_VideoModelV3 {
|
|
|
254
298
|
feature: 'frameImages',
|
|
255
299
|
details:
|
|
256
300
|
lastFrameMediaType === 'video'
|
|
257
|
-
?
|
|
258
|
-
:
|
|
301
|
+
? `${this.modelId} does not accept a video as a frame image. The last_frame video was ignored.`
|
|
302
|
+
: `${this.modelId} only accepts an image as a frame image; the "${lastFrame.mediaType}" last_frame was ignored.`,
|
|
259
303
|
});
|
|
260
304
|
lastFrame = undefined;
|
|
261
305
|
}
|
|
@@ -266,8 +310,29 @@ export class MiniMaxVideoModel implements Experimental_VideoModelV3 {
|
|
|
266
310
|
|
|
267
311
|
const referenceFiles = options.inputReferences ?? [];
|
|
268
312
|
const referenceAudioUrls = minimaxOptions?.referenceAudioUrls ?? [];
|
|
313
|
+
const supportsReferences = this.modelId !== 'MiniMax-H3-Max';
|
|
314
|
+
|
|
315
|
+
if (!supportsReferences && referenceFiles.length > 0) {
|
|
316
|
+
warnings.push({
|
|
317
|
+
type: 'unsupported',
|
|
318
|
+
feature: 'inputReferences',
|
|
319
|
+
details:
|
|
320
|
+
'MiniMax-H3-Max does not support reference-to-video inputs. The references were ignored.',
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (!supportsReferences && referenceAudioUrls.length > 0) {
|
|
325
|
+
warnings.push({
|
|
326
|
+
type: 'unsupported',
|
|
327
|
+
feature: 'referenceAudioUrls',
|
|
328
|
+
details:
|
|
329
|
+
'MiniMax-H3-Max does not support reference audio. The audio was ignored.',
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
|
|
269
333
|
const usesReferences =
|
|
270
|
-
|
|
334
|
+
supportsReferences &&
|
|
335
|
+
(referenceFiles.length > 0 || referenceAudioUrls.length > 0);
|
|
271
336
|
|
|
272
337
|
if (usesFrameImages) {
|
|
273
338
|
if (firstFrame != null) {
|
|
@@ -401,6 +466,7 @@ export class MiniMaxVideoModel implements Experimental_VideoModelV3 {
|
|
|
401
466
|
|
|
402
467
|
// Aspect ratio. In frame-image mode the ratio follows the supplied image,
|
|
403
468
|
// so an explicit ratio is ignored.
|
|
469
|
+
const isTextToVideo = content.length === 1;
|
|
404
470
|
let ratio = minimaxOptions?.ratio as string | undefined;
|
|
405
471
|
if (ratio == null && options.aspectRatio != null) {
|
|
406
472
|
if (allowedRatios.has(options.aspectRatio)) {
|
|
@@ -409,32 +475,49 @@ export class MiniMaxVideoModel implements Experimental_VideoModelV3 {
|
|
|
409
475
|
warnings.push({
|
|
410
476
|
type: 'unsupported',
|
|
411
477
|
feature: 'aspectRatio',
|
|
412
|
-
details:
|
|
413
|
-
`MiniMax-H3 does not support the aspect ratio "${options.aspectRatio}".
|
|
414
|
-
|
|
478
|
+
details: isTextToVideo
|
|
479
|
+
? `MiniMax-H3 does not support the aspect ratio "${options.aspectRatio}". Using the default (${DEFAULT_ASPECT_RATIO}).`
|
|
480
|
+
: `MiniMax-H3 does not support the aspect ratio "${options.aspectRatio}". Using the provider default (adaptive).`,
|
|
415
481
|
});
|
|
482
|
+
if (isTextToVideo) {
|
|
483
|
+
ratio = DEFAULT_ASPECT_RATIO;
|
|
484
|
+
}
|
|
416
485
|
}
|
|
417
486
|
}
|
|
418
|
-
if (
|
|
487
|
+
if (ratio === 'adaptive' && isTextToVideo) {
|
|
419
488
|
warnings.push({
|
|
420
489
|
type: 'unsupported',
|
|
421
490
|
feature: 'aspectRatio',
|
|
422
491
|
details:
|
|
423
|
-
'MiniMax-H3
|
|
492
|
+
'MiniMax-H3 text-to-video does not support the adaptive aspect ratio. ' +
|
|
493
|
+
`Using the default (${DEFAULT_ASPECT_RATIO}).`,
|
|
494
|
+
});
|
|
495
|
+
ratio = DEFAULT_ASPECT_RATIO;
|
|
496
|
+
}
|
|
497
|
+
if (usesFrameImages && ratio != null) {
|
|
498
|
+
warnings.push({
|
|
499
|
+
type: 'unsupported',
|
|
500
|
+
feature: 'aspectRatio',
|
|
501
|
+
details: `${this.modelId} derives the aspect ratio from the frame image; the requested ratio was ignored.`,
|
|
424
502
|
});
|
|
425
503
|
ratio = undefined;
|
|
426
504
|
}
|
|
505
|
+
if (ratio == null && isTextToVideo) {
|
|
506
|
+
ratio = DEFAULT_ASPECT_RATIO;
|
|
507
|
+
}
|
|
427
508
|
|
|
428
|
-
// H3
|
|
429
|
-
//
|
|
430
|
-
|
|
509
|
+
// Both H3 models take an integer duration, but H3 starts at 4 seconds while
|
|
510
|
+
// H3-Max starts at 5. Round before clamping because the API rejects both
|
|
511
|
+
// fractional and out-of-range values.
|
|
512
|
+
const minDurationSeconds = this.modelId === 'MiniMax-H3' ? 4 : 5;
|
|
513
|
+
let duration = options.duration ?? DEFAULT_DURATION_SECONDS;
|
|
431
514
|
if (options.duration != null) {
|
|
432
515
|
if (!Number.isInteger(duration)) {
|
|
433
516
|
duration = Math.round(duration);
|
|
434
517
|
warnings.push({
|
|
435
518
|
type: 'unsupported',
|
|
436
519
|
feature: 'duration',
|
|
437
|
-
details:
|
|
520
|
+
details: `${this.modelId} requires a whole number of seconds. The requested duration of ${options.duration} was rounded to ${duration}.`,
|
|
438
521
|
});
|
|
439
522
|
}
|
|
440
523
|
|
|
@@ -442,16 +525,16 @@ export class MiniMaxVideoModel implements Experimental_VideoModelV3 {
|
|
|
442
525
|
warnings.push({
|
|
443
526
|
type: 'unsupported',
|
|
444
527
|
feature: 'duration',
|
|
445
|
-
details:
|
|
528
|
+
details: `${this.modelId} supports at most ${MAX_DURATION_SECONDS} seconds. The requested duration of ${options.duration} was clamped to ${MAX_DURATION_SECONDS}.`,
|
|
446
529
|
});
|
|
447
530
|
duration = MAX_DURATION_SECONDS;
|
|
448
|
-
} else if (duration <
|
|
531
|
+
} else if (duration < minDurationSeconds) {
|
|
449
532
|
warnings.push({
|
|
450
533
|
type: 'unsupported',
|
|
451
534
|
feature: 'duration',
|
|
452
|
-
details:
|
|
535
|
+
details: `${this.modelId} requires at least ${minDurationSeconds} seconds. The requested duration of ${options.duration} was clamped to ${minDurationSeconds}.`,
|
|
453
536
|
});
|
|
454
|
-
duration =
|
|
537
|
+
duration = minDurationSeconds;
|
|
455
538
|
}
|
|
456
539
|
}
|
|
457
540
|
|