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 by generate_music() when MINIMAX_API_KEY is absent or empty. The script reads the key once at import (API_KEY = os.getenv) and refuses to build the Authorization Bearer header without it, so it aborts before any network call to POST {API_BASE}/music_generation. Note API_BASE is validated at import time (line 26) and must already be set for execution to even reach this check.
Source
Thrown at skills/frontend-dev/scripts/minimax_music.py:43
if not API_BASE:
raise SystemExit("ERROR: MINIMAX_API_BASE is not set.")
def generate_music(
prompt: str = "",
lyrics: str = "",
model: str = "music-2.5+",
is_instrumental: bool = False,
lyrics_optimizer: bool = False,
sample_rate: int = 44100,
bitrate: int = 256000,
fmt: str = "mp3",
output_format: str = "hex",
timeout: int = 600,
) -> dict:
"""Synchronous HTTP music generation. Returns dict with audio bytes and metadata."""
if not API_KEY:
raise SystemExit("ERROR: MINIMAX_API_KEY is not set.\n export MINIMAX_API_KEY='your-key'")
payload = {
"model": model,
"audio_setting": {
"sample_rate": sample_rate,
"bitrate": bitrate,
"format": fmt,
},
"output_format": output_format,
}
if prompt:
payload["prompt"] = prompt
if lyrics:
payload["lyrics"] = lyrics
if is_instrumental:
payload["is_instrumental"] = True
if lyrics_optimizer:View on GitHub (pinned to 60aaae52bb)
Solutions
- Export the key in the current shell: `export MINIMAX_API_KEY='your-key'`, then re-run the script.
- If using a .env file, source it first (`set -a; source .env; set +a`) or load it in your wrapper, since this script does not auto-load dotenv.
- For CI, inject the secret as an environment variable on the runner/step and confirm it is non-empty before the step that calls the script.
- Verify quickly: `python -c "import os;print(bool(os.getenv('MINIMAX_API_KEY')))"` should print True in the exact environment that runs the script.
Example fix
// before $ python minimax_music.py --prompt "jazz" -o out.mp3 ERROR: MINIMAX_API_KEY is not set. // after $ export MINIMAX_API_KEY='your-key' $ python minimax_music.py --prompt "jazz" -o out.mp3
Defensive patterns
Strategy: validation
Validate before calling
import os
key = os.getenv("MINIMAX_API_KEY")
base = os.getenv("MINIMAX_API_BASE")
if not key:
raise EnvironmentError("MINIMAX_API_KEY missing — export it before calling generate_music")
if not base:
raise EnvironmentError("MINIMAX_API_BASE missing — set the region host before importing minimax_music")
# only now import / call
from skills.frontend_dev.scripts.minimax_music import generate_music Type guard
def has_music_creds() -> bool:
"""True only when both env vars are non-empty."""
return bool(os.getenv("MINIMAX_API_KEY")) and bool(os.getenv("MINIMAX_API_BASE")) Try / catch
import subprocess, sys
try:
subprocess.run([sys.executable, "minimax_music.py", "--prompt", p, "-o", out], check=True)
except subprocess.CalledProcessError as e:
if "MINIMAX_API_KEY is not set" in (e.stderr or ""):
raise EnvironmentError("set MINIMAX_API_KEY before running") from e
raise Prevention
- Centralize credential loading in one bootstrap step that exports both MINIMAX_API_KEY and MINIMAX_API_BASE before any minimax script runs.
- Assert creds in CI with `test -n "$MINIMAX_API_KEY"` so a missing secret fails the job early instead of at runtime.
- Run `env | grep MINIMAX` as a preflight check in the exact shell/runner that launches the script.
When it happens
Trigger: Calling generate_music() or running the CLI (`python minimax_music.py --prompt ... -o song.mp3`) in a shell, subprocess, or CI runner where MINIMAX_API_KEY is unset, empty string, or only defined in an un-sourced .env file.
Common situations: Key stored in .env but the file was never loaded (no python-dotenv, no `source .env`); fresh terminal/CI worker that did not inherit the export; typo in the variable name; key quoted incorrectly so the shell expanded to empty; running under a different user account that lacks the export in its profile.
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_KEY is not set.\n export MINIMAX_API_KEY
- ERROR: MINIMAX_API_BASE is not set.
- ERROR: MINIMAX_API_BASE is not set.
AI-assisted analysis of MiniMax-AI/skills@60aaae52bb (2026-08-13).
Data as JSON: /api/errors/3346a0885d281298.
Report an issue: GitHub.