{"record":{"id":"3d0d52a847c38efb","repo":"MiniMax-AI/skills","slug":"error-minimax-api-key-is-not-set-n-export-minim-3d0d52","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/gif-sticker-maker/scripts/minimax_video.py","lineNumber":51,"sourceCode":"    \"MiniMax-Hailuo-2.3\",\n    \"MiniMax-Hailuo-2.3-Fast\",\n    \"MiniMax-Hailuo-02\",\n    \"I2V-01-Director\",\n    \"I2V-01-live\",\n    \"I2V-01\",\n]\n\nT2V_MODELS = [\n    \"MiniMax-Hailuo-2.3\",\n    \"MiniMax-Hailuo-02\",\n    \"T2V-01-Director\",\n    \"T2V-01\",\n]\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 _encode_image(image_path: str) -> str:\n    \"\"\"Read local image file and return base64 data URI.\"\"\"\n    ext = os.path.splitext(image_path)[1].lower().lstrip(\".\")\n    mime_map = {\"jpg\": \"jpeg\", \"jpeg\": \"jpeg\", \"png\": \"png\", \"webp\": \"webp\"}","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/MiniMax-AI/skills/blob/60aaae52bb2af8162732751a4332f62a5fef518b/skills/gif-sticker-maker/scripts/minimax_video.py#L33-L69","documentation":"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).","triggerScenarios":"Any code path that calls _headers() — create_task(), poll_task(), download_video() — while MINIMAX_API_KEY is unset or empty.","commonSituations":"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.","solutions":["export MINIMAX_API_KEY='your-key'","Confirm it is exported (not just a local var): printenv MINIMAX_API_KEY","Regenerate the key in the MiniMax console if it was revoked."],"exampleFix":"# before\npython minimax_video.py 'prompt' -o out.mp4   # SystemExit: MINIMAX_API_KEY is not set\n\n# after\nexport MINIMAX_API_KEY='your-key'\npython minimax_video.py 'prompt' -o out.mp4","handlingStrategy":"validation","validationCode":"import os\nif not os.getenv('MINIMAX_API_KEY'):\n    raise EnvironmentError('MINIMAX_API_KEY is not set. export MINIMAX_API_KEY=\\'your-key\\'')","typeGuard":null,"tryCatchPattern":"try:\n    task_id = minimax_video.create_task(...)\nexcept SystemExit as e:\n    if 'MINIMAX_API_KEY' in str(e):\n        raise EnvironmentError(str(e)) from e\n    raise","preventionTips":["Export (not just assign) the key: 'export MINIMAX_API_KEY=...'.","Validate os.getenv('MINIMAX_API_KEY') before calling any video function.","Keep keys in a sourced .env or secrets manager, never hardcoded."],"tags":["config","environment","authentication","minimax"],"backgroundTag":null,"analyzedSha":"60aaae52bb2af8162732751a4332f62a5fef518b","analyzedAt":"2026-08-13T17:32:34.717Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}