{"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":null,"httpStatus":null,"severity":"error","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/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/AiProviders/minimax/index.js#L1-L32","documentation":"MinimaxLLM's constructor throws immediately when process.env.MINIMAX_API_KEY is falsy, before the OpenAI-compatible client for https://api.minimax.io/v1 is even built. Any code path that instantiates the provider (selecting MiniMax as the LLM provider, starting a chat, or constructing providers programmatically) fails until the key is set.","triggerScenarios":"Selecting MiniMax as the workspace or system LLM provider while MINIMAX_API_KEY is unset, misspelled, or empty; editing .env without restarting the process; Docker deployments where the variable was never passed into the container.","commonSituations":"Typo'd variable name (MINIMAX_KEY, MINIMAX_APIKEY); .env edited but server not restarted; docker-compose environment section missing the var; test/CI environments that never had the key.","solutions":["Add MINIMAX_API_KEY=<key from the MiniMax platform console> to the server's .env","Restart the AnythingLLM server or container so the variable is loaded","If using Docker, confirm the variable is present in the container (check the name only, never print the value): docker exec <container> printenv | grep -c MINIMAX_API_KEY","Check for typos and stray whitespace in the variable name and value"],"exampleFix":"# before\n# (MINIMAX_API_KEY not set)\n# after\nMINIMAX_API_KEY=eyJhbGciOi...your-key","handlingStrategy":"validation","validationCode":"if (!process.env.MINIMAX_API_KEY)\n  throw new Error('MiniMax provider selected but MINIMAX_API_KEY is not configured');\nconst llm = new MinimaxLLM(embedder);","typeGuard":null,"tryCatchPattern":"try {\n  const llm = new MinimaxLLM(embedder);\n} catch (e) {\n  if (e.message === 'No Minimax API key was set.')\n    return respondConfigError(e); // stop, configure the key, restart\n  throw e;\n}","preventionTips":["Set provider API keys before selecting that provider in the UI","Restart the server after every .env change","Pass env vars explicitly in Docker (-e or --env-file)","Fail fast at startup when the configured provider lacks its key"],"tags":["minimax","anythingllm","api-key","environment-variables","configuration"],"backgroundTag":"missing-api-key","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"}