MiniMax-AI/skills · critical · SystemExit

ERROR: MINIMAX_API_KEY is not set.\n export MINIMAX_API_KEY

Error message

ERROR: MINIMAX_API_KEY is not set.\n  export MINIMAX_API_KEY='your-key'

What it means

Raised inside _headers() the first time an authenticated request is built. API_KEY is read from MINIMAX_API_KEY at module load (line 25) but checked lazily in _headers(), so import succeeds without the key; the failure surfaces only on the first API call (create_task, poll_task, or download_video).

Source

Thrown at skills/gif-sticker-maker/scripts/minimax_video.py:51

    "MiniMax-Hailuo-2.3",
    "MiniMax-Hailuo-2.3-Fast",
    "MiniMax-Hailuo-02",
    "I2V-01-Director",
    "I2V-01-live",
    "I2V-01",
]

T2V_MODELS = [
    "MiniMax-Hailuo-2.3",
    "MiniMax-Hailuo-02",
    "T2V-01-Director",
    "T2V-01",
]


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 _encode_image(image_path: str) -> str:
    """Read local image file and return base64 data URI."""
    ext = os.path.splitext(image_path)[1].lower().lstrip(".")
    mime_map = {"jpg": "jpeg", "jpeg": "jpeg", "png": "png", "webp": "webp"}

View on GitHub (pinned to 60aaae52bb)

Solutions

  1. export MINIMAX_API_KEY='your-key'
  2. Confirm it is exported (not just a local var): printenv MINIMAX_API_KEY
  3. Regenerate the key in the MiniMax console if it was revoked.

Example fix

# before
python minimax_video.py 'prompt' -o out.mp4   # SystemExit: MINIMAX_API_KEY is not set

# after
export MINIMAX_API_KEY='your-key'
python minimax_video.py 'prompt' -o out.mp4
Defensive patterns

Strategy: validation

Validate before calling

import os
if not os.getenv('MINIMAX_API_KEY'):
    raise EnvironmentError('MINIMAX_API_KEY is not set. export MINIMAX_API_KEY=\'your-key\'')

Try / catch

try:
    task_id = minimax_video.create_task(...)
except SystemExit as e:
    if 'MINIMAX_API_KEY' in str(e):
        raise EnvironmentError(str(e)) from e
    raise

Prevention

When it happens

Trigger: Any code path that calls _headers() — create_task(), poll_task(), download_video() — while MINIMAX_API_KEY is unset or empty.

Common situations: Key set in a different shell/session; key revoked or expired; .env not loaded; copy-paste left the value empty; key exported as a non-exported shell variable.

Related errors


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