Mintplex-Labs/anything-llm · error

No embedding model was set.

Error message

No embedding model was set.

What it means

AnythingLLM's OllamaEmbedder constructor throws this immediately when the EMBEDDING_MODEL_PREF environment variable is unset or empty. Ollama has no default embedding model, so the value is required and is later sent as the `model` argument to Ollama's /api/embed endpoint in embedChunks(). It fails fast at instantiation, before any network traffic happens.

Solutions

  1. Set EMBEDDING_MODEL_PREF in .env (or the embedding provider settings UI) to an embedding model, e.g. nomic-embed-text, mxbai-embed-large, or all-minilm.
  2. Confirm the model exists locally: `ollama list`, and `ollama pull nomic-embed-text` if missing.
  3. Fully restart the AnythingLLM process (or recreate the container) so the env value is loaded.
  4. If configured via the UI, re-save the embedding settings and confirm a model is actually selected.

Example fix

# .env — before
EMBEDDING_BASE_PATH=http://localhost:11434

# .env — after
EMBEDDING_BASE_PATH=http://localhost:11434
EMBEDDING_MODEL_PREF=nomic-embed-text
Defensive patterns

Strategy: validation

Validate before calling

const required = ["EMBEDDING_BASE_PATH", "EMBEDDING_MODEL_PREF"];
const missing = required.filter((k) => !process.env[k]);
if (missing.length > 0) {
  throw new Error(
    `Ollama embedder misconfigured — missing env: ${missing.join(", ")}`
  );
}
const { OllamaEmbedder } = require("server/utils/EmbeddingEngines/ollama");
const embedder = new OllamaEmbedder();

Type guard

function isOllamaEmbedderConfigValid(env = process.env) {
  return Boolean(
    typeof env.EMBEDDING_BASE_PATH === "string" &&
      env.EMBEDDING_BASE_PATH.length > 0 &&
      typeof env.EMBEDDING_MODEL_PREF === "string" &&
      env.EMBEDDING_MODEL_PREF.length > 0
  );
}

Prevention

When it happens

Trigger: Selecting Ollama as the embedding provider without ever setting EMBEDDING_MODEL_PREF; editing .env but not restarting the Node process or recreating the docker container; a typo in the variable name (e.g. EMBEDDING_MODEL_PREFERENCE); a process manager or scheduler that spawns the server without the variable.

Common situations: Fresh installs pointing at a local Ollama where only EMBEDDING_BASE_PATH was configured; docker deployments that added the env after `docker run` without recreating the container; test/CI environments that set the base path but not the model.

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/505178c566769525. Report an issue: GitHub.

Appendix: source

Thrown at server/utils/EmbeddingEngines/ollama/index.js:13

const {
  maximumChunkLength,
  reportEmbeddingProgress,
} = require("../../helpers");
const { Ollama } = require("ollama");
const { OllamaAILLM } = require("../../AiProviders/ollama");

class OllamaEmbedder {
  constructor() {
    if (!process.env.EMBEDDING_BASE_PATH)
      throw new Error("No embedding base path was set.");
    if (!process.env.EMBEDDING_MODEL_PREF)
      throw new Error("No embedding model was set.");

    this.className = "OllamaEmbedder";
    this.basePath = process.env.EMBEDDING_BASE_PATH;
    this.model = process.env.EMBEDDING_MODEL_PREF;
    this.maxConcurrentChunks = process.env.OLLAMA_EMBEDDING_BATCH_SIZE
      ? Number(process.env.OLLAMA_EMBEDDING_BATCH_SIZE)
      : 1;
    this.embeddingMaxChunkLength = maximumChunkLength();
    this.authToken = process.env.OLLAMA_AUTH_TOKEN;

    const headers = this.authToken
      ? { Authorization: `Bearer ${this.authToken}` }
      : {};
    this.client = new Ollama({
      host: this.basePath,
      headers,
      fetch: OllamaAILLM.applyOllamaFetch(),
    });

View on GitHub (pinned to 3aec848f28)