Mintplex-Labs/anything-llm · critical

No Mistral API key was set.

Error message

No Mistral API key was set.

What it means

Thrown by the MistralEmbedder constructor when MISTRAL_API_KEY is unset. The class is the simplest engine here: it talks to https://api.mistral.ai/v1 with the OpenAI SDK and defaults to the mistral-embed model. Unlike most other engines it performs no other configuration checks, so this key is its single hard requirement.

Solutions

  1. Create a key at console.mistral.ai (API Keys page) and set MISTRAL_API_KEY to it
  2. Add the variable to docker-compose environment (or -e flag) and recreate the container
  3. Restart the server so the constructor sees the value
  4. Check exact spelling — MISTRAL_API_KEY, not MISTRAL_EMBEDDING_API_KEY

Example fix

# before
EMBEDDING_ENGINE=mistral

# after
EMBEDDING_ENGINE=mistral
MISTRAL_API_KEY=...
Defensive patterns

Strategy: validation

Validate before calling

function assertMistralEmbedderConfigured() {
  if (!process.env.MISTRAL_API_KEY) {
    throw new Error("Missing MISTRAL_API_KEY — create one at console.mistral.ai");
  }
}
assertMistralEmbedderConfigured();

Try / catch

try {
  const embedder = new MistralEmbedder();
} catch (e) {
  if (e.message === "No Mistral API key was set.") {
    // deterministic config failure — surface a settings prompt, never a retry
  }
  throw e;
}

Prevention

When it happens

Trigger: Selecting Mistral as the embedding engine without entering an API key; MISTRAL_API_KEY missing from docker-compose/.env; key defined only on the host but the process runs in the container; env file edited after startup without restart.

Common situations: Users who set MISTRAL_API_KEY for the LLM provider but selected the Mistral embedding engine before the key propagated; CI environments that never received the secret.

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@f92433b4ea (2026-09-22). Data as JSON: /api/errors/260068a13aa19266. Report an issue: GitHub.

Appendix: source

Thrown at server/utils/EmbeddingEngines/mistral/index.js:10

const {
  toChunks,
  maximumChunkLength,
  reportEmbeddingProgress,
} = require("../../helpers");

class MistralEmbedder {
  constructor() {
    if (!process.env.MISTRAL_API_KEY)
      throw new Error("No Mistral API key was set.");

    const { OpenAI: OpenAIApi } = require("openai");
    this.className = "MistralEmbedder";
    this.openai = new OpenAIApi({
      baseURL: "https://api.mistral.ai/v1",
      apiKey: process.env.MISTRAL_API_KEY ?? null,
      fetch: MistralEmbedder.applyMistralFetch(),
    });
    this.model = process.env.EMBEDDING_MODEL_PREF || "mistral-embed";

    // Mistral rejects a batch whose total token count is too large with
    // 400 {"code":"3210","message":"Too many tokens overall, split into more batches."}.
    // With 1000-char chunks, 200 inputs succeed and 300 fail, so 100 leaves headroom.
    this.maxConcurrentChunks = 100;
    this.embeddingMaxChunkLength = maximumChunkLength();
    this.log(`Initialized ${this.model}`, {
      maxConcurrentChunks: this.maxConcurrentChunks,
      embeddingMaxChunkLength: this.embeddingMaxChunkLength,

View on GitHub (pinned to f92433b4ea)