MiniMax-AI/skills · critical · SystemExit
ERROR: MINIMAX_API_KEY is not set. export MINIMAX_API_KEY=
Error message
ERROR: MINIMAX_API_KEY is not set. export MINIMAX_API_KEY='your-key'
What it means
`raise SystemExit("ERROR: MINIMAX_API_KEY is not set...\n export MINIMAX_API_KEY='your-key'")` inside `_headers()` of `minimax_image.py`. Unlike the base-URL check (which runs at import), the API key check is deferred until `_headers()` is first called — i.e. when a request is actually made. This lets the module import without a key but blocks any real call. The message includes the exact export command.
Source
Thrown at skills/frontend-dev/scripts/minimax_image.py:32
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,
response_format: str = "url",
prompt_optimizer: bool = False,
seed: int = None,
) -> dict:
"""Generate image(s). Returns API response dict."""
payload = {
"model": model,View on GitHub (pinned to 60aaae52bb)
Solutions
- Export the key: `export MINIMAX_API_KEY='your-key'` (use a real key from the MiniMax console), then rerun.
- Persist it in your shell profile or a sourced `.env` so new sessions keep it.
- Verify with `printenv MINIMAX_API_KEY` that the value is present and non-empty.
Example fix
# before export MINIMAX_API_BASE='https://api.minimax.io/v1' # base set, key missing python minimax_image.py "cat" -o cat.png # SystemExit on key # after export MINIMAX_API_KEY='your-real-key' python minimax_image.py "cat" -o cat.png
Defensive patterns
Strategy: validation
Validate before calling
import os, sys
API_KEY = os.getenv("MINIMAX_API_KEY")
if not API_KEY or len(API_KEY) < 16:
print("ERROR: MINIMAX_API_KEY missing or too short. export MINIMAX_API_KEY='your-key'", file=sys.stderr)
sys.exit(2) Type guard
def _has_key() -> bool:
k = os.getenv("MINIMAX_API_KEY")
return isinstance(k, str) and len(k) >= 16 Prevention
- Store secrets in a password manager or secret backend, not loose in shell history.
- Add the key to a sourced `.env` (chmod 600) so new sessions keep it.
- Validate the key length/format before the first request for a clearer message.
- Keep base URL and key region-aligned (overseas key + overseas base URL).
When it happens
Trigger: Calling `generate_image(...)` (which calls `_headers()`) when `MINIMAX_API_KEY` is unset or empty. The base URL may already be set; the key specifically is missing.
Common situations: Base URL is configured but the key was never exported, the key variable was misspelled, or a new shell/session lost the export. Also when the key is set to an empty string.
Related errors
- ERROR: MINIMAX_API_BASE is not set.
- ERROR: MINIMAX_API_BASE is not set.
- API Error [{base_resp.get('status_code')}]: {base_resp.get('
- ERROR: MINIMAX_API_KEY is not set. export MINIMAX_API_KEY=
- ERROR: MINIMAX_API_BASE is not set.
AI-assisted analysis of MiniMax-AI/skills@60aaae52bb (2026-08-13).
Data as JSON: /api/errors/aec0cac8c3c6c901.
Report an issue: GitHub.