{"record":{"id":"505178c566769525","repo":"Mintplex-Labs/anything-llm","slug":"no-embedding-model-was-set-505178","errorCode":null,"errorMessage":"No embedding model was set.","messagePattern":"No embedding model was set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/EmbeddingEngines/ollama/index.js","lineNumber":13,"sourceCode":"const {\n  maximumChunkLength,\n  reportEmbeddingProgress,\n} = require(\"../../helpers\");\nconst { Ollama } = require(\"ollama\");\nconst { OllamaAILLM } = require(\"../../AiProviders/ollama\");\n\nclass OllamaEmbedder {\n  constructor() {\n    if (!process.env.EMBEDDING_BASE_PATH)\n      throw new Error(\"No embedding base path was set.\");\n    if (!process.env.EMBEDDING_MODEL_PREF)\n      throw new Error(\"No embedding model was set.\");\n\n    this.className = \"OllamaEmbedder\";\n    this.basePath = process.env.EMBEDDING_BASE_PATH;\n    this.model = process.env.EMBEDDING_MODEL_PREF;\n    this.maxConcurrentChunks = process.env.OLLAMA_EMBEDDING_BATCH_SIZE\n      ? Number(process.env.OLLAMA_EMBEDDING_BATCH_SIZE)\n      : 1;\n    this.embeddingMaxChunkLength = maximumChunkLength();\n    this.authToken = process.env.OLLAMA_AUTH_TOKEN;\n\n    const headers = this.authToken\n      ? { Authorization: `Bearer ${this.authToken}` }\n      : {};\n    this.client = new Ollama({\n      host: this.basePath,\n      headers,\n      fetch: OllamaAILLM.applyOllamaFetch(),\n    });","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/EmbeddingEngines/ollama/index.js#L1-L31","documentation":"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.","triggerScenarios":"Constructing `new OllamaEmbedder()` with EMBEDDING_MODEL_PREF unset/empty. Fires at construction, before the Ollama client makes any call.","commonSituations":"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).","solutions":["Set EMBEDDING_MODEL_PREF to a model visible in `ollama list`","If unsure of the exact name, run `ollama list` and copy the NAME column verbatim","Reload AnythingLLM env"],"exampleFix":"// before\nEMBEDDING_BASE_PATH=http://localhost:11434\n// EMBEDDING_MODEL_PREF unset\n\n// after\nEMBEDDING_BASE_PATH=http://localhost:11434\nEMBEDDING_MODEL_PREF=nomic-embed-text","handlingStrategy":"validation","validationCode":"function hasEmbeddingModelPref(env = process.env) {\n  return typeof env.EMBEDDING_MODEL_PREF === 'string' &&\n         env.EMBEDDING_MODEL_PREF.trim().length > 0;\n}\nif (!hasEmbeddingModelPref()) {\n  throw new Error('Missing EMBEDDING_MODEL_PREF for Ollama.');\n}","typeGuard":"function isNonEmptyModel(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["`ollama pull` the embedding model and copy its exact name from `ollama list`.","Set base path and model together when enabling Ollama.","Reload env after editing .env."],"tags":["ollama","embedding","config","env","constructor"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}