{"record":{"id":"e3e914f73b0e2fe0","repo":"mem0ai/mem0","slug":"minimax-llm-failed-message","errorCode":null,"errorMessage":"MiniMax LLM failed: ${message}","messagePattern":"MiniMax LLM failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mem0-ts/src/oss/src/llms/minimax.ts","lineNumber":31,"sourceCode":"      apiKey,\n      baseURL:\n        config.baseURL ||\n        process.env.MINIMAX_API_BASE ||\n        \"https://api.minimax.io/v1\",\n      model: config.model || \"MiniMax-M2.7\",\n    });\n  }\n\n  async generateResponse(\n    messages: Message[],\n    responseFormat?: { type: string },\n    tools?: any[],\n  ): Promise<string | LLMResponse> {\n    try {\n      return await super.generateResponse(messages, responseFormat, tools);\n    } catch (err) {\n      const message = err instanceof Error ? err.message : String(err);\n      throw new Error(`MiniMax LLM failed: ${message}`);\n    }\n  }\n\n  async generateChat(messages: Message[]): Promise<LLMResponse> {\n    try {\n      return await super.generateChat(messages);\n    } catch (err) {\n      const message = err instanceof Error ? err.message : String(err);\n      throw new Error(`MiniMax LLM failed: ${message}`);\n    }\n  }\n}\n","sourceCodeStart":13,"sourceCodeEnd":44,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0-ts/src/oss/src/llms/minimax.ts#L13-L44","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the suffix: 401/1000-series auth codes → fix the key; quota/balance errors → top up; invalid model → correct the model string.","Confirm you are on the right endpoint for your account region: default https://api.minimax.io/v1 or override via MINIMAX_API_BASE.","Verify the key with a direct curl to /v1/models or /v1/chat/completions.","For transient network/limit errors, retry with exponential backoff."],"exampleFix":"// before\nawait minimaxLlm.generateResponse(messages, { type: 'json_object' });\n// MiniMax LLM failed: 401 invalid api key\n\n// after\nawait withRetry(\n  () => minimaxLlm.generateResponse(messages, { type: 'json_object' }),\n  { retries: 3, shouldRetry: (e) => !/401|quota/i.test(String(e)) },\n);","handlingStrategy":"retry","validationCode":"async function minimaxAuthed(base = 'https://api.minimax.io/v1', key = process.env.MINIMAX_API_KEY) {\n  const r = await fetch(`${base}/models`, { headers: { Authorization: `Bearer ${key}` } });\n  if (r.status === 401) throw new Error('MiniMax key rejected');\n  return r.ok;\n}","typeGuard":"const isMiniMaxFatal = (e: unknown): boolean =>\n  e instanceof Error && e.message.startsWith('MiniMax LLM failed:') && /401|quota|balance/i.test(e.message);","tryCatchPattern":"try {\n  return await minimaxLlm.generateResponse(messages, responseFormat);\n} catch (err) {\n  if (isMiniMaxFatal(err)) throw err;\n  if (/429|timeout|ECONN/i.test(String(err))) return withRetry(fn, { retries: 3 });\n  throw err;\n}","preventionTips":["Match the base URL to your account's region (international vs mainland endpoints differ).","Monitor credit balance — exhausted balance is a common fatal suffix.","Pin the current model id from MiniMax docs."],"tags":["minimax","llm","network","api-key","typescript"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}