Mintplex-Labs/anything-llm · error

No Minimax API key was set.

Error message

No Minimax API key was set.

What it means

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.

Solutions

  1. Add MINIMAX_API_KEY=<key from the MiniMax platform console> to the server's .env
  2. Restart the AnythingLLM server or container so the variable is loaded
  3. 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
  4. Check for typos and stray whitespace in the variable name and value

Example fix

# before
# (MINIMAX_API_KEY not set)
# after
MINIMAX_API_KEY=eyJhbGciOi...your-key
Defensive patterns

Strategy: validation

Validate before calling

if (!process.env.MINIMAX_API_KEY)
  throw new Error('MiniMax provider selected but MINIMAX_API_KEY is not configured');
const llm = new MinimaxLLM(embedder);

Try / catch

try {
  const llm = new MinimaxLLM(embedder);
} catch (e) {
  if (e.message === 'No Minimax API key was set.')
    return respondConfigError(e); // stop, configure the key, restart
  throw e;
}

Prevention

When it happens

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

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

Understand the failure class

Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.

Related errors


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

Appendix: 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 3aec848f28)