- MiniMax H3 javascript api uses asynchronous video-generation tasks.
- Authentication requires a MiniMax API key in the Authorization header.
- Core flow: create a task, poll its status, retrieve the completed file, and save the download URL.
- Best practice: keep API keys server-side and retry temporary failures with backoff.
MiniMax H3 JavaScript API Overview
MiniMax H3 is a multimodal AI video model released in 2026. It accepts natural-language prompts and can work with images, video, and audio references depending on the selected workflow. The hosted API is designed for asynchronous generation rather than an immediate video response.
For a JavaScript application, the practical sequence is simple: send a request to create a video task, store the returned task_id, query the task until it reaches a terminal status, and retrieve the resulting file with its file_id. The official video generation guide and API reference should be checked whenever endpoint parameters change.
Create
Send the model, prompt, duration, resolution, and supported input settings. The response provides a task identifier.
Monitor
Poll the query endpoint at a measured interval. Treat Success and Fail as terminal states.
Retrieve
Use the returned file identifier with the file retrieval endpoint, then copy the result to permanent storage.
| API Stage | Required Value | Result |
|---|---|---|
| Authentication | Bearer API key | Authorized request |
| Creation | Model and prompt | task_id |
| Query | task_id | Processing status |
| Retrieval | file_id | Download URL |
Use the API from a backend, serverless function, or protected worker. Do not expose MINIMAX_API_KEY in browser JavaScript shipped to users.
JavaScript API Setup Steps
Before writing the request, prepare a server-side Node.js environment and store the key as an environment variable. The following workflow matches the asynchronous pattern documented by MiniMax in 2026.
Create an API Key
Open the MiniMax platform dashboard, create an API key, and save it in a protected secret store. For local development, use an environment variable such as MINIMAX_API_KEY.
Choose the Generation Settings
Select the H3 model, write a focused prompt, and choose an available duration and resolution. The reference data lists common examples such as 768P and six-second clips.
Create the Task
Send a POST request to https://api.minimax.io/v1/video_generation. Save the returned task_id; rendering continues after the request is accepted.
Poll and Retrieve
Query https://api.minimax.io/v1/query/video_generation?task_id=... until the task succeeds. Then call /files/retrieve with the returned file_id.
| Setting | Example | Guidance |
|---|---|---|
| Environment variable | MINIMAX_API_KEY | Keep it outside source files and client bundles |
| Model | MiniMax-H3 | Confirm the current model name in the API reference |
| Prompt | Cinematic scene with sound | Describe subject, action, camera, dialogue, and audio |
| Duration | 6 | Use a value supported by the selected H3 workflow |
| Resolution | 768P | Use 2K when the selected hosted feature supports it |
Setup Checklist:
- Create and securely store a MiniMax API key
- Confirm the current H3 endpoint and model name
- Prepare a prompt and supported reference assets
- Create a server-side polling handler
- Store completed files outside temporary API storage
Separate task creation, status polling, and file retrieval into independent functions. This makes retries safer and keeps each failure easy to diagnose.
Node.js MiniMax H3 API Example
The following JavaScript example uses the built-in fetch available in modern Node.js runtimes. It creates a task, polls every ten seconds, stops on success or failure, and retrieves the completed file.
const apiKey = process.env.MINIMAX_API_KEY;
const baseUrl = "https://api.minimax.io/v1";
if (!apiKey) throw new Error("MINIMAX_API_KEY is not configured");
const headers = {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json"
};
async function createVideo() {
const response = await fetch(`${baseUrl}/video_generation`, {
method: "POST",
headers,
body: JSON.stringify({
model: "MiniMax-H3",
prompt:
"A cinematic product reveal on black glass, soft violet lighting, slow camera movement, subtle mechanical sound.",
duration: 6,
resolution: "768P"
})
});
if (!response.ok) {
throw new Error(`Create failed with HTTP ${response.status}`);
}
const data = await response.json();
return data.task_id;
}
async function queryVideo(taskId) {
const response = await fetch(
`${baseUrl}/query/video_generation?task_id=${encodeURIComponent(taskId)}`,
{ headers }
);
if (!response.ok) {
throw new Error(`Query failed with HTTP ${response.status}`);
}
return response.json();
}
async function retrieveVideo(fileId) {
const response = await fetch(
`${baseUrl}/files/retrieve?file_id=${encodeURIComponent(fileId)}`,
{ headers }
);
if (!response.ok) {
throw new Error(`File retrieval failed with HTTP ${response.status}`);
}
const data = await response.json();
return data.file?.download_url || data.download_url;
}
async function main() {
const taskId = await createVideo();
while (true) {
const task = await queryVideo(taskId);
if (task.status === "Success") {
const downloadUrl = await retrieveVideo(task.file_id);
console.log({ taskId, fileId: task.file_id, downloadUrl });
break;
}
if (task.status === "Fail") {
throw new Error(task.error_message || "Video generation failed");
}
await new Promise(resolve => setTimeout(resolve, 10000));
}
}
main().catch(console.error);
The returned download URL should be copied to application storage promptly when your project requires long-term access. Treat the URL as temporary unless the current file API documentation states otherwise.
| Status | Meaning | Recommended Action |
|---|---|---|
400 | Invalid payload or unsupported option | Validate model, duration, resolution, and inputs |
401 / 403 | Authentication or permission problem | Check the secret and Authorization header |
429 | Rate limit or quota issue | Pause and retry with exponential backoff |
500–599 | Temporary service failure | Retry a limited number of times |
Fail | Task ended without a usable result | Read the error and submit a corrected task |
Never place the API key in frontend source, browser local storage, public logs, or error messages returned to ordinary users.
Prompts, Modes, and Input Choices
The JavaScript request controls the task, but prompt quality determines how clearly H3 can interpret the intended scene. Use chronological instructions and avoid conflicting camera movements.
A useful prompt structure is: subject and setting, action and timing, camera movement, lighting and style, dialogue, sound effects, ambience, and final composition.
| Generation Mode | Main Input | Best Use |
|---|---|---|
| Text-to-video | Text prompt | New scenes and rapid concept testing |
| First-frame image-to-video | One starting image and prompt | Animating a prepared composition |
| First-and-last-frame | Two ordered images and transition prompt | Controlled transformations |
| Reference-to-video | Visual references and scene prompt | Products, characters, and style continuity |
| Motion transfer | Subject reference and motion video | Matching movement and timing |
| Video regeneration | Source video and edit prompt | Restyling or modifying existing footage |
For reference-based requests, state what each asset controls. For example, identify one image as the character reference and a video as the movement reference. This reduces ambiguity and helps preserve the details that matter most.
Describe one primary action, one main camera movement, and a clear sound plan. Short clips usually benefit from focused instructions rather than many unrelated events.
Best Practices and FAQ
Use a staged production workflow: test a short 768P draft, inspect motion and audio, revise only the weak instruction, and reserve higher-resolution output for the selected result. The official pricing documentation explains that costs depend on duration, resolution, workflow, and applicable reference charges.
The hosted API and local H3 weights are different options. The official MiniMax H3 Hugging Face repository provides the open-weight release, while hosted services manage infrastructure, task queues, and file delivery. The reference material identifies H3-Base weights as available, while some hosted Context-IR and 2K regeneration features remain separate services.
| Workflow | Strength | Main Trade-Off |
|---|---|---|
| Hosted API | Fast integration and managed serving | Requires API access and usage balance |
| MiniMax CLI | Convenient terminal workflow | Depends on supported CLI commands |
| Local weights | Infrastructure and storage control | Requires compatible hardware and setup |
| Reference generation | Better identity or product control | Needs clear, supported input assets |
Keep the original prompt, task ID, input assets, API response, and final file path together. This makes successful generations easier to reproduce and audit.
Q: What is the MiniMax H3 JavaScript API workflow?
Create an asynchronous video task, store its task_id, poll the query endpoint, retrieve the file with file_id, and save the returned download URL.
Q: Can I call the MiniMax H3 API directly from browser JavaScript?
A backend or serverless proxy is safer because browser code would expose the API key. Keep authentication on infrastructure you control.
Q: How should I handle a failed H3 task?
Read the task error message, check the prompt and input constraints, correct the request, and create a new task rather than repeatedly polling a failed one.
Q: Are local H3 weights the same as the hosted API?
No. Downloaded weights support self-managed inference, while hosted services may provide separate managed features, optimizations, file delivery, and Context-IR workflows.