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

Raised as SystemExit after POST {API_BASE}/image_generation returns HTTP 200 but the body's base_resp.status_code is non-zero. MiniMax signals application-level failures (content moderation, invalid parameters, quota) through this nested field instead of an HTTP error, so resp.raise_for_status() does not catch them. The script surfaces the API's own status_code and status_msg so the CLI halts immediately.

Source

Thrown at skills/gif-sticker-maker/scripts/minimax_image.py:85

        "prompt_optimizer": prompt_optimizer,
    }
    if seed is not None:
        payload["seed"] = seed
    if subject_reference:
        payload["subject_reference"] = subject_reference

    resp = requests.post(
        f"{API_BASE}/image_generation",
        headers=_headers(),
        json=payload,
        timeout=120,
    )
    resp.raise_for_status()
    data = resp.json()

    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')}")

    return data


def download_and_save(url: str, output_path: str):
    """Download image from URL and save."""
    resp = requests.get(url, timeout=60)
    resp.raise_for_status()
    with open(output_path, "wb") as f:
        f.write(resp.content)
    return len(resp.content)


def main():
    p = argparse.ArgumentParser(description="MiniMax Text-to-Image")
    p.add_argument("prompt", help="Image description (max 1500 chars)")
    p.add_argument("-o", "--output", required=True, help="Output file path (.png/.jpg)")
    p.add_argument("--model", default="image-01", help="Model (default: image-01)")

View on GitHub (pinned to 60aaae52bb)

Solutions

  1. Read status_msg verbatim — it is the API's own reason for the rejection.
  2. Shorten/sanitize the prompt to stay under 1500 chars and avoid flagged terms.
  3. Confirm aspect_ratio is in ASPECT_RATIOS and model is valid (default image-01).
  4. Check the MiniMax console for remaining image-generation quota and billing.
  5. If rate-limited, add backoff between successive generate_image() calls.

Example fix

# before
result = generate_image(prompt=p, aspect_ratio='21:9')  # raises SystemExit on API soft-error

# after
try:
    result = generate_image(prompt=p, aspect_ratio='21:9')
except SystemExit as e:
    print(f'image generation failed: {e}', file=sys.stderr)
    sys.exit(1)
Defensive patterns

Strategy: try-catch

Validate before calling

VALID_RATIOS = {'1:1','16:9','4:3','3:2','2:3','3:4','9:16','21:9'}
if aspect_ratio not in VALID_RATIOS:
    raise ValueError(f'aspect_ratio must be one of {sorted(VALID_RATIOS)}')
if not prompt or len(prompt) > 1500:
    raise ValueError('prompt must be 1-1500 chars')

Try / catch

try:
    result = generate_image(prompt=p, aspect_ratio=r)
except SystemExit as e:
    # MiniMax scripts abort via SystemExit on API soft-errors
    raise RuntimeError(f'image generation failed: {e}') from e

Prevention

When it happens

Trigger: POST /image_generation returns JSON where base_resp.status_code != 0. Typical: prompt violates content policy, aspect_ratio is not in [1:1,16:9,4:3,3:2,2:3,3:4,9:16,21:9], prompt exceeds 1500 chars, model name is invalid/default-mismatched, or the account has no image-generation quota left.

Common situations: Account out of credits; prompt contains policy-flagged terms; passing a model name copied from docs that differs from the default 'image-01'; custom aspect_ratio string the API rejects; concurrent requests tripping a soft rate limit.

Related errors


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