{"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/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/EmbeddingEngines/localAi/index.js#L1-L30","documentation":"Thrown by the LocalAiEmbedder constructor (line 12) when process.env.EMBEDDING_MODEL_PREF is falsy, right after the base-path guard. The model name is sent as the `model` field on every /embeddings request; LocalAI needs it to pick the loaded model. The guard prevents queuing requests that LocalAI would reject.","triggerScenarios":"Constructing `new LocalAiEmbedder()` with EMBEDDING_MODEL_PREF unset/empty. Fires at construction time before any embedding work, mirroring the LMStudio model guard.","commonSituations":"LocalAI model installed but EMBEDDING_MODEL_PREF not set to match; model name typo; switching engines cleared the previous model env; models.yaml in LocalAI uses a different id than what was typed.","solutions":["Set EMBEDDING_MODEL_PREF to the model id exactly as configured in LocalAI's models.yaml","Confirm the model is actually loaded/available in LocalAI (check its /v1/models endpoint)","Reload AnythingLLM env"],"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=bge-small-en","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 LocalAI.');\n}","typeGuard":"function isNonEmptyModel(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Copy the model id exactly from LocalAI's models.yaml or /v1/models.","Set base path and model together when switching to LocalAI.","Reload env after editing .env."],"tags":["localai","embedding","config","env","constructor"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}