jackwener/OpenCLI · error · CommandExecutionError

No Midjourney generation credits remain for this billing per

Error message

No Midjourney generation credits remain for this billing period.

What it means

assertGenerationEntitlement computes remaining credits from total_credits ?? credits_total and throws CommandExecutionError when no credits remain and abilities.can_relax is falsy. It prevents wasting API calls on jobs that would be rejected for exhausted fast-generation quota.

Source

Thrown at clis/midjourney/utils.js:308

  if (!account || typeof account !== 'object' || Array.isArray(account)) {
    throw new CommandExecutionError('Midjourney subscription endpoint returned a malformed payload');
  }
  if (!account.user_id) {
    throw new AuthRequiredError(MIDJOURNEY_DOMAIN, 'Log into Midjourney in Chrome, then retry.');
  }
  return account;
}

export function assertGenerationEntitlement(account) {
  if (account.status !== 'active' || !account.plan?.type) {
    throw new CommandExecutionError(
      'Midjourney generation requires an active subscription.',
      `Check the account at ${MIDJOURNEY_URL}/account.`,
    );
  }
  const remaining = Number(account.total_credits ?? account.credits_total ?? 0);
  if (!(remaining > 0) && !account.abilities?.can_relax) {
    throw new CommandExecutionError(
      'No Midjourney generation credits remain for this billing period.',
      `Check usage at ${MIDJOURNEY_URL}/account.`,
    );
  }
}

export async function fetchHistory(page, userId, limit = 20) {
  return (await fetchHistoryPage(page, userId, limit)).data;
}

export async function fetchHistoryPage(page, userId, limit = 20, cursor = null) {
  const cursorQuery = cursor ? `&cursor=${encodeURIComponent(cursor)}` : '';
  const payload = await midjourneyJson(
    page,
    `/api/imagine?user_id=${encodeURIComponent(userId)}&page_size=${encodeURIComponent(limit)}${cursorQuery}`,
  );
  if (!payload || typeof payload !== 'object' || !Array.isArray(payload.data)) {
    throw new CommandExecutionError('Midjourney history endpoint returned a malformed payload');

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Wait for the billing period to reset fast hours, or subscribe to a higher tier.
  2. Enable relax mode if the plan supports it (can_relax) to keep generating at lower priority.
  3. Check usage at midjourney.com/account to confirm remaining credits.
  4. If credits are visibly remaining but the error fires, the CLI's credit field names may be stale — update the library.

Example fix

// before
await assertGenerationEntitlement(account); // throws when fast hours gone
// after
const remaining = Number(account.total_credits ?? account.credits_total ?? 0);
if (remaining <= 0 && account.abilities?.can_relax) {
  await submitImagine(prompt, { mode: 'relax' }); // use relax instead
} else {
  await assertGenerationEntitlement(account);
}
Defensive patterns

Strategy: fallback

Validate before calling

const account = await getMidjourneyAccount(page);
const remaining = Number(account.total_credits ?? account.credits_total ?? 0);
const canRelax = Boolean(account.abilities?.can_relax);
if (!(remaining > 0) && !canRelax) console.error('No fast credits and no relax mode — wait for reset or upgrade.');

Type guard

function hasGenerationBudget(account) {
  const remaining = Number(account?.total_credits ?? account?.credits_total ?? 0);
  return remaining > 0 || Boolean(account?.abilities?.can_relax);
}

Try / catch

try {
  assertGenerationEntitlement(account);
} catch (err) {
  if (/No Midjourney generation credits remain/.test(err.message)) {
    console.error('Fast hours exhausted; wait for reset or enable relax mode.');
  } else throw err;
}

Prevention

When it happens

Trigger: Number(account.total_credits ?? account.credits_total ?? 0) is not > 0 AND account.abilities?.can_relax is not truthy — fast hours fully consumed with no relax-mode fallback available on the plan.

Common situations: Heavy usage drained fast GPU hours before the monthly reset, basic plan without relax mode, or a plan change resetting credit fields mid-cycle.

Related errors


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