MiniMax-AI/skills · error · SystemExit

API Error [{code}]: {msg}

Error message

API Error [{code}]: {msg}

What it means

Shared _check_resp() helper: after HTTP 2xx on any video endpoint (POST video_generation, GET query/video_generation, GET files/retrieve), the body's base_resp.status_code is non-zero. This is MiniMax's application-level error channel; status_msg holds the detail and is surfaced for whichever endpoint produced it.

Source

Thrown at skills/frontend-dev/scripts/minimax_video.py:43

if not API_BASE:
    raise SystemExit("ERROR: MINIMAX_API_BASE is not set.")


def _headers():
    if not API_KEY:
        raise SystemExit("ERROR: MINIMAX_API_KEY is not set.\n  export MINIMAX_API_KEY='your-key'")
    return {
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "application/json",
    }


def _check_resp(data):
    base_resp = data.get("base_resp", {})
    code = base_resp.get("status_code", 0)
    if code != 0:
        msg = base_resp.get("status_msg", "Unknown error")
        raise SystemExit(f"API Error [{code}]: {msg}")


def create_task(
    prompt: str,
    model: str = "MiniMax-Hailuo-2.3",
    duration: int = 6,
    resolution: str = "768P",
    prompt_optimizer: bool = True,
) -> str:
    """Submit a video generation task. Returns task_id."""
    payload = {
        "model": model,
        "prompt": prompt,
        "duration": duration,
        "resolution": resolution,
        "prompt_optimizer": prompt_optimizer,
    }

View on GitHub (pinned to 60aaae52bb)

Solutions

  1. Read the printed code + status_msg to identify which of the three endpoints failed and why.
  2. For create failures, validate model in {MiniMax-Hailuo-2.3, MiniMax-Hailuo-02, T2V-01-Director, T2V-01}, duration in {6,10}, resolution in {720P,768P,1080P}, and prompt ≤2000 chars.
  3. Match API_BASE region to the key region.
  4. On transient/rate-limit codes, back off and retry; on auth codes (e.g. 1004) re-check the key.

Example fix

// before: generic abort
raise SystemExit(f"API Error [{code}]: {msg}")

// after: classify retryable vs terminal
class MiniMaxApiError(RuntimeError):
    def __init__(self, code, msg):
        super().__init__(f"{code}: {msg}"); self.code = code
    @property
    def retryable(self):
        return self.code in {1027, 1039}  # rate-limit style codes
if code != 0:
    raise MiniMaxApiError(code, msg)
Defensive patterns

Strategy: try-catch

Validate before calling

def validate_video_params(model, duration, resolution, prompt):
    assert model in {"MiniMax-Hailuo-2.3", "MiniMax-Hailuo-02", "T2V-01-Director", "T2V-01"}, f"bad model {model}"
    assert duration in {6, 10}, f"bad duration {duration}"
    assert resolution in {"720P", "768P", "1080P"}, f"bad resolution {resolution}"
    assert len(prompt) <= 2000, "prompt > 2000 chars"

Type guard

def is_api_error(data: dict) -> bool:
    base = data.get("base_resp", {}) if isinstance(data, dict) else {}
    return isinstance(base, dict) and base.get("status_code", 0) != 0

Try / catch

import subprocess, sys
try:
    subprocess.run([sys.executable, "minimax_video.py", prompt, "-o", out], check=True, capture_output=True, text=True)
except subprocess.CalledProcessError as e:
    msg = (e.stderr or "") + (e.stdout or "")
    if "API Error [" in msg:
        code, detail = parse_api_error(msg)
        if code in TRANSIENT_CODES:
            time.sleep(backoff); retry()
        else:
            raise RuntimeError(f"video API {code}: {detail}") from e
    raise

Prevention

When it happens

Trigger: Invalid model/resolution/duration combo on create (e.g. 1080P with a model that doesn't support it); prompt over 2000 chars or content-policy rejection; querying a task_id that doesn't belong to the account; retrieving a file_id that expired or is invalid; rate limit / quota on any of the three calls.

Common situations: Region/key mismatch (mainland key vs overseas host); model not enabled for the account; camera-command or bracket syntax the API rejects; querying a stale task; concurrent-request ceiling hit.

Related errors


AI-assisted analysis of MiniMax-AI/skills@60aaae52bb (2026-08-13). Data as JSON: /api/errors/f58e9d30792e06a7. Report an issue: GitHub.