Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/video/v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const VIDEO_V2_IMAGE_ROLES = new Set<VideoV2ImageRole>([
'reference_image',
]);

const VIDEO_V2_MAX_REFERENCE_INPUTS = 12;

export class VideoV2InputError extends Error {
constructor(message: string) {
super(message);
Expand Down Expand Up @@ -187,6 +189,11 @@ export function validateVideoV2Request(request: VideoV2Request): void {
if (referenceImages.length > 9 || videos.length > 3 || audios.length > 3) {
throw new VideoV2InputError('MiniMax-H3 accepts up to 9 reference images, 3 reference videos, and 3 reference audios.');
}
if (referenceImages.length + videos.length + audios.length > VIDEO_V2_MAX_REFERENCE_INPUTS) {
throw new VideoV2InputError(
`MiniMax-H3 accepts up to ${VIDEO_V2_MAX_REFERENCE_INPUTS} reference images, videos, and audios in total.`,
);
}
if (hasFrameInput && hasReferenceInput) {
throw new VideoV2InputError('MiniMax-H3 frame inputs and reference inputs cannot be used together.');
}
Expand Down
15 changes: 15 additions & 0 deletions test/video/v2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,21 @@ describe('Video Generation V2 request builder', () => {
})).toThrow('3 reference audios');
});

it('enforces the combined reference input limit', () => {
expect(() => buildVideoV2Request({
prompt,
images: referenceImages(9),
referenceVideos: referenceMedia(3, 'mp4'),
})).not.toThrow();

expect(() => buildVideoV2Request({
prompt,
images: referenceImages(9),
referenceVideos: referenceMedia(3, 'mp4'),
referenceAudios: referenceMedia(1, 'mp3'),
})).toThrow('up to 12 reference images, videos, and audios in total');
});

it('rejects oversized Base64 image, video, and audio inputs', () => {
expect(() => buildVideoV2Request({
prompt,
Expand Down
Loading