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_image.py`. `MINIMAX_API_BASE` (the API origin, e.g. `https://api.minimax.io/v1` for overseas or `https://api.minimaxi.com/v1` for China mainland) is read at import time; if unset the script aborts immediately because every request URL is built from it. `SystemExit` exits with a non-zero code rather than raising a traceback.

Source

Thrown at skills/frontend-dev/scripts/minimax_image.py:25

  python minimax_image.py "A cat in space" -o cat.png
  python minimax_image.py "Mountain landscape" -o bg.png --ratio 16:9
  python minimax_image.py "Product icons" -o icons.png -n 4 --ratio 1:1

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.")

ASPECT_RATIOS = ["1:1", "16:9", "4:3", "3:2", "2:3", "3:4", "9:16", "21:9"]


def _headers():
    if not API_KEY:
        raise SystemExit("ERROR: MINIMAX_API_KEY is not set.\n  export MINIMAX_API_KEY='your-key'")
    return {
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "application/json",
    }


def generate_image(
    prompt: str,
    model: str = "image-01",
    aspect_ratio: str = "1:1",
    n: int = 1,

View on GitHub (pinned to 60aaae52bb)

Solutions

  1. 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).
  2. Add it to your shell profile (`~/.bashrc`/`.zshrc`) or a `.env` file you source before running.
  3. Confirm with `printenv MINIMAX_API_BASE` that it is set in the active shell (child processes inherit only exported vars).

Example fix

# before — env not set
python minimax_image.py "cat" -o cat.png  # SystemExit

# after
export MINIMAX_API_BASE='https://api.minimax.io/v1'
export MINIMAX_API_KEY='your-key'
python minimax_image.py "cat" -o cat.png
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

When it happens

Trigger: Importing or running the script in a shell where `MINIMAX_API_BASE` was never exported. The check runs at top-level module code, so even `import minimax_image` triggers it.

Common situations: New machine/container without the env set, forgetting to source the env file, or a typo in the variable name. Note the key is `MINIMAX_API_BASE` (the base URL), distinct from `MINIMAX_API_KEY`.

Related errors


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