MiniMax H3 javascript api: Async Video Setup Guide - API

MiniMax H3 javascript api: Async Video Setup Guide

Learn the MiniMax H3 JavaScript API workflow for creating asynchronous video tasks, polling results, retrieving files, and handling errors.

2026-08-03
MiniMax H3 Wiki Team
Quick Guide
  • 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 StageRequired ValueResult
AuthenticationBearer API keyAuthorized request
CreationModel and prompttask_id
Querytask_idProcessing status
Retrievalfile_idDownload URL
Architecture Tip

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.

1

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.

2

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.

3

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.

4

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.

SettingExampleGuidance
Environment variableMINIMAX_API_KEYKeep it outside source files and client bundles
ModelMiniMax-H3Confirm the current model name in the API reference
PromptCinematic scene with soundDescribe subject, action, camera, dialogue, and audio
Duration6Use a value supported by the selected H3 workflow
Resolution768PUse 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
Reliable Setup

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.

StatusMeaningRecommended Action
400Invalid payload or unsupported optionValidate model, duration, resolution, and inputs
401 / 403Authentication or permission problemCheck the secret and Authorization header
429Rate limit or quota issuePause and retry with exponential backoff
500–599Temporary service failureRetry a limited number of times
FailTask ended without a usable resultRead the error and submit a corrected task
Security Warning

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 ModeMain InputBest Use
Text-to-videoText promptNew scenes and rapid concept testing
First-frame image-to-videoOne starting image and promptAnimating a prepared composition
First-and-last-frameTwo ordered images and transition promptControlled transformations
Reference-to-videoVisual references and scene promptProducts, characters, and style continuity
Motion transferSubject reference and motion videoMatching movement and timing
Video regenerationSource video and edit promptRestyling 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.

Prompt Formula

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.

WorkflowStrengthMain Trade-Off
Hosted APIFast integration and managed servingRequires API access and usage balance
MiniMax CLIConvenient terminal workflowDepends on supported CLI commands
Local weightsInfrastructure and storage controlRequires compatible hardware and setup
Reference generationBetter identity or product controlNeeds clear, supported input assets
Production Tip

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.