Mintplex-Labs/anything-llm · error

Minimax chat: is not valid for chat completion!

Error message

Minimax chat: ${this.model} is not valid for chat completion!

What it means

MinimaxLLM.getChatCompletion validates this.model by calling the MiniMax OpenAI-compatible GET /v1/models endpoint (openai.models.list()) and checking whether the id appears in the list. If the id is absent — or the listing call itself failed — isValidChatCompletionModel returns false and this error is thrown before any completion request is sent.

Solutions

  1. List valid ids with your key: curl -H 'Authorization: Bearer $MINIMAX_API_KEY' https://api.minimax.io/v1/models — then set MINIMAX_MODEL_PREF to one of them
  2. Re-pick the model from the AnythingLLM UI dropdown so the current id is stored
  3. Verify the API key is active — a bad key makes models.list() fail and looks exactly like an invalid model
  4. Restart the server after changing MINIMAX_MODEL_PREF in .env

Example fix

# before
MINIMAX_MODEL_PREF=abab6.5s-chat
# after
MINIMAX_MODEL_PREF=MiniMax-M2.7
Defensive patterns

Strategy: validation

Validate before calling

const models = await llm.openai.models.list().catch(() => ({ data: [] }));
const ok = models.data.some((m) => m.id === llm.model);
if (!ok)
  throw new Error(`Model ${llm.model} not in MiniMax model list — check key and model id`);

Try / catch

try {
  await llm.getChatCompletion(messages);
} catch (e) {
  if (/Minimax chat: .* is not valid/.test(e.message)) {
    // treat as config error: verify model id AND key (both produce this)
  }
  throw e;
}

Prevention

When it happens

Trigger: MINIMAX_MODEL_PREF (or a workspace-selected model) is not an id returned by https://api.minimax.io/v1/models, e.g. a renamed/deprecated id; or the models.list() call fails (revoked key, network block) and the .catch(() => ({ data: [] })) turns the failure into an empty list, which is indistinguishable from an invalid model.

Common situations: MiniMax renames or retires model ids (e.g. old abab-* ids vs MiniMax-M2.7) while the stored preference still uses the old name; hardcoding model ids from blog posts; a deactivated API key making models.list() fail silently.

Related errors


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

Appendix: source

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

    return models.data.some((model) => model.id === modelName);
  }

  constructPrompt({
    systemPrompt = "",
    contextTexts = [],
    chatHistory = [],
    userPrompt = "",
  }) {
    const prompt = {
      role: "system",
      content: `${systemPrompt}${this.#appendContext(contextTexts)}`,
    };
    return [prompt, ...chatHistory, { role: "user", content: userPrompt }];
  }

  async getChatCompletion(messages = null, { temperature = 0.7 }) {
    if (!(await this.isValidChatCompletionModel(this.model)))
      throw new Error(
        `Minimax chat: ${this.model} is not valid for chat completion!`
      );

    const result = await LLMPerformanceMonitor.measureAsyncFunction(
      this.openai.chat.completions
        .create({
          model: this.model,
          messages,
          temperature,
        })
        .catch((e) => {
          throw new Error(e.message);
        })
    );

    if (
      !result?.output?.hasOwnProperty("choices") ||
      result?.output?.choices?.length === 0

View on GitHub (pinned to 3aec848f28)