{"record":{"id":"7416851df558546d","repo":"Mintplex-Labs/anything-llm","slug":"minimax-stream-this-model-is-not-valid-for-cha","errorCode":null,"errorMessage":"Minimax stream: ${this.model} is not valid for chat completion!","messagePattern":"Minimax stream: (.+?) is not valid for chat completion!","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/minimax/index.js","lineNumber":125,"sourceCode":"\n    return {\n      textResponse: result.output.choices[0].message.content,\n      metrics: {\n        prompt_tokens: result.output.usage.prompt_tokens || 0,\n        completion_tokens: result.output.usage.completion_tokens || 0,\n        total_tokens: result.output.usage.total_tokens || 0,\n        outputTps: result.output.usage.completion_tokens / result.duration,\n        duration: result.duration,\n        model: this.model,\n        provider: this.className,\n        timestamp: new Date(),\n      },\n    };\n  }\n\n  async streamGetChatCompletion(messages = null, { temperature = 0.7 }) {\n    if (!(await this.isValidChatCompletionModel(this.model)))\n      throw new Error(\n        `Minimax stream: ${this.model} is not valid for chat completion!`\n      );\n\n    const measuredStreamRequest = await LLMPerformanceMonitor.measureStream({\n      func: this.openai.chat.completions.create({\n        model: this.model,\n        stream: true,\n        messages,\n        temperature,\n      }),\n      messages,\n      runPromptTokenCalculation: false,\n      modelTag: this.model,\n      provider: this.className,\n    });\n\n    return measuredStreamRequest;\n  }","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/AiProviders/minimax/index.js#L107-L143","documentation":"Streaming guard in MinimaxLLM.streamGetChatCompletion(): before opening the stream it validates this.model via isValidChatCompletionModel, which calls GET /v1/models on api.minimax.io and checks id membership. A model id absent from the list — or a failed listing request (silently caught into an empty list) — makes the check false and this error is thrown.","triggerScenarios":"Starting a streaming chat with MINIMAX_MODEL_PREF or a UI-selected model id that api.minimax.io/v1/models does not return; a revoked/expired API key making models.list() fail; a renamed or deprecated MiniMax model id still stored as the preference.","commonSituations":"Vendor model renames leaving stale stored ids; hardcoding model names; egress rules blocking the models endpoint so the list comes back empty.","solutions":["Run curl -H 'Authorization: Bearer $MINIMAX_API_KEY' https://api.minimax.io/v1/models and set MINIMAX_MODEL_PREF to a listed id","Re-select the model from the AnythingLLM UI dropdown","Verify the API key is valid — a failing models.list() is indistinguishable from an invalid model","Restart the server after .env changes"],"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.streamGetChatCompletion(messages);\n} catch (e) {\n  if (/Minimax stream: .* is not valid/.test(e.message)) {\n    // config error: fix model id or API key, then restart the stream\n  }\n  throw e;\n}","preventionTips":["Validate the model id before opening a stream (streams fail late otherwise)","Pick model ids from the UI dropdown backed by /v1/models","Watch for vendor model deprecations and update stored preferences"],"tags":["minimax","anythingllm","model-validation","streaming","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"}