{"record":{"id":"9bacafd75db0bba9","repo":"Mintplex-Labs/anything-llm","slug":"no-minimax-api-key-was-set","errorCode":null,"errorMessage":"No Minimax API key was set.","messagePattern":"No Minimax API key was set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/AiProviders/minimax/index.js","lineNumber":14,"sourceCode":"const { NativeEmbedder } = require(\"../../EmbeddingEngines/native\");\nconst {\n  LLMPerformanceMonitor,\n} = require(\"../../helpers/chat/LLMPerformanceMonitor\");\nconst {\n  handleDefaultStreamResponseV2,\n} = require(\"../../helpers/chat/responses\");\nconst { MODEL_MAP } = require(\"../modelMap\");\n\nclass MinimaxLLM {\n  constructor(embedder = null, modelPreference = null) {\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n    if (!process.env.MINIMAX_API_KEY)\n      throw new Error(\"No Minimax API key was set.\");\n    this.className = \"MinimaxLLM\";\n\n    this.openai = new OpenAIApi({\n      baseURL: \"https://api.minimax.io/v1\",\n      apiKey: process.env.MINIMAX_API_KEY,\n    });\n    this.model =\n      modelPreference || process.env.MINIMAX_MODEL_PREF || \"MiniMax-M2.7\";\n    this.limits = {\n      history: this.promptWindowLimit() * 0.15,\n      system: this.promptWindowLimit() * 0.15,\n      user: this.promptWindowLimit() * 0.7,\n    };\n\n    this.embedder = embedder ?? new NativeEmbedder();\n    this.defaultTemp = 0.7;\n    this.log(\n      `Initialized ${this.model} with context window ${this.promptWindowLimit()}`","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/minimax/index.js#L1-L32","documentation":"Thrown synchronously in the MinimaxLLM constructor when process.env.MINIMAX_API_KEY is falsy. The provider needs the key to build its OpenAI-compatible client pointed at https://api.minimax.io/v1, so without it the adapter cannot be instantiated at all. This is a hard gate at construction time, not at request time.","triggerScenarios":"Instantiating `new MinimaxLLM(embedder, modelPreference)` (AnythingLLM's provider factory does this when Minimax is the selected LLM) while MINIMAX_API_KEY is unset, empty, or whitespace-only in the process environment.","commonSituations":"Fresh deploy without the env var set; .env file not loaded by the Node process; typo such as MINIMAX_KEY or MINIMAX_APIKEY; switching the workspace's LLM provider to Minimax without configuring credentials; CI/container missing the secret.","solutions":["Set MINIMAX_API_KEY in server/.env (or your runtime env) to a valid key from the Minimax console.","Restart the AnythingLLM server process so it re-reads .env.","Verify from a Node REPL that process.env.MINIMAX_API_KEY is non-empty before selecting the provider.","If using Docker/k8s, confirm the env var is injected into the container, not just the host."],"exampleFix":"// before\n// MINIMAX_API_KEY is unset -> new MinimaxLLM() throws\n\n// after (server/.env)\nMINIMAX_API_KEY=your_key_here\nMINIMAX_MODEL_PREF=MiniMax-M2.7","handlingStrategy":"validation","validationCode":"// Before selecting/instantiating the Minimax provider\nif (!process.env.MINIMAX_API_KEY) {\n  throw new Error('MINIMAX_API_KEY missing — configure it before enabling Minimax.');\n}","typeGuard":null,"tryCatchPattern":"// Constructor throws synchronously; catch at the provider factory\ntry {\n  const llm = new MinimaxLLM(embedder, modelPref);\n} catch (e) {\n  if (/No Minimax API key/i.test(e.message)) {\n    // surface a config error to the user, do not retry\n  }\n}","preventionTips":["Centralize env-var validation in the provider factory so missing keys never reach constructors.","Add a startup health check that asserts all configured-provider keys are present.","Keep provider selection and credential config in the same admin screen to avoid drift."],"tags":["minimax","configuration","api-key","env","constructor"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}