{"record":{"id":"d22d047a4cec003c","repo":"Mintplex-Labs/anything-llm","slug":"minimax-chat-this-model-is-not-valid-for-chat","errorCode":null,"errorMessage":"Minimax chat: ${this.model} is not valid for chat completion!","messagePattern":"Minimax chat: (.+?) is not valid for chat completion!","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/minimax/index.js","lineNumber":84,"sourceCode":"    return models.data.some((model) => model.id === modelName);\n  }\n\n  constructPrompt({\n    systemPrompt = \"\",\n    contextTexts = [],\n    chatHistory = [],\n    userPrompt = \"\",\n  }) {\n    const prompt = {\n      role: \"system\",\n      content: `${systemPrompt}${this.#appendContext(contextTexts)}`,\n    };\n    return [prompt, ...chatHistory, { role: \"user\", content: userPrompt }];\n  }\n\n  async getChatCompletion(messages = null, { temperature = 0.7 }) {\n    if (!(await this.isValidChatCompletionModel(this.model)))\n      throw new Error(\n        `Minimax chat: ${this.model} is not valid for chat completion!`\n      );\n\n    const result = await LLMPerformanceMonitor.measureAsyncFunction(\n      this.openai.chat.completions\n        .create({\n          model: this.model,\n          messages,\n          temperature,\n        })\n        .catch((e) => {\n          throw new Error(e.message);\n        })\n    );\n\n    if (\n      !result?.output?.hasOwnProperty(\"choices\") ||\n      result?.output?.choices?.length === 0","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/minimax/index.js#L66-L102","documentation":"In getChatCompletion the provider awaits isValidChatCompletionModel(this.model), which checks the configured/default model against Minimax's known chat models. If this.model is not in that set, it throws before any network call. this.model defaults to process.env.MINIMAX_MODEL_PREF or 'MiniMax-M2.7'.","triggerScenarios":"Calling getChatCompletion when MINIMAX_MODEL_PREF (or the passed modelPreference) names a model not present in the resolved Minimax model list — e.g. a typo, an embedding-only model id, or a model Minimax has retired.","commonSituations":"Typo in the model name in .env; using an embedding model id for chat; Minimax renamed/deprecated the model and the cached model list in storage/models/minimax is stale; default model constant drifts from the live catalog.","solutions":["Confirm the exact model id against Minimax's current model documentation.","Delete the cached model list under storage/models/minimax so it re-fetches the live catalog.","Update MINIMAX_MODEL_PREF to a valid current chat model id.","Ensure the server has outbound network access when isValidChatCompletionModel fetches the catalog."],"exampleFix":"// before\nMINIMAX_MODEL_PREF=minimax-text-01   // retired / wrong id\n\n// after\nMINIMAX_MODEL_PREF=MiniMax-M2.7","handlingStrategy":"validation","validationCode":"// Validate model against the catalog before calling getChatCompletion\nconst valid = await llm.isValidChatCompletionModel(llm.model);\nif (!valid) {\n  throw new Error(`Model '${llm.model}' is not in the Minimax chat catalog — fix MINIMAX_MODEL_PREF.`);\n}","typeGuard":"function isKnownMinimaxModel(model, catalog) {\n  return typeof model === 'string' && model.length > 0 && catalog.includes(model);\n}","tryCatchPattern":"try {\n  await llm.getChatCompletion(messages, { temperature });\n} catch (e) {\n  if (/not valid for chat completion/i.test(e.message)) {\n    // reconfigure model, do not retry with the same id\n  }\n}","preventionTips":["Refresh the cached Minimax model list on a schedule so retirements surface early.","Treat model ids as config: validate them in admin UI before save.","Pin a known-good default model rather than chasing the newest id."],"tags":["minimax","model-validation","chat-completion","configuration"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}