{"record":{"id":"8141341434a9b824","repo":"Mintplex-Labs/anything-llm","slug":"no-embedding-model-was-set-814134","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/localAi/index.js","lineNumber":12,"sourceCode":"const {\n  toChunks,\n  maximumChunkLength,\n  reportEmbeddingProgress,\n} = require(\"../../helpers\");\n\nclass LocalAiEmbedder {\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 = \"LocalAiEmbedder\";\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n    this.model = process.env.EMBEDDING_MODEL_PREF;\n    this.openai = new OpenAIApi({\n      baseURL: process.env.EMBEDDING_BASE_PATH,\n      apiKey: process.env.LOCAL_AI_API_KEY ?? null,\n    });\n\n    // Limit of how many strings we can process in a single pass to stay with resource or network limits\n    this.maxConcurrentChunks = 50;\n    this.embeddingMaxChunkLength = maximumChunkLength();\n\n    this.log(\n      `Initialized with ${this.model} - Max Size: ${this.embeddingMaxChunkLength}` +\n        (this.outputDimensions\n          ? ` - Output Dimensions: ${this.outputDimensions}`\n          : \" Assuming default output dimensions\")","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/EmbeddingEngines/localAi/index.js#L1-L30","documentation":"Thrown by the LocalAiEmbedder constructor when EMBEDDING_MODEL_PREF is unset. LocalAI models must be installed explicitly (via its model gallery or config), so there is no safe default model id; the constructor demands the exact name of an installed embedding model. It runs after the base-path check, so this error implies the URL is already configured.","triggerScenarios":"Configuring LocalAI embeddings with a URL but empty model field; the model was uninstalled from LocalAI but the preference left blank; settings saved mid-configuration.","commonSituations":"Fresh LocalAI installs where no embedding backend (e.g. bert-embeddings) has been pulled from the gallery yet; model name mismatch between the gallery id and what the user typed.","solutions":["Install an embedding model in LocalAI (gallery: e.g. 'localai' provides bert-embeddings / sentence-transformers backends)","Copy the exact installed model name into EMBEDDING_MODEL_PREF","Restart the backend and re-embed the failed documents"],"exampleFix":"# before\nEMBEDDING_BASE_PATH=http://localhost:8080/v1\n# EMBEDDING_MODEL_PREF unset\n\n# after\nEMBEDDING_BASE_PATH=http://localhost:8080/v1\nEMBEDDING_MODEL_PREF=bert-embeddings","handlingStrategy":"validation","validationCode":"function assertLocalAiModelSelected() {\n  if (!process.env.EMBEDDING_MODEL_PREF) {\n    throw new Error(\"LocalAI embedder needs EMBEDDING_MODEL_PREF set to an installed embedding model\");\n  }\n}\nassertLocalAiModelSelected();","typeGuard":null,"tryCatchPattern":"try {\n  const embedder = new LocalAiEmbedder();\n} catch (e) {\n  if (e.message === \"No embedding model was set.\") {\n    // install an embedding model from the LocalAI gallery, then set its exact name\n  }\n  throw e;\n}","preventionTips":["Install the embedding model in LocalAI before configuring AnythingLLM's embedding engine","Copy the model name verbatim from the LocalAI gallery/config (backend names matter)","Treat model installation and model preference as one setup step so they cannot drift"],"tags":["localai","model-name","env-var","self-hosted","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"}