MiniMax-AI/skills · error · SystemExit

API Error [{base_resp.get('status_code')}]: {base_resp.get('

Error message

API Error [{base_resp.get('status_code')}]: {base_resp.get('status_msg')}

What it means

The HTTP call to music_generation succeeded (resp.raise_for_status() passed, i.e. HTTP 2xx) but the response body carried an application-level error: data.base_resp.status_code is non-zero. MiniMax communicates business/logic errors through base_resp rather than HTTP status codes, and status_msg holds the human-readable cause.

Source

Thrown at skills/frontend-dev/scripts/minimax_music.py:79

    if lyrics_optimizer:
        payload["lyrics_optimizer"] = True

    resp = requests.post(
        f"{API_BASE}/music_generation",
        headers={
            "Authorization": f"Bearer {API_KEY}",
            "Content-Type": "application/json",
        },
        json=payload,
        timeout=timeout,
    )
    resp.raise_for_status()
    data = resp.json()

    # Check API-level error
    base_resp = data.get("base_resp", {})
    if base_resp.get("status_code", 0) != 0:
        raise SystemExit(f"API Error [{base_resp.get('status_code')}]: {base_resp.get('status_msg')}")

    status = data.get("data", {}).get("status")
    if status != 2:
        raise SystemExit(f"Generation incomplete (status={status}): {json.dumps(data, indent=2)}")

    audio_data = data.get("data", {}).get("audio", "")
    if not audio_data:
        raise SystemExit(f"No audio in response: {json.dumps(data, indent=2)}")

    extra = data.get("extra_info", {})

    if output_format == "hex":
        audio_bytes = bytes.fromhex(audio_data)
    else:
        # URL mode — audio_data is a URL string
        audio_bytes = None

    return {

View on GitHub (pinned to 60aaae52bb)

Solutions

  1. Read the printed status_code and status_msg first — they name the exact cause (e.g. 1004 auth, 1027 rate limit, 1039 content).
  2. Cross-check the chosen MINIMAX_API_BASE region against the key's account region and switch to the matching host.
  3. Validate payload values against current limits (model in [music-2.5+, music-2.5], sample_rate in {16000,24000,32000,44100}, bitrate in {32000,64000,128000,256000}, format in {mp3,wav,pcm}).
  4. If it is a transient/rate-limit code, back off and retry; if content/policy, shorten or rephrase prompt/lyrics.

Example fix

// before: only HTTP errors surface
resp.raise_for_status()
data = resp.json()

// after: also surface base_resp business errors with context
base_resp = data.get("base_resp", {})
code = base_resp.get("status_code", 0)
if code != 0:
    raise RuntimeError(f"music_generation failed code={code}: {base_resp.get('status_msg')}")
Defensive patterns

Strategy: try-catch

Validate before calling

ALLOWED = {
    "model": {"music-2.5+", "music-2.5"},
    "sample_rate": {16000, 24000, 32000, 44100},
    "bitrate": {32000, 64000, 128000, 256000},
    "fmt": {"mp3", "wav", "pcm"},
}
def validate_music_payload(model, sample_rate, bitrate, fmt, prompt, lyrics):
    assert model in ALLOWED["model"], f"bad model {model}"
    assert sample_rate in ALLOWED["sample_rate"]
    assert bitrate in ALLOWED["bitrate"]
    assert fmt in ALLOWED["fmt"]
    assert len(prompt) <= 2000, "prompt > 2000 chars"
    assert len(lyrics) <= 3500, "lyrics > 3500 chars"

Type guard

def is_api_error(data: dict) -> bool:
    """True when a MiniMax response carries a non-zero base_resp.status_code."""
    base = data.get("base_resp", {}) if isinstance(data, dict) else {}
    return isinstance(base, dict) and base.get("status_code", 0) != 0

Try / catch

import subprocess, sys
try:
    subprocess.run([sys.executable, "minimax_music.py", "--prompt", p, "-o", out], check=True, capture_output=True, text=True)
except subprocess.CalledProcessError as e:
    out = e.stdout or "" + e.stderr or ""
    if "API Error [" in out:
        code, msg = parse_api_error(out)  # extract [code]: msg
        if code in TRANSIENT_CODES:
            time.sleep(backoff); retry()
        else:
            raise RuntimeError(f"music API {code}: {msg}") from e
    raise

Prevention

When it happens

Trigger: POST {API_BASE}/music_generation with an invalid/disabled model name (e.g. a model not enabled for the account), an unsupported audio_setting combination (sample_rate/bitrate/format), prompt or lyrics exceeding char limits (prompt 2000, lyrics 3500), content-policy rejection of the lyrics, rate limiting, or account quota exhaustion.

Common situations: Using the overseas endpoint (api.minimax.io) with a China-mainland key or vice versa; requesting a model the account tier doesn't have access to; pasting lyrics with disallowed content; hitting a free-tier concurrency/quotat ceiling; sending is_instrumental together with lyrics the API rejects.

Related errors


AI-assisted analysis of MiniMax-AI/skills@60aaae52bb (2026-08-13). Data as JSON: /api/errors/6ec967acfb684b20. Report an issue: GitHub.