MiniMax-AI/skills · critical · SystemExit
ERROR: MINIMAX_API_BASE is not set.
Error message
ERROR: MINIMAX_API_BASE is not set.
What it means
`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.
Source
Thrown at skills/frontend-dev/scripts/minimax_music.py:26
python minimax_music.py --prompt "Indie folk, melancholic" --lyrics "[verse]\nStreetlights flicker" -o song.mp3
python minimax_music.py --prompt "Upbeat pop, energetic" --auto-lyrics -o pop.mp3
python minimax_music.py --prompt "Jazz piano, smooth, relaxing" --instrumental -o jazz.mp3
Env: MINIMAX_API_KEY (required)
"""
import os
import sys
import json
import argparse
import requests
API_KEY = os.getenv("MINIMAX_API_KEY")
# China Mainland: https://api.minimaxi.com/v1
# Overseas: https://api.minimax.io/v1
API_BASE = os.getenv("MINIMAX_API_BASE")
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'")
View on GitHub (pinned to 60aaae52bb)
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.
Example fix
# before — base URL missing python minimax_music.py --prompt "jazz" -o song.mp3 # SystemExit # after export MINIMAX_API_BASE='https://api.minimax.io/v1' export MINIMAX_API_KEY='your-key' python minimax_music.py --prompt "jazz" -o song.mp3
Defensive patterns
Strategy: validation
Validate before calling
import os, sys
API_BASE = os.getenv("MINIMAX_API_BASE")
if not API_BASE:
print("ERROR: set MINIMAX_API_BASE (overseas: https://api.minimax.io/v1, CN: https://api.minimaxi.com/v1)", file=sys.stderr)
sys.exit(2) Type guard
def _valid_base(url: str | None) -> bool:
return bool(url) and url.startswith("http") and url.rstrip("/").endswith("/v1") Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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`).
Related errors
- ERROR: MINIMAX_API_BASE is not set.
- ERROR: MINIMAX_API_KEY is not set. export MINIMAX_API_KEY=
- API Error [{base_resp.get('status_code')}]: {base_resp.get('
- ERROR: MINIMAX_API_KEY is not set. export MINIMAX_API_KEY=
- API Error [{base_resp.get('status_code')}]: {base_resp.get('
AI-assisted analysis of MiniMax-AI/skills@60aaae52bb (2026-08-13).
Data as JSON: /api/errors/12694a01bda888d1.
Report an issue: GitHub.