{"record":{"id":"530720b796d79656","repo":"Mintplex-Labs/anything-llm","slug":"no-lmstudio-api-base-path-was-set","errorCode":null,"errorMessage":"No LMStudio API Base Path was set.","messagePattern":"No LMStudio API Base Path was set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/AiProviders/lmStudio/index.js","lineNumber":18,"sourceCode":"const { NativeEmbedder } = require(\"../../EmbeddingEngines/native\");\nconst {\n  handleDefaultStreamResponseV2,\n  formatChatHistory,\n} = require(\"../../helpers/chat/responses\");\nconst {\n  LLMPerformanceMonitor,\n} = require(\"../../helpers/chat/LLMPerformanceMonitor\");\nconst { OpenAI: OpenAIApi } = require(\"openai\");\n\n//  hybrid of openAi LLM chat completion for LMStudio\nclass LMStudioLLM {\n  /** @see LMStudioLLM.cacheContextWindows */\n  static modelContextWindows = {};\n\n  constructor(embedder = null, modelPreference = null) {\n    if (!process.env.LMSTUDIO_BASE_PATH)\n      throw new Error(\"No LMStudio API Base Path was set.\");\n\n    this.className = \"LMStudioLLM\";\n    const apiKey = process.env.LMSTUDIO_AUTH_TOKEN ?? null;\n    this.lmstudio = new OpenAIApi({\n      baseURL: parseLMStudioBasePath(process.env.LMSTUDIO_BASE_PATH), // here is the URL to your LMStudio instance\n      apiKey,\n    });\n\n    // Prior to LMStudio 0.2.17 the `model` param was not required and you could pass anything\n    // into that field and it would work. On 0.2.17 LMStudio introduced multi-model chat\n    // which now has a bug that reports the server model id as \"Loaded from Chat UI\"\n    // and any other value will crash inferencing. So until this is patched we will\n    // try to fetch the `/models` and have the user set it, or just fallback to \"Loaded from Chat UI\"\n    // which will not impact users with <v0.2.17 and should work as well once the bug is fixed.\n    this.model = modelPreference || process.env.LMSTUDIO_MODEL_PREF;\n    if (!this.model) throw new Error(\"LMStudio must have a valid model set.\");\n\n    this.embedder = embedder ?? new NativeEmbedder();","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/lmStudio/index.js#L1-L36","documentation":"Thrown by the LMStudioLLM constructor when LMSTUDIO_BASE_PATH is not set. The base path is the URL of the local LMStudio server. It is parsed through parseLMStudioBasePath to normalize the URL format. There is no constructor-parameter fallback for the base path — it must come from the environment.","triggerScenarios":"Instantiating `new LMStudioLLM(embedder, model)` (via getLLMProvider('lmstudio')) when process.env.LMSTUDIO_BASE_PATH is undefined or empty. The check `if (!process.env.LMSTUDIO_BASE_PATH)` fires immediately.","commonSituations":"LMStudio was selected as the provider but the .env was never configured. A new deployment where .env.example was copied but LMSTUDIO_BASE_PATH remained commented out. The user assumed selecting the provider in the UI was sufficient without editing .env.","solutions":["Set LMSTUDIO_BASE_PATH in .env to your LMStudio server URL (e.g. 'http://localhost:1234/v1') and restart.","Ensure the LMStudio local server is started and listening (LMStudio > Local Server tab > Start Server).","If running AnythingLLM in Docker, use host.docker.internal instead of localhost."],"exampleFix":"// before: .env\n# LMSTUDIO_BASE_PATH='http://your-server:1234/v1'\n\n// after (local)\nLMSTUDIO_BASE_PATH='http://localhost:1234/v1'\n\n// after (docker)\nLMSTUDIO_BASE_PATH='http://host.docker.internal:1234/v1'","handlingStrategy":"validation","validationCode":"function validateLMStudioConfig() {\n  if (!process.env.LMSTUDIO_BASE_PATH) {\n    throw new Error(\n      'LMSTUDIO_BASE_PATH is not set. Configure it in .env (e.g. http://localhost:1234/v1).'\n    );\n  }\n  return process.env.LMSTUDIO_BASE_PATH;\n}\n\nvalidateLMStudioConfig();","typeGuard":null,"tryCatchPattern":"try {\n  const llm = new LMStudioLLM(embedder, model);\n} catch (e) {\n  if (e.message.includes('Base Path')) {\n    console.error('Set LMSTUDIO_BASE_PATH in .env and ensure LMStudio local server is running.');\n    return null;\n  }\n  throw e;\n}","preventionTips":["Start the LMStudio local server before launching AnythingLLM.","Use host.docker.internal in Docker deployments instead of localhost.","Add a startup health check that pings the LMStudio server URL."],"tags":["lmstudio","configuration","env-var","constructor","base-path"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}