mem0ai/mem0 · error · Error

MiniMax LLM failed: ${message}

Error message

MiniMax LLM failed: ${message}

What it means

Thrown by MiniMaxLLM.generateResponse when the underlying call to MiniMax's OpenAI-compatible endpoint (default https://api.minimax.io/v1) fails. The suffix after 'MiniMax LLM failed:' is the MiniMax API's own error text — auth, quota, invalid model, or a network failure.

Source

Thrown at mem0-ts/src/oss/src/llms/minimax.ts:31

      apiKey,
      baseURL:
        config.baseURL ||
        process.env.MINIMAX_API_BASE ||
        "https://api.minimax.io/v1",
      model: config.model || "MiniMax-M2.7",
    });
  }

  async generateResponse(
    messages: Message[],
    responseFormat?: { type: string },
    tools?: any[],
  ): Promise<string | LLMResponse> {
    try {
      return await super.generateResponse(messages, responseFormat, tools);
    } catch (err) {
      const message = err instanceof Error ? err.message : String(err);
      throw new Error(`MiniMax LLM failed: ${message}`);
    }
  }

  async generateChat(messages: Message[]): Promise<LLMResponse> {
    try {
      return await super.generateChat(messages);
    } catch (err) {
      const message = err instanceof Error ? err.message : String(err);
      throw new Error(`MiniMax LLM failed: ${message}`);
    }
  }
}

View on GitHub (pinned to 001c235229)

Solutions

  1. Read the suffix: 401/1000-series auth codes → fix the key; quota/balance errors → top up; invalid model → correct the model string.
  2. Confirm you are on the right endpoint for your account region: default https://api.minimax.io/v1 or override via MINIMAX_API_BASE.
  3. Verify the key with a direct curl to /v1/models or /v1/chat/completions.
  4. For transient network/limit errors, retry with exponential backoff.

Example fix

// before
await minimaxLlm.generateResponse(messages, { type: 'json_object' });
// MiniMax LLM failed: 401 invalid api key

// after
await withRetry(
  () => minimaxLlm.generateResponse(messages, { type: 'json_object' }),
  { retries: 3, shouldRetry: (e) => !/401|quota/i.test(String(e)) },
);
Defensive patterns

Strategy: retry

Validate before calling

async function minimaxAuthed(base = 'https://api.minimax.io/v1', key = process.env.MINIMAX_API_KEY) {
  const r = await fetch(`${base}/models`, { headers: { Authorization: `Bearer ${key}` } });
  if (r.status === 401) throw new Error('MiniMax key rejected');
  return r.ok;
}

Type guard

const isMiniMaxFatal = (e: unknown): boolean =>
  e instanceof Error && e.message.startsWith('MiniMax LLM failed:') && /401|quota|balance/i.test(e.message);

Try / catch

try {
  return await minimaxLlm.generateResponse(messages, responseFormat);
} catch (err) {
  if (isMiniMaxFatal(err)) throw err;
  if (/429|timeout|ECONN/i.test(String(err))) return withRetry(fn, { retries: 3 });
  throw err;
}

Prevention

When it happens

Trigger: Calling generateResponse() with an invalid/expired MiniMax key (401), exhausted quota/balance, a wrong model identifier (default 'MiniMax-M2.7'), an unsupported responseFormat for the chosen model, or when api.minimax.io (or a custom MINIMAX_API_BASE) is unreachable from the runtime.

Common situations: Using a mainland-China endpoint key against the international API or vice versa (base URL mismatch); trial credits exhausted; model renamed/deprecated on the MiniMax side; regional network blocks to api.minimax.io; custom proxy baseURL returning non-OpenAI error shapes.

Related errors


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/e3e914f73b0e2fe0. Report an issue: GitHub.