AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How to Configure the MiniMax Video-01 REST API for Automated Video Generation Across Global and Mainland Endpoints

高岡さゆり · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

Automating video creation at commercial scale requires moving past web GUIs and integrating directly with backend render engines. For engineering teams evaluating MiniMax Video, the Video-01 REST API delivers high-fidelity cinematic video synthesis through an asynchronous pipeline. However, deploying Video-01 reliably across international platforms and domestic Chinese infrastructure requires strict gateway routing, resilient polling loops, and immediate asset persistence.

At 365Finds, our testing and architectural assessment leads to a direct recommendation: decouple your API orchestration from region-specific gateways using strict environment isolation, turn off default prompt optimization when using upstream LLM prompt builders, and treat MiniMax storage URLs as temporary transfer links rather than persistent media hosting.


1. Regional Endpoint Architecture and Routing Isolation

A common failure mode when integrating MiniMax Video is attempting to use a single API key or unified endpoint across all geographic traffic. MiniMax operates two isolated production clusters with distinct authentication stores, regulatory compliance layers, and base URLs.

DimensionGlobal PlatformMainland China Platform
Gateway Hostapi.minimaxi.chatapi.minimax.chat
Developer Portalplatform.minimax.ioplatform.minimaxi.com
Auth Token TypeBearer API Key (Global Org)Bearer API Key (Mainland Org)
Account BalanceUSD Billing / Stripe / WireCNY Billing / Alipay / Corporate Transfer
Primary Use CaseGlobal SaaS; international web appsDomestic apps requiring Mainland compliance

Notice the naming divergence: the global endpoint contains an extra i (minimaxi.chat), whereas the domestic gateway uses minimax.chat. Authentication keys issued on platform.minimax.io do not authenticate against api.minimax.chat and immediately return HTTP 401 unauthorized errors.

365Finds Architectural Recommendation: Explicit Cluster Routing

Do not attempt dynamic runtime fallback between regions. 365Finds recommends enforcing an explicit cluster configuration pattern in your backend microservices:

import os

class MiniMaxConfig:
    REGIONAL_ENDPOINTS = {
        "global": "https://api.minimaxi.chat/v1",
        "cn": "https://api.minimax.chat/v1",
    }

    def __init__(self, region: str = "global"):
        region_key = region.lower()
        if region_key not in self.REGIONAL_ENDPOINTS:
            raise ValueError(f"Unsupported region: {region}. Choose 'global' or 'cn'.")
        
        self.base_url = self.REGIONAL_ENDPOINTS[region_key]
        env_var = "MINIMAX_API_KEY_GLOBAL" if region_key == "global" else "MINIMAX_API_KEY_CN"
        self.api_key = os.getenv(env_var)
        
        if not self.api_key:
            raise EnvironmentError(f"Missing API key environment variable: {env_var}")

    @property
    def headers(self) -> dict:
        return {
            "Authorization": f"Bearer {self.api_key}",
            "Content-Type": "application/json",
        }

2. Asynchronous Task Submission (POST /v1/video_generation)

Video generation is GPU-intensive and cannot return synchronous responses. Calling the /v1/video_generation endpoint registers a render task and immediately returns a unique task_id.

Core Parameters for Video-01

365Finds Evaluation: Controlling prompt_optimizer

MiniMax includes an automated prompt expansion model that activates when prompt_optimizer: true. While beneficial for casual human users typing brief prompts like "a dog running," 365Finds strongly advises setting prompt_optimizer: false in automated production systems if:

  1. You already operate a dedicated LLM prompt-refinement node (e.g., GPT-4o or Claude 3.5 Sonnet) that injects structured scene parameters.
  2. You rely on explicit cinematic framing commands such as [Push in], [Pan left], or [Aerial tracking]. Automatic rewriting often strips or reinterprets bracketed camera directives.

When using first_frame_image, ensure your prompt describes temporal change rather than existing scene composition. Describing elements already present in frame zero wastes attention tokens and introduces model hallucinations.


3. Production Task Polling (GET /v1/query/video_generation)

Once a task_id is acquired, the generation pipeline enters an asynchronous processing state. The status query endpoint is accessed via GET /v1/query/video_generation?task_id={task_id}.

Task Status State Machine

   [Preparing]
        │
        ▼
   [Queueing]  ──(Resource constraint)──► [Queueing backoff]
        │
        ▼
  [Processing] ──(Active GPU inference)──► 45s - 180s typical render
        │
   ┌────┴────────────────────────┐
   ▼                             ▼
[Success]                      [Fail]
(Returns file_id)          (Returns error_msg & status_code)

Polling Best Practices

Avoid naive tight-loop requests that bombard the query endpoint every second. Aggressive polling triggers HTTP 429 rate limits without accelerating the GPU job. 365Finds recommends:


4. Asset Retrieval and the 9-Hour Expiration Risk

A critical operational pitfall in MiniMax Video integration involves file handling upon task completion. The query endpoint does not return a direct permanent CDN URL. Instead, it yields a file_id.

To resolve the download link, your service must call the File Management API: GET /v1/files/retrieve?file_id={file_id}

The returned JSON payload includes:

{
  "file": {
    "file_id": "9876543210",
    "bytes": 5896337,
    "created_at": 1700469398,
    "filename": "output_video.mp4",
    "purpose": "video_generation",
    "download_url": "https://filecdn.minimax.chat/..."
  },
  "base_resp": {
    "status_code": 0,
    "status_msg": "success"
  }
}

The 9-Hour Ephemeral Expiration

The download_url provided by MiniMax is signed with a temporary token valid for approximately 9 hours. After this window closes, the URL fails and the raw file is purged from the platform's cache.

