MiniMax H3
import { experimental_generateVideo as generateVideo } from 'ai';
const result = await generateVideo({ model: 'minimax/minimax-h3', prompt: 'A serene mountain lake at sunrise.'});Getting started
Generate videos with MiniMax H3 using the experimental_generateVideo function from AI SDK 6 or later. AI Gateway handles routing and polls until the video is ready.
Install the AI SDK (pnpm add ai dotenv), create an API key from the API Keys page, and set it as AI_GATEWAY_API_KEY in your environment. Full setup is covered in the video generation quickstart.
import { experimental_generateVideo as generateVideo } from 'ai';import fs from 'node:fs';import 'dotenv/config';
async function main() { const result = await generateVideo({ model: 'minimax/minimax-h3', prompt: 'A white kitten chases a butterfly across a sunlit garden.', });
// Save the generated video fs.writeFileSync('output.mp4', result.videos[0].uint8Array);
console.log('Video saved to output.mp4');}
main().catch(console.error);Top-level parameters
Load the supported top-level parameters: prompt, duration, aspectRatio, and resolution. 2K is the only resolution H3 renders, and the named tier is accepted in place of the {width}x{height} form.
import { experimental_generateVideo as generateVideo } from 'ai';import fs from 'node:fs';import 'dotenv/config';
async function main() { const result = await generateVideo({ model: 'minimax/minimax-h3', prompt: 'A white kitten chases a butterfly across a sunlit garden.', duration: 5, aspectRatio: '16:9', resolution: '2048x2048', });
// Save the generated video fs.writeFileSync('output.mp4', result.videos[0].uint8Array);
console.log('Video saved to output.mp4');}
main().catch(console.error);| Parameter | Type | Required | Description |
|---|---|---|---|
prompt | string | No | Text description of the video to generate. |
duration | number | No | Video length in seconds. 5-15 seconds. |
resolution | string | No | Resolution ('2048x2048'). |
aspectRatio | string | No | Aspect ratio ('21:9', '16:9', '4:3', '1:1', '3:4', '9:16'). |
prompt.image | string | No | URL of an image to animate as the first frame. Equivalent to a single frameImages entry with frameType: "first_frame". |
frameImages | Array<{ image: string; frameType: 'first_frame' | 'last_frame' }> | No | First and last frames of the clip. A last_frame without a first_frame is dropped with a warning, and only images are accepted. |
inputReferences | Array<string | { data: string; mediaType: string }> | No | Reference images and videos to keep a subject or follow motion. Up to 9 images and 3 videos. Pass videos as { data, mediaType: "video/mp4" } — a URL without a media type is treated as an image. |
Input limits
| Input | Formats | Sources | Max count | Max size | Limits |
|---|---|---|---|---|---|
| Image | jpg, jpeg, png, webp, heic, heif | url | 9 | 30 MB | ≥256px · ≤5760px · aspect 2:5–5:2 |
| Video | h264, h265, mp4 | url | 3 | 50 MB | 2-15s · ≥256px · ≤5760px |
| Audio | wav, mp3 | url | — | 15 MB | 2-15s |
Provider options
Pass MiniMax options under providerOptions.minimax. ratio overrides the top-level aspectRatio and is the only way to request adaptive.
Learn more in the AI SDK MiniMax video docs.
import { experimental_generateVideo as generateVideo } from 'ai';import fs from 'node:fs';import 'dotenv/config';
async function main() { const result = await generateVideo({ model: 'minimax/minimax-h3', prompt: 'A white kitten chases a butterfly across a sunlit garden.', duration: 5, providerOptions: { minimax: { ratio: '16:9', resolution: '2K', aigcWatermark: false, pollIntervalMs: 10000, pollTimeoutMs: 600000, }, }, });
// Save the generated video fs.writeFileSync('output.mp4', result.videos[0].uint8Array);
console.log('Video saved to output.mp4');}
main().catch(console.error);Pass MiniMax-specific options under providerOptions.minimax in your generateVideo call.
| Parameter | Type | Required | Description |
|---|---|---|---|
ratio | 'adaptive' | '21:9' | '16:9' | '4:3' | '1:1' | '3:4' | '9:16' | No | Aspect ratio of the generated video. Overrides the top-level aspectRatio, and unlike it can be set to adaptive. |
resolution | '2K' | No | Output resolution. H3 currently only supports 2K, which is also the default. |
referenceAudioUrls | string[] | No | Up to 3 reference audio URLs for reference-to-video. Must be paired with at least one reference image or video, or the audio is dropped with a warning. The only input that accepts mm_file:// handles — pass images and videos as public URLs, data URIs, or binary data. |
aigcWatermark | boolean | No | Whether to embed an AIGC watermark in the output. Defaults to false. |
pollIntervalMs | number | No | How often to check task status. Defaults to 10000. |
pollTimeoutMs | number | No | Maximum wait time. Defaults to 600000 (10 minutes). |
First and last frame
Control the transition by opening on one image and closing on another. The aspect ratio follows the input images, so an explicit aspectRatio is ignored.
import { experimental_generateVideo as generateVideo } from 'ai';import fs from 'node:fs';import 'dotenv/config';
async function main() { const result = await generateVideo({ model: 'minimax/minimax-h3', prompt: 'The kitten crosses the garden and settles under the bench.', duration: 5, frameImages: [ { image: 'https://example.com/start.jpg', frameType: 'first_frame' }, { image: 'https://example.com/end.jpg', frameType: 'last_frame' }, ], });
// Save the generated video fs.writeFileSync('output.mp4', result.videos[0].uint8Array);
console.log('Video saved to output.mp4');}
main().catch(console.error);Reference to video
Keep a subject or follow motion from reference media, and optionally drive it with reference audio. Videos need an explicit media type; audio goes in providerOptions.minimax.referenceAudioUrls and has to accompany at least one image or video.
import { experimental_generateVideo as generateVideo } from 'ai';import fs from 'node:fs';import 'dotenv/config';
async function main() { const result = await generateVideo({ model: 'minimax/minimax-h3', prompt: 'The same kitten, now padding along a rainy city street at night.', duration: 5, inputReferences: [ 'https://example.com/kitten.jpg', { data: 'https://example.com/motion.mp4', mediaType: 'video/mp4' }, ], providerOptions: { minimax: { ratio: 'adaptive', referenceAudioUrls: ['https://example.com/voice.wav'], }, }, });
// Save the generated video fs.writeFileSync('output.mp4', result.videos[0].uint8Array);
console.log('Video saved to output.mp4');}
main().catch(console.error);