MiniMax-AI/skills · critical · SystemExit

ERROR: MINIMAX_API_BASE is not set.

Error message

ERROR: MINIMAX_API_BASE is not set.

What it means

Fires at MODULE IMPORT TIME (top-level line 26). API_BASE is falsy, so importing minimax_video or running the CLI aborts before any function runs. The base URL selects the China-mainland vs overseas host used for the async video pipeline (create task, poll, files/retrieve).

Source

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

  python minimax_video.py "Ocean waves [Truck left]" -o waves.mp4 --model MiniMax-Hailuo-2.3 --duration 10
  python minimax_video.py "City skyline at sunset [Push in]" -o city.mp4 --resolution 1080P

Env: MINIMAX_API_KEY (required)
"""

import os
import sys
import json
import time
import argparse
import requests

API_KEY = os.getenv("MINIMAX_API_KEY")
# China Mainland: https://api.minimaxi.com/v1
# Overseas:       https://api.minimax.io/v1
API_BASE = os.getenv("MINIMAX_API_BASE")
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}")

View on GitHub (pinned to 60aaae52bb)

Solutions

  1. Export the region host: `export MINIMAX_API_BASE='https://api.minimax.io/v1'` (overseas) or `https://api.minimaxi.com/v1` (China mainland).
  2. Set it in the same process before import/run; add it to .env and CI secrets alongside the key.
  3. Verify: `python -c "import os;print(os.getenv('MINIMAX_API_BASE'))"` in the launch environment.

Example fix

// before
$ python minimax_video.py "a cat" -o cat.mp4
ERROR: MINIMAX_API_BASE is not set.

// after
$ export MINIMAX_API_BASE='https://api.minimax.io/v1'
$ python minimax_video.py "a cat" -o cat.mp4
Defensive patterns

Strategy: validation

Validate before calling

import os

base = os.getenv("MINIMAX_API_BASE")
if not base:
    raise EnvironmentError("MINIMAX_API_BASE must be set BEFORE importing minimax_video")
import skills.frontend_dev.scripts.minimax_video as video_mod

Type guard

def video_env_ready() -> bool:
    """True only when the import-time API_BASE requirement is satisfied."""
    return bool(os.getenv("MINIMAX_API_BASE"))

Try / catch

try:
    import minimax_video  # module-level API_BASE check
except SystemExit as e:
    if "MINIMAX_API_BASE" in str(e):
        raise EnvironmentError("set MINIMAX_API_BASE before importing minimax_video") from e
    raise

Prevention

When it happens

Trigger: Importing the module or running the CLI with MINIMAX_API_BASE unset/empty. Module-level check means even `import minimax_video` triggers it; setting the var after import is too late.

Common situations: Only the API key was exported; .env missing the base URL; CI has the key but not the host; importing the module from another script before sourcing environment.

Related errors


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