Mintplex-Labs/anything-llm · error

Minimax stream: is not valid for chat completion!

Error message

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

What it means

Streaming guard in MinimaxLLM.streamGetChatCompletion(): before opening the stream it validates this.model via isValidChatCompletionModel, which calls GET /v1/models on api.minimax.io and checks id membership. A model id absent from the list — or a failed listing request (silently caught into an empty list) — makes the check false and this error is thrown.

Solutions

  1. Run curl -H 'Authorization: Bearer $MINIMAX_API_KEY' https://api.minimax.io/v1/models and set MINIMAX_MODEL_PREF to a listed id
  2. Re-select the model from the AnythingLLM UI dropdown
  3. Verify the API key is valid — a failing models.list() is indistinguishable from an invalid model
  4. Restart the server after .env changes

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.streamGetChatCompletion(messages);
} catch (e) {
  if (/Minimax stream: .* is not valid/.test(e.message)) {
    // config error: fix model id or API key, then restart the stream
  }
  throw e;
}

Prevention

When it happens

Trigger: Starting a streaming chat with MINIMAX_MODEL_PREF or a UI-selected model id that api.minimax.io/v1/models does not return; a revoked/expired API key making models.list() fail; a renamed or deprecated MiniMax model id still stored as the preference.

Common situations: Vendor model renames leaving stale stored ids; hardcoding model names; egress rules blocking the models endpoint so the list comes back empty.

Related errors


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

Appendix: source

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

    return {
      textResponse: result.output.choices[0].message.content,
      metrics: {
        prompt_tokens: result.output.usage.prompt_tokens || 0,
        completion_tokens: result.output.usage.completion_tokens || 0,
        total_tokens: result.output.usage.total_tokens || 0,
        outputTps: result.output.usage.completion_tokens / result.duration,
        duration: result.duration,
        model: this.model,
        provider: this.className,
        timestamp: new Date(),
      },
    };
  }

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

    const measuredStreamRequest = await LLMPerformanceMonitor.measureStream({
      func: this.openai.chat.completions.create({
        model: this.model,
        stream: true,
        messages,
        temperature,
      }),
      messages,
      runPromptTokenCalculation: false,
      modelTag: this.model,
      provider: this.className,
    });

    return measuredStreamRequest;
  }

View on GitHub (pinned to 3aec848f28)