MiniMax-AI/skills · error · SystemExit
API Error [{code}]: {msg}
Error message
API Error [{code}]: {msg} What it means
Central response validator for the video API (_check_resp). After every successful HTTP call, it inspects base_resp.status_code; any non-zero value aborts via SystemExit with the API's code and message. Common codes: 1004 invalid/expired token, 1027 content moderation, 1xxx config/payload errors.
Source
Thrown at skills/gif-sticker-maker/scripts/minimax_video.py:63
"T2V-01",
]
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 _check_resp(data):
base_resp = data.get("base_resp", {})
code = base_resp.get("status_code", 0)
if code != 0:
msg = base_resp.get("status_msg", "Unknown error")
raise SystemExit(f"API Error [{code}]: {msg}")
def _encode_image(image_path: str) -> str:
"""Read local image file and return base64 data URI."""
ext = os.path.splitext(image_path)[1].lower().lstrip(".")
mime_map = {"jpg": "jpeg", "jpeg": "jpeg", "png": "png", "webp": "webp"}
mime = mime_map.get(ext, "png")
with open(image_path, "rb") as f:
raw = f.read()
return f"data:image/{mime};base64,{base64.b64encode(raw).decode()}"
def create_task(
prompt: str,
model: str = "MiniMax-Hailuo-2.3",
duration: int = 6,View on GitHub (pinned to 60aaae52bb)
Solutions
- Match the numeric code: 1004 -> re-authenticate/refresh key; 1027 -> content policy; 1xxx -> fix the payload.
- Verify the model is in T2V_MODELS or I2V_MODELS for the chosen mode.
- Check duration (6/10) and resolution (720P/768P/1080P) are valid for the model.
- Re-set MINIMAX_API_KEY if the code indicates an auth failure.
Example fix
# before
task_id = create_task(prompt=p, model='MiniMax-Hailuo-2.3') # SystemExit: API Error [1004]: ...
# after
try:
task_id = create_task(prompt=p, model='MiniMax-Hailuo-2.3')
except SystemExit as e:
raise RuntimeError(f'video API rejected request: {e}') from e Defensive patterns
Strategy: try-catch
Validate before calling
assert model in set(T2V_MODELS + I2V_MODELS), f'unknown model: {model}'
assert duration in (6, 10), 'duration must be 6 or 10'
assert resolution in ('720P','768P','1080P'), 'bad resolution' Try / catch
try:
task_id = create_task(...)
except SystemExit as e:
msg = str(e)
if 'API Error [1004]' in msg:
os.environ['MINIMAX_API_KEY'] = refresh_key()
else:
raise RuntimeError(msg) from e Prevention
- Treat base_resp.status_code (not HTTP status) as the real success signal.
- Whitelist model/duration/resolution values before calling create_task().
- Refresh tokens proactively for long-running sessions.
When it happens
Trigger: POST video_generation, GET query/video_generation, or GET files/retrieve returns base_resp.status_code != 0. E.g. invalid model name, expired token (1004), unsupported duration/resolution for the model, or content moderation on the prompt/image.
Common situations: Token expired mid-session; model not enabled for the account; duration/resolution pair unsupported by the chosen model; prompt or I2V first-frame tripped moderation; account suspended.
Related errors
- No task_id in response: {json.dumps(data, indent=2)}
- Video generation failed: {json.dumps(data, indent=2)}
- No download_url in response: {json.dumps(data, indent=2)}
- ERROR: MINIMAX_API_BASE is not set.
- ERROR: MINIMAX_API_KEY is not set. export MINIMAX_API_KEY=
AI-assisted analysis of MiniMax-AI/skills@60aaae52bb (2026-08-13).
Data as JSON: /api/errors/3327d537e58cea17.
Report an issue: GitHub.