jackwener/OpenCLI · error · CommandExecutionError

Suno API: insufficient credits (HTTP 402). ${detail}

Error message

Suno API: insufficient credits (HTTP 402). ${detail}

What it means

When Suno's generate API answers HTTP 402, the account lacks generation credits; submitSunoGeneration converts that into CommandExecutionError('Suno API: insufficient credits (HTTP 402). <detail>'). `detail` comes from the API's body.detail, raw body, or a truncated JSON dump, often naming the credit type needed.

Source

Thrown at clis/suno/utils.js:335

        const res = await fetch('${STUDIO_API}/api/generate/v2-web/', {
            method: 'POST',
            headers: ${sunoHeadersJs(deviceId, { 'Content-Type': 'application/json' })},
            body: ${JSON.stringify(bodyJson)},
        });
        const text = await res.text();
        let parsed = null;
        try { parsed = JSON.parse(text); } catch {}
        return { status: res.status, ok: res.ok, body: parsed, raw: parsed ? null : text.slice(0, 600) };
    })()`));

    if (!result || !result.ok) {
        const status = result?.status || 'unknown';
        const detail = result?.body?.detail || result?.raw || JSON.stringify(result?.body || {}).slice(0, 500);
        if (status === 401 || status === 403) {
            throw new AuthRequiredError(SUNO_DOMAIN, `Suno API rejected request (HTTP ${status}). Re-login on suno.com.`);
        }
        if (status === 402) {
            throw new CommandExecutionError(`Suno API: insufficient credits (HTTP 402). ${detail}`);
        }
        throw new CommandExecutionError(`Suno generate failed (HTTP ${status}): ${detail}`);
    }

    if (!result.body || typeof result.body !== 'object' || Array.isArray(result.body)) {
        throw new CommandExecutionError('Suno generate returned malformed JSON payload.');
    }
    const clips = result.body?.clips || [];
    if (!clips.length) {
        throw new EmptyResultError('suno generate', `Submission accepted but Suno returned no clip ids. Raw: ${JSON.stringify(result.body).slice(0, 300)}`);
    }
    return result.body;
}

// ─────────────────────────────────────────────────────────────────────────────
// Poll /api/feed/v3 (cookie auth, no Bearer).
// ─────────────────────────────────────────────────────────────────────────────

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Wait for credit refresh (daily/monthly reset) or upgrade your Suno subscription to get more credits.
  2. Switch to a cheaper model version via the model option (e.g. chirp-v4 instead of chirp-fenix) if your credits tier allows it.
  3. Check the detail suffix in the message — it usually names which credit balance is short.
  4. Verify the right account is signed in; you may be hitting an account with no credits.

Example fix

// before
opencli suno generate --prompt "song" --model chirp-fenix   // HTTP 402
// after (use a model your credits cover, or top up at suno.com)
opencli suno generate --prompt "song" --model chirp-v4
Defensive patterns

Strategy: try-catch

Validate before calling

// Check credit state via a cheap feed/session call before generating
const session = await ensureSunoSession(page, deviceId);
if (!session.ok || session.credits === 0) throw new Error('No Suno credits — top up at suno.com');

Type guard

function isInsufficientCreditsError(err) {
  return err && /insufficient credits \(HTTP 402\)/.test(err.message || '');
}

Try / catch

try {
  await submitSunoGeneration(page, params);
} catch (err) {
  if (isInsufficientCreditsError(err)) {
    console.error('Out of credits: top up at suno.com or wait for reset.');
  } else throw err;
}

Prevention

When it happens

Trigger: Submitting a generation request when the signed-in Suno account has run out of monthly/c subscription credits (or the required credit tier for the requested model, e.g. V5.5), so the API returns 402 Payment Required.

Common situations: Free-tier daily credits exhausted; end of monthly billing cycle; attempting an expensive model generation with only basic credits; shared account where a teammate consumed the credits.

Understand the failure class

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/e35f7d2839ecf21a. Report an issue: GitHub.