{"record":{"id":"f82f11615e1d6aee","repo":"MiniMax-AI/skills","slug":"error-minimax-api-key-is-not-set-export-minima-f82f11","errorCode":null,"errorMessage":"ERROR: MINIMAX_API_KEY is not set.\n  export MINIMAX_API_KEY='your-key'","messagePattern":"ERROR: MINIMAX_API_KEY is not set\\.\n  export MINIMAX_API_KEY='your-key'","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"critical","filePath":"skills/frontend-dev/scripts/minimax_video.py","lineNumber":31,"sourceCode":"\nimport os\nimport sys\nimport json\nimport time\nimport argparse\nimport requests\n\nAPI_KEY = os.getenv(\"MINIMAX_API_KEY\")\n# China Mainland: https://api.minimaxi.com/v1\n# Overseas:       https://api.minimax.io/v1\nAPI_BASE = os.getenv(\"MINIMAX_API_BASE\")\nif not API_BASE:\n    raise SystemExit(\"ERROR: MINIMAX_API_BASE is not set.\")\n\n\ndef _headers():\n    if not API_KEY:\n        raise SystemExit(\"ERROR: MINIMAX_API_KEY is not set.\\n  export MINIMAX_API_KEY='your-key'\")\n    return {\n        \"Authorization\": f\"Bearer {API_KEY}\",\n        \"Content-Type\": \"application/json\",\n    }\n\n\ndef _check_resp(data):\n    base_resp = data.get(\"base_resp\", {})\n    code = base_resp.get(\"status_code\", 0)\n    if code != 0:\n        msg = base_resp.get(\"status_msg\", \"Unknown error\")\n        raise SystemExit(f\"API Error [{code}]: {msg}\")\n\n\ndef create_task(\n    prompt: str,\n    model: str = \"MiniMax-Hailuo-2.3\",\n    duration: int = 6,","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/MiniMax-AI/skills/blob/60aaae52bb2af8162732751a4332f62a5fef518b/skills/frontend-dev/scripts/minimax_video.py#L13-L49","documentation":"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.","triggerScenarios":"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).","commonSituations":".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.","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."],"exampleFix":"// before\n$ python minimax_video.py \"a cat\" -o cat.mp4\nERROR: MINIMAX_API_KEY is not set.\n\n// after\n$ export MINIMAX_API_KEY='your-key'\n$ python minimax_video.py \"a cat\" -o cat.mp4","handlingStrategy":"validation","validationCode":"import os\n\nif not os.getenv(\"MINIMAX_API_KEY\"):\n    raise EnvironmentError(\"MINIMAX_API_KEY must be set before calling create_task/poll_task/download_video\")\nif not os.getenv(\"MINIMAX_API_BASE\"):\n    raise EnvironmentError(\"MINIMAX_API_BASE must be set before importing minimax_video\")\nfrom skills.frontend_dev.scripts.minimax_video import generate","typeGuard":"def has_video_key() -> bool:\n    \"\"\"True only when the video API key env var is non-empty.\"\"\"\n    return bool(os.getenv(\"MINIMAX_API_KEY\"))","tryCatchPattern":"import subprocess, sys\ntry:\n    subprocess.run([sys.executable, \"minimax_video.py\", prompt, \"-o\", out], check=True, capture_output=True, text=True)\nexcept subprocess.CalledProcessError as e:\n    if \"MINIMAX_API_KEY is not set\" in (e.stderr or \"\"):\n        raise EnvironmentError(\"export MINIMAX_API_KEY first\") from e\n    raise","preventionTips":["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."],"tags":["config","environment","authentication","python","minimax","video"],"backgroundTag":null,"analyzedSha":"60aaae52bb2af8162732751a4332f62a5fef518b","analyzedAt":"2026-08-13T17:32:34.717Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}