{"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":null,"httpStatus":null,"severity":"error","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/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/EmbeddingEngines/ollama/index.js#L1-L31","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","Confirm the model exists locally: `ollama list`, and `ollama pull nomic-embed-text` if missing.","Fully restart the AnythingLLM process (or recreate the container) so the env value is loaded.","If configured via the UI, re-save the embedding settings and confirm a model is actually selected."],"exampleFix":"# .env — before\nEMBEDDING_BASE_PATH=http://localhost:11434\n\n# .env — after\nEMBEDDING_BASE_PATH=http://localhost:11434\nEMBEDDING_MODEL_PREF=nomic-embed-text","handlingStrategy":"validation","validationCode":"const required = [\"EMBEDDING_BASE_PATH\", \"EMBEDDING_MODEL_PREF\"];\nconst missing = required.filter((k) => !process.env[k]);\nif (missing.length > 0) {\n  throw new Error(\n    `Ollama embedder misconfigured — missing env: ${missing.join(\", \")}`\n  );\n}\nconst { OllamaEmbedder } = require(\"server/utils/EmbeddingEngines/ollama\");\nconst embedder = new OllamaEmbedder();","typeGuard":"function isOllamaEmbedderConfigValid(env = process.env) {\n  return Boolean(\n    typeof env.EMBEDDING_BASE_PATH === \"string\" &&\n      env.EMBEDDING_BASE_PATH.length > 0 &&\n      typeof env.EMBEDDING_MODEL_PREF === \"string\" &&\n      env.EMBEDDING_MODEL_PREF.length > 0\n  );\n}","tryCatchPattern":null,"preventionTips":["Fail fast on startup with an env manifest check for the selected embedding engine instead of crashing on first use.","Keep a .env.example listing engine-specific variables to catch typos in CI.","Recreate containers (not just restart) after changing docker env."],"tags":["ollama","embeddings","configuration","environment-variables","constructor"],"backgroundTag":"missing-env-var","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}