jackwener/OpenCLI · error · AuthRequiredError
MiniMax ${region.host} rejected ${MINIMAX_API_KEY_VAR} (serv
Error message
MiniMax ${region.host} rejected ${MINIMAX_API_KEY_VAR} (service ${base.status_code}${message}). What it means
An AuthRequiredError thrown by parseCompletedMusic() when the response body reports a service-level auth failure: base_resp.status_code is 1004 or 2049 (the AUTH_CODES set). Even though HTTP status was 2xx, MiniMax rejected the API key at the application layer, so the library demands a valid key for the region.
Source
Thrown at clis/minimax/utils.js:95
} catch (error) {
throw new CommandExecutionError(`MiniMax music returned malformed JSON: ${error?.message ?? error}`);
}
}
export function parseCompletedMusic(payload, region) {
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
throw new CommandExecutionError('MiniMax music returned a malformed response envelope');
}
const base = payload.base_resp;
if (!base || typeof base !== 'object' || !Number.isInteger(base.status_code)) {
throw new CommandExecutionError('MiniMax music response is missing integer base_resp.status_code');
}
if (base.status_code !== 0) {
const message = typeof base.status_msg === 'string' && base.status_msg.trim()
? `: ${base.status_msg.trim()}`
: '';
if (AUTH_CODES.has(base.status_code)) {
throw new AuthRequiredError(region.host, `MiniMax ${region.host} rejected ${MINIMAX_API_KEY_VAR} (service ${base.status_code}${message}).`);
}
throw new CommandExecutionError(`MiniMax music failed (service ${base.status_code}${message})`);
}
const data = payload.data;
if (!data || typeof data !== 'object' || Array.isArray(data) || !Number.isInteger(data.status)) {
throw new CommandExecutionError('MiniMax music response is missing integer data.status');
}
if (data.status === 1) {
const traceId = typeof payload.trace_id === 'string' && /^[A-Za-z0-9_-]{1,128}$/.test(payload.trace_id.trim())
? payload.trace_id.trim()
: '';
throw new CommandExecutionError(
`MiniMax music returned status 1 (in progress) without a resumable task id${traceId ? ` (trace_id: ${traceId})` : ''}`,
'Do not resubmit blindly: this endpoint exposes no query command, so check MiniMax account history first.',
);
}
if (data.status !== 2) {
throw new CommandExecutionError(`MiniMax music returned unknown data.status ${data.status}`);View on GitHub (pinned to 49907e53dc)
Solutions
- Regenerate a valid API key for the correct region in the MiniMax console and re-export MINIMAX_API_KEY.
- If status_code is 2049, top up or verify your MiniMax account balance/quota for the music product.
- Match the region: ensure the key belongs to the host in use (api.minimax.io vs api.minimaxi.com).
- Re-run and inspect the appended status_msg for the exact rejection reason.
Example fix
// before // service 2049: balance exhausted minimax music --prompt "ambient" // after topping up / reissuing key export MINIMAX_API_KEY="<new-key>" minimax music --prompt "ambient"
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check balance/quota in console or via account API before long jobs
// and ensure key matches region host
const key = process.env.MINIMAX_API_KEY ?? '';
if (!key.trim()) throw new Error('Export MINIMAX_API_KEY for the selected region'); Try / catch
try {
const done = parseCompletedMusic(payload, region);
} catch (e) {
if (e instanceof AuthRequiredError) {
console.error(`Service-level auth rejection from ${e.host}: reissue key or top up balance.`);
process.exitCode = 2;
} else throw e;
} Prevention
- Monitor MiniMax account balance before batch generation runs.
- Keep keys fresh and region-matched to the host being called.
- Treat codes 1004/2049 as credential/billing signals, not transient errors.
- Rotate and re-export keys promptly after revocation.
When it happens
Trigger: The music_generation endpoint returns HTTP 200 with base_resp.status_code 1004 (invalid/missing API key) or 2049 (insufficient balance/quota auth rejection), with an optional status_msg appended to the message.
Common situations: Expired or revoked key still exported in the environment; cn-region key used against the global host or vice versa; account balance exhausted (2049 commonly indicates billing/quota); key without music product entitlement.
Related errors
- MiniMax ${region.host} rejected ${MINIMAX_API_KEY_VAR} (HTTP
- WEREAD_API_KEY rejected (errcode=${errcode}, ${errmsg}). Reg
- 请先在共享 Chrome 完成 1688 登录/验证,再重试(${action})
- 1point3acres Discuz *_auth cookie missing
- 需要登录一亩三分地后再使用该命令
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/23d51658f7945d6c.
Report an issue: GitHub.