{"record":{"id":"12694a01bda888d1","repo":"MiniMax-AI/skills","slug":"error-minimax-api-base-is-not-set-12694a","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_music.py","lineNumber":26,"sourceCode":"  python minimax_music.py --prompt \"Indie folk, melancholic\" --lyrics \"[verse]\\nStreetlights flicker\" -o song.mp3\n  python minimax_music.py --prompt \"Upbeat pop, energetic\" --auto-lyrics -o pop.mp3\n  python minimax_music.py --prompt \"Jazz piano, smooth, relaxing\" --instrumental -o jazz.mp3\n\nEnv: MINIMAX_API_KEY (required)\n\"\"\"\n\nimport os\nimport sys\nimport json\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 generate_music(\n    prompt: str = \"\",\n    lyrics: str = \"\",\n    model: str = \"music-2.5+\",\n    is_instrumental: bool = False,\n    lyrics_optimizer: bool = False,\n    sample_rate: int = 44100,\n    bitrate: int = 256000,\n    fmt: str = \"mp3\",\n    output_format: str = \"hex\",\n    timeout: int = 600,\n) -> dict:\n    \"\"\"Synchronous HTTP music generation. Returns dict with audio bytes and metadata.\"\"\"\n    if not API_KEY:\n        raise SystemExit(\"ERROR: MINIMAX_API_KEY is not set.\\n  export MINIMAX_API_KEY='your-key'\")\n","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/MiniMax-AI/skills/blob/60aaae52bb2af8162732751a4332f62a5fef518b/skills/frontend-dev/scripts/minimax_music.py#L8-L44","documentation":"`raise SystemExit(\"ERROR: MINIMAX_API_BASE is not set.\")` at module load of `minimax_music.py`. Identical pattern to the image script: `MINIMAX_API_BASE` is read at import time and, if empty, the script aborts because the music generation endpoint URL (`{API_BASE}/music_generation`) cannot be constructed. Uses `SystemExit` for a clean non-zero exit rather than a traceback.","triggerScenarios":"Importing or running `minimax_music.py` in an environment where `MINIMAX_API_BASE` is not exported. The guard executes during top-level module code, before `generate_music` is ever called.","commonSituations":"Fresh shell/container without the env set, forgetting to source the env file, or a typo in the variable name. Distinct from `MINIMAX_API_KEY` (the music script checks the key lazily inside `generate_music`).","solutions":["Export the base URL for your region: `export MINIMAX_API_BASE='https://api.minimax.io/v1'` (overseas) or `'https://api.minimaxi.com/v1'` (China mainland).","Add the export to your shell profile or a sourced `.env` for persistence.","Confirm with `printenv MINIMAX_API_BASE` in the active shell before running."],"exampleFix":"# before — base URL missing\npython minimax_music.py --prompt \"jazz\" -o song.mp3  # SystemExit\n\n# after\nexport MINIMAX_API_BASE='https://api.minimax.io/v1'\nexport MINIMAX_API_KEY='your-key'\npython minimax_music.py --prompt \"jazz\" -o song.mp3","handlingStrategy":"validation","validationCode":"import os, sys\n\nAPI_BASE = os.getenv(\"MINIMAX_API_BASE\")\nif not API_BASE:\n    print(\"ERROR: set MINIMAX_API_BASE (overseas: https://api.minimax.io/v1, CN: https://api.minimaxi.com/v1)\", file=sys.stderr)\n    sys.exit(2)","typeGuard":"def _valid_base(url: str | None) -> bool:\n    return bool(url) and url.startswith(\"http\") and url.rstrip(\"/\").endswith(\"/v1\")","tryCatchPattern":null,"preventionTips":["Document required env vars in a `.env.example` and the script header.","Validate the base URL shape (scheme + trailing `/v1`) and pick a region default if sensible.","Source the same `.env` for image and music scripts so base URL is set once.","Use a settings loader to surface all missing vars in one consolidated error."],"tags":["python","config","env","api","minimax","cli","music"],"backgroundTag":null,"analyzedSha":"60aaae52bb2af8162732751a4332f62a5fef518b","analyzedAt":"2026-08-13T17:32:34.717Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}