{"record":{"id":"ede4673b2fc9a7fa","repo":"MiniMax-AI/skills","slug":"error-minimax-api-base-is-not-set-ede467","errorCode":null,"errorMessage":"ERROR: MINIMAX_API_BASE is not set.","messagePattern":"ERROR: MINIMAX_API_BASE is not set\\.","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"critical","filePath":"skills/frontend-dev/scripts/minimax_video.py","lineNumber":26,"sourceCode":"  python minimax_video.py \"Ocean waves [Truck left]\" -o waves.mp4 --model MiniMax-Hailuo-2.3 --duration 10\n  python minimax_video.py \"City skyline at sunset [Push in]\" -o city.mp4 --resolution 1080P\n\nEnv: MINIMAX_API_KEY (required)\n\"\"\"\n\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","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/MiniMax-AI/skills/blob/60aaae52bb2af8162732751a4332f62a5fef518b/skills/frontend-dev/scripts/minimax_video.py#L8-L44","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Export the region host: `export MINIMAX_API_BASE='https://api.minimax.io/v1'` (overseas) or `https://api.minimaxi.com/v1` (China mainland).","Set it in the same process before import/run; add it to .env and CI secrets alongside the key.","Verify: `python -c \"import os;print(os.getenv('MINIMAX_API_BASE'))\"` in the launch environment."],"exampleFix":"// before\n$ python minimax_video.py \"a cat\" -o cat.mp4\nERROR: MINIMAX_API_BASE is not set.\n\n// after\n$ export MINIMAX_API_BASE='https://api.minimax.io/v1'\n$ python minimax_video.py \"a cat\" -o cat.mp4","handlingStrategy":"validation","validationCode":"import os\n\nbase = os.getenv(\"MINIMAX_API_BASE\")\nif not base:\n    raise EnvironmentError(\"MINIMAX_API_BASE must be set BEFORE importing minimax_video\")\nimport skills.frontend_dev.scripts.minimax_video as video_mod","typeGuard":"def video_env_ready() -> bool:\n    \"\"\"True only when the import-time API_BASE requirement is satisfied.\"\"\"\n    return bool(os.getenv(\"MINIMAX_API_BASE\"))","tryCatchPattern":"try:\n    import minimax_video  # module-level API_BASE check\nexcept SystemExit as e:\n    if \"MINIMAX_API_BASE\" in str(e):\n        raise EnvironmentError(\"set MINIMAX_API_BASE before importing minimax_video\") from e\n    raise","preventionTips":["Set MINIMAX_API_BASE in the parent process BEFORE importing or running minimax_video.","Keep KEY and BASE together in .env / CI secrets.","Preflight `test -n \"$MINIMAX_API_BASE\"` in launch scripts."],"tags":["config","environment","import-time","python","minimax","video"],"backgroundTag":null,"analyzedSha":"60aaae52bb2af8162732751a4332f62a5fef518b","analyzedAt":"2026-08-13T17:32:34.717Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}