{"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":null,"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/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/AiProviders/minimax/index.js#L66-L102","documentation":"MinimaxLLM.getChatCompletion validates this.model by calling the MiniMax OpenAI-compatible GET /v1/models endpoint (openai.models.list()) and checking whether the id appears in the list. If the id is absent — or the listing call itself failed — isValidChatCompletionModel returns false and this error is thrown before any completion request is sent.","triggerScenarios":"MINIMAX_MODEL_PREF (or a workspace-selected model) is not an id returned by https://api.minimax.io/v1/models, e.g. a renamed/deprecated id; or the models.list() call fails (revoked key, network block) and the .catch(() => ({ data: [] })) turns the failure into an empty list, which is indistinguishable from an invalid model.","commonSituations":"MiniMax renames or retires model ids (e.g. old abab-* ids vs MiniMax-M2.7) while the stored preference still uses the old name; hardcoding model ids from blog posts; a deactivated API key making models.list() fail silently.","solutions":["List valid ids with your key: curl -H 'Authorization: Bearer $MINIMAX_API_KEY' https://api.minimax.io/v1/models — then set MINIMAX_MODEL_PREF to one of them","Re-pick the model from the AnythingLLM UI dropdown so the current id is stored","Verify the API key is active — a bad key makes models.list() fail and looks exactly like an invalid model","Restart the server after changing MINIMAX_MODEL_PREF in .env"],"exampleFix":"# before\nMINIMAX_MODEL_PREF=abab6.5s-chat\n# after\nMINIMAX_MODEL_PREF=MiniMax-M2.7","handlingStrategy":"validation","validationCode":"const models = await llm.openai.models.list().catch(() => ({ data: [] }));\nconst ok = models.data.some((m) => m.id === llm.model);\nif (!ok)\n  throw new Error(`Model ${llm.model} not in MiniMax model list — check key and model id`);","typeGuard":null,"tryCatchPattern":"try {\n  await llm.getChatCompletion(messages);\n} catch (e) {\n  if (/Minimax chat: .* is not valid/.test(e.message)) {\n    // treat as config error: verify model id AND key (both produce this)\n  }\n  throw e;\n}","preventionTips":["Select models from the UI dropdown instead of typing ids","Remember a failing models.list() (bad key/network) looks identical to an invalid model","Re-validate stored model ids when the vendor ships model renames","Cache the models.list() result briefly to avoid an extra call per chat"],"tags":["minimax","anythingllm","model-validation","chat-completion"],"backgroundTag":"invalid-model-id","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}