Mintplex-Labs/anything-llm · error · Error

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

Error message

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

What it means

In getChatCompletion the provider awaits isValidChatCompletionModel(this.model), which checks the configured/default model against Minimax's known chat models. If this.model is not in that set, it throws before any network call. this.model defaults to process.env.MINIMAX_MODEL_PREF or 'MiniMax-M2.7'.

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 526360e320)

Solutions

  1. Confirm the exact model id against Minimax's current model documentation.
  2. Delete the cached model list under storage/models/minimax so it re-fetches the live catalog.
  3. Update MINIMAX_MODEL_PREF to a valid current chat model id.
  4. Ensure the server has outbound network access when isValidChatCompletionModel fetches the catalog.

Example fix

// before
MINIMAX_MODEL_PREF=minimax-text-01   // retired / wrong id

// after
MINIMAX_MODEL_PREF=MiniMax-M2.7
Defensive patterns

Strategy: validation

Validate before calling

// Validate model against the catalog before calling getChatCompletion
const valid = await llm.isValidChatCompletionModel(llm.model);
if (!valid) {
  throw new Error(`Model '${llm.model}' is not in the Minimax chat catalog — fix MINIMAX_MODEL_PREF.`);
}

Type guard

function isKnownMinimaxModel(model, catalog) {
  return typeof model === 'string' && model.length > 0 && catalog.includes(model);
}

Try / catch

try {
  await llm.getChatCompletion(messages, { temperature });
} catch (e) {
  if (/not valid for chat completion/i.test(e.message)) {
    // reconfigure model, do not retry with the same id
  }
}

Prevention

When it happens

Trigger: Calling getChatCompletion when MINIMAX_MODEL_PREF (or the passed modelPreference) names a model not present in the resolved Minimax model list — e.g. a typo, an embedding-only model id, or a model Minimax has retired.

Common situations: Typo in the model name in .env; using an embedding model id for chat; Minimax renamed/deprecated the model and the cached model list in storage/models/minimax is stale; default model constant drifts from the live catalog.

Related errors


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