{"record":{"id":"061ba23505da55b4","repo":"Mintplex-Labs/anything-llm","slug":"no-embedding-model-was-set","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/lmstudio/index.js","lineNumber":12,"sourceCode":"const { parseLMStudioBasePath } = require(\"../../AiProviders/lmStudio\");\nconst {\n  maximumChunkLength,\n  reportEmbeddingProgress,\n} = require(\"../../helpers\");\n\nclass LMStudioEmbedder {\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    const apiKey = process.env.LMSTUDIO_AUTH_TOKEN ?? null;\n    this.className = \"LMStudioEmbedder\";\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n    this.lmstudio = new OpenAIApi({\n      baseURL: parseLMStudioBasePath(process.env.EMBEDDING_BASE_PATH),\n      apiKey,\n    });\n    this.model = process.env.EMBEDDING_MODEL_PREF;\n\n    // Limit of how many strings we can process in a single pass to stay with resource or network limits\n    this.maxConcurrentChunks = 1;\n    this.embeddingMaxChunkLength = maximumChunkLength();\n  }\n\n  log(text, ...args) {\n    console.log(`\\x1b[36m[${this.className}]\\x1b[0m ${text}`, ...args);\n  }","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/EmbeddingEngines/lmstudio/index.js#L1-L30","documentation":"Thrown by the LMStudioEmbedder constructor (line 12) when process.env.EMBEDDING_MODEL_PREF is falsy, immediately after the base-path check. The model identifier is required because it is passed as the `model` field to every /embeddings request; an empty value would make LMStudio reject or misroute the call. This guard fails fast before any network work.","triggerScenarios":"Instantiating `new LMStudioEmbedder()` with EMBEDDING_MODEL_PREF unset/empty. Happens at construction, before #isAlive or any embedding call. Typically when the UI/system settings saved a base path but no model, or .env is partially configured.","commonSituations":"User loaded a model into LMStudio but did not set the matching EMBEDDING_MODEL_PREF in AnythingLLM; model name copied with a typo; switching engines and the previous model env was cleared; fresh install where only EMBEDDING_BASE_PATH was set.","solutions":["Set EMBEDDING_MODEL_PREF to the exact model name loaded in LMStudio (visible in its UI), e.g. nomic-ai/nomic-embed-text-v1.5","Verify the string matches LMStudio's loaded model identifier exactly (case/hyphens)","Reload AnythingLLM env after editing .env"],"exampleFix":"// before\nEMBEDDING_BASE_PATH=http://localhost:1234/v1\n// EMBEDDING_MODEL_PREF unset\n\n// after\nEMBEDDING_BASE_PATH=http://localhost:1234/v1\nEMBEDDING_MODEL_PREF=nomic-ai/nomic-embed-text-v1.5","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 LMStudio.');\n}","typeGuard":"function isNonEmptyModel(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Copy the model identifier verbatim from LMStudio's loaded-models list.","Treat base path and model as a required pair — set both together.","Validate env in a single boot check covering all local engines."],"tags":["lmstudio","embedding","config","env","constructor"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}