Mintplex-Labs/anything-llm · critical · Error

No Embedding Model Pref was set.

Error message

No Embedding Model Pref was set.

What it means

Thrown by the LemonadeEmbedder constructor when EMBEDDING_MODEL_PREF is unset. Unlike engines with a default model, the Lemonade embedder requires an explicit model id because it cannot guess which model your local Lemonade server has loaded. It is checked after the base-path guard, so seeing this error means EMBEDDING_BASE_PATH is already present.

Solutions

  1. List the models available on your Lemonade server (its UI or OpenAI-compatible /models endpoint) and copy the exact id
  2. Set EMBEDDING_MODEL_PREF to that id
  3. Make sure the model is loaded/downloaded on the server so the id is valid
  4. Restart the backend and re-embed

Example fix

# before
EMBEDDING_BASE_PATH=http://localhost:8080
# EMBEDDING_MODEL_PREF unset

# after
EMBEDDING_BASE_PATH=http://localhost:8080
EMBEDDING_MODEL_PREF=onnx-community/Llama-3.2-1B
Defensive patterns

Strategy: validation

Validate before calling

function assertLemonadeModelSelected() {
  if (!process.env.EMBEDDING_MODEL_PREF) {
    throw new Error("Lemonade embedder needs EMBEDDING_MODEL_PREF set to a model id the server has loaded");
  }
}
assertLemonadeModelSelected();

Try / catch

try {
  const embedder = new LemonadeEmbedder();
} catch (e) {
  if (e.message === "No Embedding Model Pref was set.") {
    // fetch the server's model list and have the user pick one
  }
  throw e;
}

Prevention

When it happens

Trigger: Configuring the Lemonade embedding engine with a base path but leaving the model preference empty; EMBEDDING_MODEL_PREF removed from .env; model field cleared in the settings UI and saved.

Common situations: Admins who assumed Lemonade would use whatever model is currently loaded; copying a config template that only filled in the server URL.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at server/utils/EmbeddingEngines/lemonade/index.js:9

const { parseLemonadeServerEndpoint } = require("../../AiProviders/lemonade");
const { toChunks, reportEmbeddingProgress } = require("../../helpers");

class LemonadeEmbedder {
  constructor() {
    if (!process.env.EMBEDDING_BASE_PATH)
      throw new Error("No Lemonade API Base Path was set.");
    if (!process.env.EMBEDDING_MODEL_PREF)
      throw new Error("No Embedding Model Pref was set.");
    this.className = "LemonadeEmbedder";
    const { OpenAI: OpenAIApi } = require("openai");
    this.lemonade = new OpenAIApi({
      baseURL: parseLemonadeServerEndpoint(
        process.env.EMBEDDING_BASE_PATH,
        "openai"
      ),
      apiKey: process.env.LEMONADE_LLM_API_KEY || null,
    });
    this.model = process.env.EMBEDDING_MODEL_PREF;

    this.maxConcurrentChunks = 50;
    this.embeddingMaxChunkLength =
      process.env.EMBEDDING_MODEL_MAX_CHUNK_LENGTH || 8_191;
  }

  log(text, ...args) {
    console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);

View on GitHub (pinned to 3aec848f28)