Mintplex-Labs/anything-llm · error

No LMStudio API Base Path was set.

Error message

No LMStudio API Base Path was set.

What it means

LMStudioLLM's constructor throws when LMSTUDIO_BASE_PATH is unset. LM Studio runs a local OpenAI-compatible server; the value is normalized by parseLMStudioBasePath() (lmStudio/index.js:368), which keeps only the origin and appends /v1 — so http://192.168.1.10:1234 becomes http://192.168.1.10:1234/v1. If the input is not parseable as a URL, it is passed through raw. LMSTUDIO_AUTH_TOKEN is optional (null default).

Solutions

  1. In LM Studio: start the server (Developer → Start Server) and note the port (default 1234).
  2. Set LMSTUDIO_BASE_PATH=http://127.0.0.1:1234 (include the http:// scheme) in backend .env.
  3. Docker: use http://host.docker.internal:1234 or the host LAN IP.
  4. If LM Studio's server requires CORS/auth, set LMSTUDIO_AUTH_TOKEN accordingly.
  5. Restart AnythingLLM after saving env.

Example fix

# before (.env)
LMSTUDIO_MODEL_PREF=loaded-model

# after (.env)
LMSTUDIO_BASE_PATH=http://127.0.0.1:1234
LMSTUDIO_MODEL_PREF=loaded-model
Defensive patterns

Strategy: validation

Validate before calling

if (!process.env.LMSTUDIO_BASE_PATH) throw new Error("LMSTUDIO_BASE_PATH missing");
try { new URL(process.env.LMSTUDIO_BASE_PATH); } catch { throw new Error("Include the scheme: http://127.0.0.1:1234"); }

Try / catch

try {
  new LMStudioLLM(embedder, model);
} catch (e) {
  if (/LMStudio API Base Path/i.test(e.message)) return promptEnvSetup("LMSTUDIO_BASE_PATH");
  throw e;
}

Prevention

When it happens

Trigger: Selecting LM Studio as the LLM provider while LMSTUDIO_BASE_PATH is missing from the server env — e.g., LM Studio's 'Local Server' not started (default port 1234), the var never added to .env, or Docker deployments where localhost must become host.docker.internal.

Common situations: User starts LM Studio the app but never clicks 'Start Server'; server bound in LM Studio to a different port; AnythingLLM in a container pointing at 127.0.0.1; providing a full path like http://localhost:1234/v1 (harmless — normalizer strips it) versus providing 'localhost:1234' without a scheme (URL() throws and the raw string is passed through, later breaking the SDK).

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@f92433b4ea (2026-08-18). Data as JSON: /api/errors/530720b796d79656. Report an issue: GitHub.

Appendix: 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 f92433b4ea)