365Finds Verdict: Under no circumstances should backend services pass the raw MiniMax download_url directly to client applications or database storage. A production pipeline must immediately stream the video binary into private persistent object storage (such as Amazon S3, Cloudflare R2, or Alibaba Cloud OSS) and return internally managed CDN URLs.


5. End-to-End Implementation Script

The following production-ready Python implementation demonstrates region routing, task creation, adaptive polling, and streaming download to disk:

import os
import time
import requests

class MiniMaxVideoClient:
    REGIONAL_ENDPOINTS = {
        "global": "https://api.minimaxi.chat/v1",
        "cn": "https://api.minimax.chat/v1",
    }

    def __init__(self, region: str = "global"):
        region_key = region.lower()
        if region_key not in self.REGIONAL_ENDPOINTS:
            raise ValueError(f"Invalid region '{region}'. Must be 'global' or 'cn'.")
            
        self.base_url = self.REGIONAL_ENDPOINTS[region_key]
        env_var = "MINIMAX_API_KEY_GLOBAL" if region_key == "global" else "MINIMAX_API_KEY_CN"
        self.api_key = os.getenv(env_var)
        
        if not self.api_key:
            raise ValueError(f"API key environment variable {env_var} is not set.")
            
        self.headers = {
            "Authorization": f"Bearer {self.api_key}",
            "Content-Type": "application/json",
        }

    def submit_video_task(
        self,
        prompt: str,
        model: str = "video-01",
        prompt_optimizer: bool = False,
        first_frame_image: str | None = None,
    ) -> str:
        url = f"{self.base_url}/video_generation"
        payload = {
            "model": model,
            "prompt": prompt,
            "prompt_optimizer": prompt_optimizer,
        }
        if first_frame_image:
            payload["first_frame_image"] = first_frame_image

        response = requests.post(url, headers=self.headers, json=payload, timeout=30)
        response.raise_for_status()
        data = response.json()

        base_resp = data.get("base_resp", {})
        if base_resp.get("status_code", 0) != 0:
            raise RuntimeError(f"MiniMax API Error: {base_resp.get('status_msg')}")

        task_id = data.get("task_id")
        if not task_id:
            raise KeyError("Failed to parse 'task_id' from response.")
        return task_id

    def poll_until_complete(
        self,
        task_id: str,
        poll_interval: int = 12,
        timeout: int = 600,
    ) -> str:
        query_url = f"{self.base_url}/query/video_generation"
        start_time = time.time()
        time.sleep(10)  # Initial wait before first query

        while True:
            if time.time() - start_time > timeout:
                raise TimeoutError(f"Task {task_id} timed out after {timeout} seconds.")

            response = requests.get(
                query_url,
                headers=self.headers,
                params={"task_id": task_id},
                timeout=15,
            )
            response.raise_for_status()
            data = response.json()

            status = data.get("status")
            if status == "Success":
                file_id = data.get("file_id")
                if not file_id:
                    raise KeyError(f"Task succeeded but file_id is missing: {data}")
                return str(file_id)
            elif status == "Fail":
                err_msg = data.get("base_resp", {}).get("status_msg", "Unknown error")
                raise RuntimeError(f"Video render failed for task {task_id}: {err_msg}")

            time.sleep(poll_interval)

    def retrieve_download_url(self, file_id: str) -> str:
        retrieve_url = f"{self.base_url}/files/retrieve"
        response = requests.get(
            retrieve_url,
            headers=self.headers,
            params={"file_id": file_id},
            timeout=15,
        )
        response.raise_for_status()
        data = response.json()

        download_url = data.get("file", {}).get("download_url")
        if not download_url:
            raise KeyError(f"Failed to extract download_url for file {file_id}: {data}")
        return download_url

    def stream_to_storage(self, download_url: str, destination_path: str):
        with requests.get(download_url, stream=True, timeout=60) as resp:
            resp.raise_for_status()
            with open(destination_path, "wb") as f:
                for chunk in resp.iter_content(chunk_size=65536):
                    if chunk:
                        f.write(chunk)

# Operational execution workflow
if __name__ == "__main__":
    client = MiniMaxVideoClient(region="global")
    
    prompt_text = "Cinematic aerial tracking shot over volcanic black sand beaches at twilight, surging ocean spray, 35mm film grain."
    print("Submitting render task...")
    task_id = client.submit_video_task(prompt=prompt_text, prompt_optimizer=False)
    print(f"Submitted. Task ID: {task_id}")

    print("Polling task status...")
    file_id = client.poll_until_complete(task_id=task_id)
    print(f"Task completed successfully. File ID: {file_id}")

    temp_url = client.retrieve_download_url(file_id=file_id)
    print("Acquired ephemeral download link. Persisting asset...")
    
    local_output = f"minimax_video_{file_id}.mp4"
    client.stream_to_storage(temp_url, local_output)
    print(f"Video successfully downloaded and secured: {local_output}")

6. Architecture Synthesis and Operational Checklist

When constructing an enterprise-scale video pipeline powered by MiniMax Video, keep this architecture checklist integrated into your continuous delivery standards:

  1. Routing Verification: Ensure build pipelines enforce separate configurations for api.minimaxi.chat and api.minimax.chat. Never reuse API keys across regional environments.
  2. Prompt Control: Disable prompt_optimizer if upstream prompt templates provide structured cinematography cues.
  3. Queue Decoupling: Offload task submission and status polling to background workers (e.g., Celery, Redis BullMQ, or AWS SQS). Do not hold synchronous HTTP connections open in user-facing web servers.
  4. Immediate Persistence: Trigger automatic stream uploads to S3 or R2 storage immediately upon receiving file_id to eliminate data loss from the 9-hour expiration window.
  5. Content Violation Handling: Implement fallback logic for error code 1026 (sensitive content flag) to alert upstream users without causing background worker crashes.

References