Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat(video): add MiniMax-H3 with official v2 API support (#17827)

Yichenfad36790ebb2
diff --git a/locales/en-US/models.json b/locales/en-US/models.json
index bc975f5fcc6..22ec74989ff 100644
--- a/locales/en-US/models.json
+++ b/locales/en-US/models.json
@@ -100,6 +100,7 @@
"Meta-Llama-3.3-70B-Instruct.description": "Llama 3.3 is the most advanced multilingual open-source Llama model, delivering near-405B performance at very low cost. It is Transformer-based and improved with SFT and RLHF for usefulness and safety. The instruction-tuned version is optimized for multilingual chat and beats many open and closed chat models on industry benchmarks. Knowledge cutoff: Dec 2023.",
"Meta-Llama-4-Maverick-17B-128E-Instruct-FP8.description": "Llama 4 Maverick is a large MoE model with efficient expert activation for strong reasoning performance.",
"MiMo-V2-Pro.description": "MiMo-V2-Pro is specifically designed for high-intensity agent workflows in real-world scenarios. It features over 1 trillion total parameters (42B activated parameters), adopts an innovative hybrid attention architecture, and supports an ultra-long context length of up to 1 million tokens. Built on a powerful foundational model, we continuously scale computational resources across a broader range of agent scenarios, further expanding the action space of intelligence and achieving significant generalization—from coding to real-world task execution (“claw”).",
+ "MiniMax-H3.description": "A unified text-to-video, image-to-video, and reference-to-video model with enhanced motion, consistency, and native audio capabilities.",
"MiniMax-Hailuo-02.description": "The next-generation video generation model, MiniMax Hailuo 02, has been officially released, supporting 1080P resolution and 10-second video generation.",
"MiniMax-Hailuo-2.3-Fast.description": "Brand-new video generation model with comprehensive upgrades in body motion, physical realism, and instruction following.",
"MiniMax-Hailuo-2.3.description": "Brand-new video generation model with comprehensive upgrades in body motion, physical realism, and instruction following.",
diff --git a/locales/zh-CN/models.json b/locales/zh-CN/models.json
index 71bb44f6cd3..f2afe8062ea 100644
--- a/locales/zh-CN/models.json
+++ b/locales/zh-CN/models.json
@@ -100,6 +100,7 @@
"Meta-Llama-3.3-70B-Instruct.description": "Llama 3.3 是最先进的多语言开源 Llama 模型,在极低成本下实现接近 405B 的性能。基于 Transformer 架构,并通过 SFT 和 RLHF 提升实用性与安全性。指令微调版本专为多语言对话优化,在行业基准测试中超越众多开放与闭源聊天模型。知识截止时间:2023 年 12 月。",
"Meta-Llama-4-Maverick-17B-128E-Instruct-FP8.description": "Llama 4 Maverick 是一款大型 MoE 模型,采用高效专家激活机制,具备强大的推理能力。",
"MiMo-V2-Pro.description": "MiMo-V2-Pro 专为真实世界中的高强度智能体工作流设计。其总参数量超过 1 万亿(激活参数 42B),采用创新的混合注意力架构,支持超长上下文长度(最高 100 万 tokens)。基于强大的基础模型,我们持续在更广泛的智能体场景中扩展算力,进一步拓展智能的行动空间,在从编码到真实任务执行(“钳爪”)等方面实现显著泛化。",
+ "MiniMax-H3.description": "统一的文生视频、图生视频与参考生视频模型,运动表现、一致性和原生音频能力全面增强。",
"MiniMax-Hailuo-02.description": "下一代视频生成模型MiniMax Hailuo 02正式发布,支持1080P分辨率和10秒视频生成。",
"MiniMax-Hailuo-2.3-Fast.description": "全新视频生成模型,在身体动作、物理真实感和指令遵循性方面全面升级。",
"MiniMax-Hailuo-2.3.description": "全新视频生成模型,在身体动作、物理真实感和指令遵循性方面全面升级。",
diff --git a/packages/model-bank/src/aiModels/__tests__/index.test.ts b/packages/model-bank/src/aiModels/__tests__/index.test.ts
index c4fce02dcd1..dd229f0dce3 100644
--- a/packages/model-bank/src/aiModels/__tests__/index.test.ts
+++ b/packages/model-bank/src/aiModels/__tests__/index.test.ts
@@ -148,6 +148,50 @@ describe('Hunyuan models', () => {
});
});
+describe('MiniMax video models', () => {
+ it('registers MiniMax-H3 with the official v2 parameter limits', () => {
+ const h3 = LOBE_DEFAULT_MODEL_LIST.find(
+ (model) => model.providerId === ModelProvider.Minimax && model.id === 'MiniMax-H3',
+ );
+
+ expect(h3).toEqual(
+ expect.objectContaining({
+ enabled: true,
+ parameters: expect.objectContaining({
+ aspectRatio: expect.objectContaining({ default: '16:9' }),
+ duration: expect.objectContaining({ max: 15, min: 4 }),
+ imageUrls: expect.objectContaining({ maxCount: 7 }),
+ resolution: expect.objectContaining({ default: '768P', enum: ['768P', '2K'] }),
+ }),
+ releasedAt: '2026-07-31',
+ type: 'video',
+ }),
+ );
+ });
+
+ it('keeps the combined MiniMax-H3 reference capacity within the v2 limit of 9', () => {
+ const h3 = LOBE_DEFAULT_MODEL_LIST.find(
+ (model) => model.providerId === ModelProvider.Minimax && model.id === 'MiniMax-H3',
+ );
+
+ const parameters = (h3?.parameters ?? {}) as {
+ endImageUrl?: unknown;
+ imageUrl?: unknown;
+ imageUrls?: { maxCount?: number };
+ };
+
+ // The first-frame (imageUrl), reference-list (imageUrls), and last-frame
+ // (endImageUrl) slots all normalize into a single reference pool that the
+ // runtime caps at 9. The combined upload capacity must stay within that
+ // limit so the UI can never assemble a payload createVideo would reject.
+ const firstFrameSlots = parameters.imageUrl === undefined ? 0 : 1;
+ const lastFrameSlots = parameters.endImageUrl === undefined ? 0 : 1;
+ const referenceSlots = parameters.imageUrls?.maxCount ?? 0;
+
+ expect(firstFrameSlots + referenceSlots + lastFrameSlots).toBeLessThanOrEqual(9);
+ });
+});
+
describe('Google rolling model aliases', () => {
it('tracks the current Flash and Flash-Lite model versions', () => {
const googleModels = LOBE_DEFAULT_MODEL_LIST.filter((model) => model.providerId === 'google');
diff --git a/packages/model-bank/src/aiModels/minimax.ts b/packages/model-bank/src/aiModels/minimax.ts
index 9afcb83bf59..eea6781437d 100644
--- a/packages/model-bank/src/aiModels/minimax.ts
+++ b/packages/model-bank/src/aiModels/minimax.ts
@@ -377,6 +377,44 @@ const minimaxImageModels: AIImageModelCard[] = [
];
const minimaxVideoModels: AIVideoModelCard[] = [
+ {
+ description:
+ 'A unified text-to-video, image-to-video, and reference-to-video model with enhanced motion, consistency, and native audio capabilities.',
+ displayName: 'MiniMax H3',
+ enabled: true,
+ id: 'MiniMax-H3',
+ parameters: {
+ aspectRatio: {
+ default: '16:9',
+ enum: ['21:9', '16:9', '4:3', '1:1', '3:4', '9:16'],
+ },
+ duration: { default: 6, max: 15, min: 4, step: 1 },
+ endImageUrl: {
+ default: null,
+ },
+ imageUrl: {
+ default: null,
+ },
+ imageUrls: {
+ default: [],
+ // The v2 API accepts at most 9 images total across the first-frame
+ // (imageUrl), reference-list (imageUrls), and last-frame (endImageUrl)
+ // slots, which all normalize into a single reference pool at runtime.
+ // Cap the reference array at 7 so the combined upload capacity
+ // (1 + 7 + 1) never exceeds 9 — otherwise the UI could assemble a
+ // payload that createVideo rejects.
+ maxCount: 7,
+ },
+ prompt: { default: '' },
+ resolution: {
+ default: '768P',
+ enum: ['768P', '2K'],
+ },
+ watermark: { default: false },
+ },
+ releasedAt: '2026-07-31',
+ type: 'video',
+ },
{
description:
'Brand-new video generation model with comprehensive upgrades in body motion, physical realism, and instruction following.',
diff --git a/packages/model-runtime/src/providers/minimax/createVideo.test.ts b/packages/model-runtime/src/providers/minimax/createVideo.test.ts
index f8de37ef201..96d9dd076e9 100644
--- a/packages/model-runtime/src/providers/minimax/createVideo.test.ts
+++ b/packages/model-runtime/src/providers/minimax/createVideo.test.ts
@@ -6,6 +6,7 @@ import type { CreateVideoPayload } from '../../types/video';
import {
createMiniMaxVideo,
pollMiniMaxVideoStatus,
+ queryMiniMaxH3VideoStatus,
queryMiniMaxVideoStatus,
retrieveMiniMaxVideoFile,
} from './createVideo';
@@ -157,6 +158,142 @@ describe('createMiniMaxVideo', () => {
'Invalid response: missing task_id',
);
});
+
+ it('should create MiniMax-H3 video with the v2 content API', async () => {
+ global.fetch = vi.fn().mockResolvedValueOnce({
+ ok: true,
+ json: async () => ({ task_id: 'h3-task-123' }),
+ });
+
+ const payload: CreateVideoPayload = {
+ model: 'MiniMax-H3',
+ params: {
+ aspectRatio: '9:16',
+ duration: 12,
+ prompt: 'A cinematic city at night',
+ resolution: '2K',
+ watermark: true,
+ },
+ };
+
+ const result = await createMiniMaxVideo(payload, mockOptions);
+
+ expect(fetch).toHaveBeenCalledWith(
+ 'https://api.minimaxi.com/v2/video_generation',
+ expect.any(Object),
+ );
+ const body = JSON.parse((global.fetch as any).mock.calls[0][1].body);
+ expect(body).toEqual({
+ aigc_watermark: true,
+ content: [{ text: 'A cinematic city at night', type: 'text' }],
+ duration: 12,
+ model: 'MiniMax-H3',
+ ratio: '9:16',
+ resolution: '2K',
+ });
+ expect(result).toEqual({ inferenceId: 'MiniMax-H3::h3-task-123' });
+ });
+
+ it('should map MiniMax-H3 first and last frames and use adaptive ratio', async () => {
+ global.fetch = vi.fn().mockResolvedValueOnce({
+ ok: true,
+ json: async () => ({ task_id: 'h3-frames-task' }),
+ });
+
+ const payload: CreateVideoPayload = {
+ model: 'MiniMax-H3',
+ params: {
+ aspectRatio: '16:9',
+ endImageUrl: 'https://example.com/last.jpg',
+ imageUrl: 'https://example.com/first.jpg',
+ prompt: 'Smoothly transition between these frames',
+ },
+ };
+
+ await createMiniMaxVideo(payload, mockOptions);
+
+ const body = JSON.parse((global.fetch as any).mock.calls[0][1].body);
+ expect(body.ratio).toBe('adaptive');
+ expect(body.content).toEqual([
+ { text: 'Smoothly transition between these frames', type: 'text' },
+ {
+ image_url: { url: 'https://example.com/first.jpg' },
+ role: 'first_frame',
+ type: 'image_url',
+ },
+ {
+ image_url: { url: 'https://example.com/last.jpg' },
+ role: 'last_frame',
+ type: 'image_url',
+ },
+ ]);
+ });
+
+ it('should normalize all visible H3 inputs into reference images', async () => {
+ global.fetch = vi.fn().mockResolvedValueOnce({
+ ok: true,
+ json: async () => ({ task_id: 'h3-reference-task' }),
+ });
+
+ const payload: CreateVideoPayload = {
+ model: 'MiniMax-H3',
+ params: {
+ aspectRatio: '1:1',
+ endImageUrl: 'https://example.com/ignored-last.jpg',
+ imageUrl: 'https://example.com/ignored-first.jpg',
+ imageUrls: ['https://example.com/reference-1.jpg', 'https://example.com/reference-2.jpg'],
+ prompt: 'Keep the referenced characters consistent',
+ },
+ };
+
+ await createMiniMaxVideo(payload, mockOptions);
+
+ const body = JSON.parse((global.fetch as any).mock.calls[0][1].body);
+ expect(body.ratio).toBe('1:1');
+ expect(body.content).toEqual([
+ { text: 'Keep the referenced characters consistent', type: 'text' },
+ {
+ image_url: { url: 'https://example.com/ignored-first.jpg' },
+ role: 'reference_image',
+ type: 'image_url',
+ },
+ {
+ image_url: { url: 'https://example.com/reference-1.jpg' },
+ role: 'reference_image',
+ type: 'image_url',
+ },
+ {
+ image_url: { url: 'https://example.com/reference-2.jpg' },
+ role: 'reference_image',
+ type: 'image_url',
+ },
+ {
+ image_url: { url: 'https://example.com/ignored-last.jpg' },
+ role: 'reference_image',
+ type: 'image_url',
+ },
+ ]);
+ });
+
+ it('should reject more than nine normalized H3 reference images', async () => {
+ const payload: CreateVideoPayload = {
+ model: 'MiniMax-H3',
+ params: {
+ endImageUrl: 'https://example.com/last.jpg',
+ imageUrl: 'https://example.com/first.jpg',
+ imageUrls: Array.from(
+ { length: 8 },
+ (_, index) => `https://example.com/reference-${index}.jpg`,
+ ),
+ prompt: 'Keep every visible reference',
+ },
+ };
+
+ await expect(createMiniMaxVideo(payload, mockOptions)).rejects.toThrow(
+ 'MiniMax-H3 supports up to 9 reference images',
+ );
+ expect(fetch).not.toHaveBeenCalled();
+ });
});
describe('pollMiniMaxVideoStatus', () => {
@@ -241,6 +378,65 @@ describe('pollMiniMaxVideoStatus', () => {
error: 'Task succeeded but no file_id found',
});
});
+
+ it('should return MiniMax-H3 result directly from the v2 task response', async () => {
+ global.fetch = vi.fn().mockResolvedValueOnce({
+ ok: true,
+ json: async () => ({
+ task: {
+ content: { url: 'https://cdn.minimax.com/h3-video.mp4' },
+ id: 'h3-task-123',
+ model: 'MiniMax-H3',
+ status: 'succeeded',
+ },
+ }),
+ });
+
+ const result = await pollMiniMaxVideoStatus('MiniMax-H3::h3-task-123', options);
+
+ expect(fetch).toHaveBeenCalledWith(
+ 'https://api.minimaxi.com/v2/query/video_generation/h3-task-123',
+ expect.any(Object),
+ );
+ expect(result).toEqual({
+ status: 'success',
+ videoUrl: 'https://cdn.minimax.com/h3-video.mp4',
+ });
+ });
+
+ it.each(['queued', 'running'])(
+ 'should return pending for MiniMax-H3 %s tasks',
+ async (status) => {
+ global.fetch = vi.fn().mockResolvedValueOnce({
+ ok: true,
+ json: async () => ({
+ task: { id: 'h3-task-123', model: 'MiniMax-H3', status },
+ }),
+ });
+
+ const result = await pollMiniMaxVideoStatus('MiniMax-H3::h3-task-123', options);
+
+ expect(result).toEqual({ status: 'pending' });
+ },
+ );
+
+ it.each(['failed', 'expired'])('should return failed for MiniMax-H3 %s tasks', async (status) => {
+ global.fetch = vi.fn().mockResolvedValueOnce({
+ ok: true,
+ json: async () => ({
+ task: {
+ error: { message: 'Generation failed' },
+ id: 'h3-task-123',
+ model: 'MiniMax-H3',
+ status,
+ },
+ }),
+ });
+
+ const result = await pollMiniMaxVideoStatus('MiniMax-H3::h3-task-123', options);
+
+ expect(result).toEqual({ error: 'Generation failed', status: 'failed' });
+ });
});
describe('queryMiniMaxVideoStatus', () => {
@@ -269,6 +465,30 @@ describe('queryMiniMaxVideoStatus', () => {
});
});
+describe('queryMiniMaxH3VideoStatus', () => {
+ it('should query the v2 path with an encoded task id', async () => {
+ const mockResponse = {
+ task: { id: 'h3/task', model: 'MiniMax-H3', status: 'running' as const },
+ };
+
+ global.fetch = vi.fn().mockResolvedValueOnce({
+ ok: true,
+ json: async () => mockResponse,
+ });
+
+ const result = await queryMiniMaxH3VideoStatus('h3/task', {
+ apiKey: 'test-key',
+ baseURL: 'https://api.minimaxi.com/v1',
+ });
+
+ expect(fetch).toHaveBeenCalledWith(
+ 'https://api.minimaxi.com/v2/query/video_generation/h3%2Ftask',
+ expect.any(Object),
+ );
+ expect(result).toEqual(mockResponse);
+ });
+});
+
describe('retrieveMiniMaxVideoFile', () => {
it('should retrieve file download URL', async () => {
const mockResponse = {
diff --git a/packages/model-runtime/src/providers/minimax/createVideo.ts b/packages/model-runtime/src/providers/minimax/createVideo.ts
index beff6ef65f5..2e0e5389179 100644
--- a/packages/model-runtime/src/providers/minimax/createVideo.ts
+++ b/packages/model-runtime/src/providers/minimax/createVideo.ts
@@ -7,13 +7,26 @@ import { resolveMappedModelId } from '../../utils/modelIdMapping';
const log = createDebug('lobe-video:minimax');
interface MiniMaxVideoCreateResponse {
- base_resp: {
+ base_resp?: {
status_code: number;
status_msg: string;
};
task_id: string;
}
+interface MiniMaxH3VideoStatusResponse {
+ task?: {
+ content?: {
+ url?: string;
+ };
+ error?: { message?: string } | string;
+ id: string;
+ message?: string;
+ model: string;
+ status: 'queued' | 'running' | 'succeeded' | 'failed' | 'expired';
+ };
+}
+
interface MiniMaxVideoStatusResponse {
base_resp: {
status_code: number;
@@ -42,6 +55,33 @@ interface MiniMaxFileRetrieveResponse {
};
}
+const INFERENCE_ID_SEPARATOR = '::';
+const MINIMAX_H3_MODEL = 'MiniMax-H3';
+
+const isMiniMaxH3 = (model?: string) => model?.toLowerCase() === MINIMAX_H3_MODEL.toLowerCase();
+
+const buildInferenceId = (model: string, taskId: string) =>
+ `${model}${INFERENCE_ID_SEPARATOR}${taskId}`;
+
+const parseInferenceId = (inferenceId: string) => {
+ const separatorIndex = inferenceId.indexOf(INFERENCE_ID_SEPARATOR);
+ if (separatorIndex === -1) return { id: inferenceId, model: undefined };
+
+ return {
+ id: inferenceId.slice(separatorIndex + INFERENCE_ID_SEPARATOR.length),
+ model: inferenceId.slice(0, separatorIndex),
+ };
+};
+
+const resolveMiniMaxV2BaseURL = (baseURL?: string) => {
+ const normalizedBaseURL = (baseURL || 'https://api.minimaxi.com/v1').replace(/\/$/, '');
+
+ if (normalizedBaseURL.endsWith('/v2')) return normalizedBaseURL;
+ if (normalizedBaseURL.endsWith('/v1')) return `${normalizedBaseURL.slice(0, -3)}/v2`;
+
+ return `${normalizedBaseURL}/v2`;
+};
+
export async function queryMiniMaxVideoStatus(
taskId: string,
options: { apiKey: string; baseURL: string },
@@ -65,6 +105,27 @@ export async function queryMiniMaxVideoStatus(
return (await response.json()) as MiniMaxVideoStatusResponse;
}
+export async function queryMiniMaxH3VideoStatus(
+ taskId: string,
+ options: { apiKey: string; baseURL: string },
+): Promise<MiniMaxH3VideoStatusResponse> {
+ const statusUrl = `${resolveMiniMaxV2BaseURL(options.baseURL)}/query/video_generation/${encodeURIComponent(taskId)}`;
+
+ const response = await fetch(statusUrl, {
+ headers: {
+ Authorization: `Bearer ${options.apiKey}`,
+ },
+ method: 'GET',
+ });
+
+ if (!response.ok) {
+ const errorText = await response.text();
+ throw new Error(`MiniMax H3 status API error: ${response.status} ${errorText}`);
+ }
+
+ return (await response.json()) as MiniMaxH3VideoStatusResponse;
+}
+
export async function retrieveMiniMaxVideoFile(
fileId: string,
options: { apiKey: string; baseURL: string },
@@ -99,13 +160,41 @@ export async function retrieveMiniMaxVideoFile(
}
export async function pollMiniMaxVideoStatus(
- taskId: string,
+ inferenceId: string,
options: { apiKey: string; baseURL: string },
): Promise<
| { status: 'success'; videoUrl: string }
| { status: 'failed'; error: string }
| { status: 'pending' }
> {
+ const { id: taskId, model } = parseInferenceId(inferenceId);
+
+ if (isMiniMaxH3(model)) {
+ const response = await queryMiniMaxH3VideoStatus(taskId, options);
+ const task = response.task;
+
+ if (!task) return { error: 'Missing task in MiniMax H3 status response', status: 'failed' };
+
+ if (task.status === 'succeeded') {
+ if (!task.content?.url) {
+ return { error: 'Task succeeded but no video URL found', status: 'failed' };
+ }
+
+ return { status: 'success', videoUrl: task.content.url };
+ }
+
+ if (task.status === 'failed' || task.status === 'expired') {
+ const taskError =
+ typeof task.error === 'string' ? task.error : task.error?.message || task.message;
+ return {
+ error: taskError || `Video generation ${task.status}`,
+ status: 'failed',
+ };
+ }
+
+ return { status: 'pending' };
+ }
+
const response = await queryMiniMaxVideoStatus(taskId, options);
if (response.status === 'Success') {
@@ -138,10 +227,83 @@ export async function createMiniMaxVideo(
): Promise<CreateVideoResponse> {
const { model, params } = payload;
const requestModel = resolveMappedModelId(model, options);
- const { prompt, imageUrl, endImageUrl, duration, resolution } = params;
+ const { prompt, imageUrl, imageUrls, endImageUrl, aspectRatio, duration, resolution } = params;
const baseURL = options.baseURL || 'https://api.minimaxi.com/v1';
+ if (isMiniMaxH3(model) || isMiniMaxH3(requestModel)) {
+ const content: Record<string, unknown>[] = [{ text: prompt, type: 'text' }];
+ const hasReferenceImages = Boolean(imageUrls?.length);
+ const referenceImageUrls = hasReferenceImages
+ ? [imageUrl, ...(imageUrls ?? []), endImageUrl].filter(
+ (url): url is string => typeof url === 'string' && url.length > 0,
+ )
+ : [];
+
+ if (referenceImageUrls.length > 9) {
+ throw new Error('MiniMax-H3 supports up to 9 reference images');
+ }
+
+ if (hasReferenceImages) {
+ referenceImageUrls.forEach((url) =>
+ content.push({
+ image_url: { url },
+ role: 'reference_image',
+ type: 'image_url',
+ }),
+ );
+ } else if (imageUrl) {
+ content.push({
+ image_url: { url: imageUrl },
+ role: 'first_frame',
+ type: 'image_url',
+ });
+ }
+
+ if (!hasReferenceImages && endImageUrl) {
+ content.push({
+ image_url: { url: endImageUrl },
+ role: 'last_frame',
+ type: 'image_url',
+ });
+ }
+
+ const body: Record<string, unknown> = {
+ aigc_watermark: params.watermark ?? false,
+ content,
+ model: requestModel,
+ ratio: !hasReferenceImages && (imageUrl || endImageUrl) ? 'adaptive' : aspectRatio || '16:9',
+ ...(typeof duration === 'number' ? { duration } : {}),
+ ...(typeof resolution === 'string' ? { resolution } : {}),
+ };
+
+ log('Creating video with MiniMax H3 API - model: %s, params: %O', model, params);
+
+ const response = await fetch(`${resolveMiniMaxV2BaseURL(baseURL)}/video_generation`, {
+ body: JSON.stringify(body),
+ headers: {
+ 'Authorization': `Bearer ${options.apiKey}`,
+ 'Content-Type': 'application/json',
+ },
+ method: 'POST',
+ });
+
+ if (!response.ok) {
+ const errorText = await response.text();
+ throw new Error(`MiniMax H3 video API error: ${response.status} ${errorText}`);
+ }
+
+ const data = (await response.json()) as MiniMaxVideoCreateResponse;
+
+ if (data.base_resp && data.base_resp.status_code !== 0) {
+ throw new Error(`MiniMax H3 video API error: ${data.base_resp.status_msg}`);
+ }
+
+ if (!data.task_id) throw new Error('Invalid response: missing task_id');
+
+ return { inferenceId: buildInferenceId(MINIMAX_H3_MODEL, data.task_id) };
+ }
+
const body: Record<string, unknown> = {
model: requestModel,
prompt,
@@ -187,7 +349,7 @@ export async function createMiniMaxVideo(
const data = (await response.json()) as MiniMaxVideoCreateResponse;
- if (data.base_resp.status_code !== 0) {
+ if (data.base_resp && data.base_resp.status_code !== 0) {
throw new Error(`MiniMax video API error: ${data.base_resp.status_msg}`);
}
diff --git a/src/store/video/slices/generationConfig/action.test.ts b/src/store/video/slices/generationConfig/action.test.ts
index 540c3fb767b..c4c61aa7f45 100644
--- a/src/store/video/slices/generationConfig/action.test.ts
+++ b/src/store/video/slices/generationConfig/action.test.ts
@@ -23,6 +23,19 @@ const modelBSchema: VideoModelParamsSchema = {
duration: { default: 3, min: 1, max: 10 },
};
+const seedanceSchema: VideoModelParamsSchema = {
+ prompt: { default: '' },
+ imageUrls: { default: [], maxCount: 9 },
+ endImageUrl: { default: null },
+};
+
+const minimaxH3Schema: VideoModelParamsSchema = {
+ prompt: { default: '' },
+ imageUrl: { default: null },
+ imageUrls: { default: [], maxCount: 7 },
+ endImageUrl: { default: null },
+};
+
const testVideoModels: AIVideoModelCard[] = [
{
id: 'video-model-a',
@@ -38,18 +51,32 @@ const testVideoModels: AIVideoModelCard[] = [
parameters: modelBSchema,
releasedAt: '2025-01-02',
},
+ {
+ id: 'seedance-2-0',
+ displayName: 'Seedance 2.0',
+ type: 'video',
+ parameters: seedanceSchema,
+ releasedAt: '2026-01-01',
+ },
+ {
+ id: 'minimax-h3',
+ displayName: 'MiniMax H3',
+ type: 'video',
+ parameters: minimaxH3Schema,
+ releasedAt: '2026-07-31',
+ },
];
const mockProviders = [
{
id: 'provider-a',
name: 'Provider A',
- children: [testVideoModels[0]],
+ children: [testVideoModels[0], testVideoModels[2]],
},
{
id: 'provider-b',
name: 'Provider B',
- children: [testVideoModels[1]],
+ children: [testVideoModels[1], testVideoModels[3]],
},
];
@@ -106,6 +133,33 @@ describe('video generationConfig actions', () => {
});
expect(result.current.parameters?.duration).toBe(modelBDefaultValues.duration);
});
+
+ it('should clamp preserved reference images to the next model limit', () => {
+ const imageUrls = Array.from({ length: 9 }, (_, index) => `reference-${index}.png`);
+ useVideoStore.setState({
+ model: 'seedance-2-0',
+ parameters: {
+ endImageUrl: 'end-frame.png',
+ imageUrls,
+ prompt: 'preserve references',
+ } as RuntimeVideoGenParams,
+ parametersSchema: seedanceSchema,
+ provider: 'provider-a',
+ });
+
+ const { result } = renderHook(() => useVideoStore());
+
+ act(() => {
+ result.current.setModelAndProviderOnSelect('minimax-h3', 'provider-b');
+ });
+
+ expect(result.current.parameters).toEqual({
+ endImageUrl: 'end-frame.png',
+ imageUrl: null,
+ imageUrls: imageUrls.slice(0, 7),
+ prompt: 'preserve references',
+ });
+ });
});
describe('uploading image previews', () => {
diff --git a/src/store/video/slices/generationConfig/action.ts b/src/store/video/slices/generationConfig/action.ts
index 72192fb87a7..d94c239903f 100644
--- a/src/store/video/slices/generationConfig/action.ts
+++ b/src/store/video/slices/generationConfig/action.ts
@@ -56,7 +56,14 @@ function preserveVideoInputParams(
'endImageUrl',
]);
- return normalizeImageInputOnSchemaSwitch(previousParameters, nextSchema, result);
+ const normalized = normalizeImageInputOnSchemaSwitch(previousParameters, nextSchema, result);
+ const maxImageCount = nextSchema.imageUrls?.maxCount;
+
+ if (Array.isArray(normalized.imageUrls) && typeof maxImageCount === 'number') {
+ normalized.imageUrls = normalized.imageUrls.slice(0, maxImageCount);
+ }
+
+ return normalized;
}
type Setter = StoreSetter<VideoStore>;