MiniMax-AI/skills · critical · SystemExit
ERROR: MINIMAX_API_KEY is not set. export MINIMAX_API_KEY=
Error message
ERROR: MINIMAX_API_KEY is not set. export MINIMAX_API_KEY='your-key'
What it means
Raised inside the _headers() helper, which is called lazily on every request (create_task, poll_task, download_video). API_KEY is falsy, so the Authorization header cannot be built. Because the check is in _headers and not at import, importing the module succeeds; it only fails when a request is attempted.
Source
Thrown at skills/frontend-dev/scripts/minimax_video.py:31
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}")
def create_task(
prompt: str,
model: str = "MiniMax-Hailuo-2.3",
duration: int = 6,View on GitHub (pinned to 60aaae52bb)
Solutions
- Export the key: `export MINIMAX_API_KEY='your-key'` then re-run.
- Source .env before launching; confirm with `env | grep MINIMAX`.
- In CI, inject MINIMAX_API_KEY as a secret env on the step and assert non-empty up front.
Example fix
// before $ python minimax_video.py "a cat" -o cat.mp4 ERROR: MINIMAX_API_KEY is not set. // after $ export MINIMAX_API_KEY='your-key' $ python minimax_video.py "a cat" -o cat.mp4
Defensive patterns
Strategy: validation
Validate before calling
import os
if not os.getenv("MINIMAX_API_KEY"):
raise EnvironmentError("MINIMAX_API_KEY must be set before calling create_task/poll_task/download_video")
if not os.getenv("MINIMAX_API_BASE"):
raise EnvironmentError("MINIMAX_API_BASE must be set before importing minimax_video")
from skills.frontend_dev.scripts.minimax_video import generate Type guard
def has_video_key() -> bool:
"""True only when the video API key env var is non-empty."""
return bool(os.getenv("MINIMAX_API_KEY")) 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:
if "MINIMAX_API_KEY is not set" in (e.stderr or ""):
raise EnvironmentError("export MINIMAX_API_KEY first") from e
raise Prevention
- Assert both MINIMAX env vars in one bootstrap step before any video call.
- Gate CI steps on `test -n "$MINIMAX_API_KEY"`.
- Run `env | grep MINIMAX` as a preflight in the launching shell.
When it happens
Trigger: Calling create_task/poll_task/download_video or running the CLI with MINIMAX_API_KEY unset/empty (while API_BASE was set, so import succeeded).
Common situations: .env not sourced; CI secret empty/masked; different shell than where the export ran; key var name typo; key set in interactive shell but not the runner subprocess.
Related errors
- ERROR: MINIMAX_API_KEY is not set. export MINIMAX_API_KEY=
- ERROR: MINIMAX_API_KEY is not set. export MINIMAX_API_KEY=
- ERROR: MINIMAX_API_BASE is not set.
- ERROR: MINIMAX_API_KEY is not set.\n export MINIMAX_API_KEY
- ERROR: MINIMAX_API_BASE is not set.
AI-assisted analysis of MiniMax-AI/skills@60aaae52bb (2026-08-13).
Data as JSON: /api/errors/f82f11615e1d6aee.
Report an issue: GitHub.