Mintplex-Labs/anything-llm · critical · Error

No embedding model was set.

Error message

No embedding model was set.

What it means

Thrown by the OllamaEmbedder constructor (line 13) when process.env.EMBEDDING_MODEL_PREF is falsy, right after the base-path guard. The model is passed to every client.embed call as `model`; Ollama needs it to select a pulled model. The guard fails fast before #isAlive or any embedding work.

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

Solutions

  1. Set EMBEDDING_MODEL_PREF to a model visible in `ollama list`
  2. If unsure of the exact name, run `ollama list` and copy the NAME column verbatim
  3. Reload AnythingLLM env

Example fix

// before
EMBEDDING_BASE_PATH=http://localhost:11434
// EMBEDDING_MODEL_PREF unset

// after
EMBEDDING_BASE_PATH=http://localhost:11434
EMBEDDING_MODEL_PREF=nomic-embed-text
Defensive patterns

Strategy: validation

Validate before calling

function hasEmbeddingModelPref(env = process.env) {
  return typeof env.EMBEDDING_MODEL_PREF === 'string' &&
         env.EMBEDDING_MODEL_PREF.trim().length > 0;
}
if (!hasEmbeddingModelPref()) {
  throw new Error('Missing EMBEDDING_MODEL_PREF for Ollama.');
}

Type guard

function isNonEmptyModel(v) {
  return typeof v === 'string' && v.trim().length > 0;
}

Prevention

When it happens

Trigger: Constructing `new OllamaEmbedder()` with EMBEDDING_MODEL_PREF unset/empty. Fires at construction, before the Ollama client makes any call.

Common situations: User ran `ollama pull <model>` but did not set EMBEDDING_MODEL_PREF to the same name; model name typo; switching engines cleared the model env; using a tag suffix the user omitted (e.g. nomic-embed-text vs nomic-embed-text:latest).

Related errors


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