Mintplex-Labs/anything-llm · critical · Error
No LMStudio API Base Path was set.
Error message
No LMStudio API Base Path was set.
What it means
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.
Source
Thrown at server/utils/AiProviders/lmStudio/index.js:18
const { NativeEmbedder } = require("../../EmbeddingEngines/native");
const {
handleDefaultStreamResponseV2,
formatChatHistory,
} = require("../../helpers/chat/responses");
const {
LLMPerformanceMonitor,
} = require("../../helpers/chat/LLMPerformanceMonitor");
const { OpenAI: OpenAIApi } = require("openai");
// hybrid of openAi LLM chat completion for LMStudio
class LMStudioLLM {
/** @see LMStudioLLM.cacheContextWindows */
static modelContextWindows = {};
constructor(embedder = null, modelPreference = null) {
if (!process.env.LMSTUDIO_BASE_PATH)
throw new Error("No LMStudio API Base Path was set.");
this.className = "LMStudioLLM";
const apiKey = process.env.LMSTUDIO_AUTH_TOKEN ?? null;
this.lmstudio = new OpenAIApi({
baseURL: parseLMStudioBasePath(process.env.LMSTUDIO_BASE_PATH), // here is the URL to your LMStudio instance
apiKey,
});
// Prior to LMStudio 0.2.17 the `model` param was not required and you could pass anything
// into that field and it would work. On 0.2.17 LMStudio introduced multi-model chat
// which now has a bug that reports the server model id as "Loaded from Chat UI"
// and any other value will crash inferencing. So until this is patched we will
// try to fetch the `/models` and have the user set it, or just fallback to "Loaded from Chat UI"
// which will not impact users with <v0.2.17 and should work as well once the bug is fixed.
this.model = modelPreference || process.env.LMSTUDIO_MODEL_PREF;
if (!this.model) throw new Error("LMStudio must have a valid model set.");
this.embedder = embedder ?? new NativeEmbedder();View on GitHub (pinned to 526360e320)
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.
Example fix
// before: .env # LMSTUDIO_BASE_PATH='http://your-server:1234/v1' // after (local) LMSTUDIO_BASE_PATH='http://localhost:1234/v1' // after (docker) LMSTUDIO_BASE_PATH='http://host.docker.internal:1234/v1'
Defensive patterns
Strategy: validation
Validate before calling
function validateLMStudioConfig() {
if (!process.env.LMSTUDIO_BASE_PATH) {
throw new Error(
'LMSTUDIO_BASE_PATH is not set. Configure it in .env (e.g. http://localhost:1234/v1).'
);
}
return process.env.LMSTUDIO_BASE_PATH;
}
validateLMStudioConfig(); Try / catch
try {
const llm = new LMStudioLLM(embedder, model);
} catch (e) {
if (e.message.includes('Base Path')) {
console.error('Set LMSTUDIO_BASE_PATH in .env and ensure LMStudio local server is running.');
return null;
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No Lemonade API Base Path was set.
- LiteLLM must have a valid base path to use for the api.
- LMStudio must have a valid model set.
- No LocalAI Base Path was set.
- KoboldCPP must have a valid model set.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/530720b796d79656.
Report an issue: GitHub.