Mintplex-Labs/anything-llm · critical · Error

No Minimax API key was set.

Error message

No Minimax API key was set.

What it means

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.

Source

Thrown at server/utils/AiProviders/minimax/index.js:14

const { NativeEmbedder } = require("../../EmbeddingEngines/native");
const {
  LLMPerformanceMonitor,
} = require("../../helpers/chat/LLMPerformanceMonitor");
const {
  handleDefaultStreamResponseV2,
} = require("../../helpers/chat/responses");
const { MODEL_MAP } = require("../modelMap");

class MinimaxLLM {
  constructor(embedder = null, modelPreference = null) {
    const { OpenAI: OpenAIApi } = require("openai");
    if (!process.env.MINIMAX_API_KEY)
      throw new Error("No Minimax API key was set.");
    this.className = "MinimaxLLM";

    this.openai = new OpenAIApi({
      baseURL: "https://api.minimax.io/v1",
      apiKey: process.env.MINIMAX_API_KEY,
    });
    this.model =
      modelPreference || process.env.MINIMAX_MODEL_PREF || "MiniMax-M2.7";
    this.limits = {
      history: this.promptWindowLimit() * 0.15,
      system: this.promptWindowLimit() * 0.15,
      user: this.promptWindowLimit() * 0.7,
    };

    this.embedder = embedder ?? new NativeEmbedder();
    this.defaultTemp = 0.7;
    this.log(
      `Initialized ${this.model} with context window ${this.promptWindowLimit()}`

View on GitHub (pinned to 526360e320)

Solutions

  1. Set MINIMAX_API_KEY in server/.env (or your runtime env) to a valid key from the Minimax console.
  2. Restart the AnythingLLM server process so it re-reads .env.
  3. Verify from a Node REPL that process.env.MINIMAX_API_KEY is non-empty before selecting the provider.
  4. If using Docker/k8s, confirm the env var is injected into the container, not just the host.

Example fix

// before
// MINIMAX_API_KEY is unset -> new MinimaxLLM() throws

// after (server/.env)
MINIMAX_API_KEY=your_key_here
MINIMAX_MODEL_PREF=MiniMax-M2.7
Defensive patterns

Strategy: validation

Validate before calling

// Before selecting/instantiating the Minimax provider
if (!process.env.MINIMAX_API_KEY) {
  throw new Error('MINIMAX_API_KEY missing — configure it before enabling Minimax.');
}

Try / catch

// Constructor throws synchronously; catch at the provider factory
try {
  const llm = new MinimaxLLM(embedder, modelPref);
} catch (e) {
  if (/No Minimax API key/i.test(e.message)) {
    // surface a config error to the user, do not retry
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/9bacafd75db0bba9. Report an issue: GitHub.