Mintplex-Labs/anything-llm · critical · Error

LMStudio base path must be provided to use agents.

Error message

LMStudio base path must be provided to use agents.

What it means

checkSetup() (index.js:138-141) throws for provider === "lmstudio" when process.env.LMSTUDIO_BASE_PATH is falsy. Unlike cloud providers, LM Studio needs a base URL (its local OpenAI-compatible server), not an API key, so that is what is validated before the agent runs.

Source

Thrown at server/utils/agents/index.js:140

    } catch (e) {
      this.log("Error loading chat history", e.message);
      return [];
    }
  }

  checkSetup() {
    switch (this.provider) {
      case "openai":
        if (!process.env.OPEN_AI_KEY)
          throw new Error("OpenAI API key must be provided to use agents.");
        break;
      case "anthropic":
        if (!process.env.ANTHROPIC_API_KEY)
          throw new Error("Anthropic API key must be provided to use agents.");
        break;
      case "lmstudio":
        if (!process.env.LMSTUDIO_BASE_PATH)
          throw new Error("LMStudio base path must be provided to use agents.");
        break;
      case "ollama":
        if (!process.env.OLLAMA_BASE_PATH)
          throw new Error("Ollama base path must be provided to use agents.");
        break;
      case "groq":
        if (!process.env.GROQ_API_KEY)
          throw new Error("Groq API key must be provided to use agents.");
        break;
      case "togetherai":
        if (!process.env.TOGETHER_AI_API_KEY)
          throw new Error("TogetherAI API key must be provided to use agents.");
        break;
      case "azure":
        if (!process.env.AZURE_OPENAI_ENDPOINT || !process.env.AZURE_OPENAI_KEY)
          throw new Error(
            "Azure OpenAI API endpoint and key must be provided to use agents."
          );

View on GitHub (pinned to 526360e320)

Solutions

  1. Set LMSTUDIO_BASE_PATH (e.g. http://127.0.0.1:1234/v1) in .env.
  2. Start the LM Studio local server and load a model.
  3. Restart the server process after editing .env.
  4. Verify the URL is reachable from the AnythingLLM process (no firewall/loopback mismatch).

Example fix

# before (.env)
# LMSTUDIO_BASE_PATH=

# after (.env)
LMSTUDIO_BASE_PATH=http://127.0.0.1:1234/v1
Defensive patterns

Strategy: validation

Validate before calling

function lmStudioAgentReady() {
  return Boolean(process.env.LMSTUDIO_BASE_PATH && process.env.LMSTUDIO_BASE_PATH.trim());
}
if (provider === "lmstudio" && !lmStudioAgentReady())
  throw new Error("Set LMSTUDIO_BASE_PATH (e.g. http://127.0.0.1:1234/v1) before enabling the lmstudio agent.");

Try / catch

try {
  agent.checkSetup();
} catch (e) {
  if (/LMSTUDIO_BASE_PATH|base path must be provided/i.test(e.message)) {
    throw new Error("LMStudio agent is not configured: set LMSTUDIO_BASE_PATH in .env and restart.");
  }
  throw e;
}

Prevention

When it happens

Trigger: Selecting the lmstudio agent provider while LMSTUDIO_BASE_PATH is unset, e.g. before starting/pointing at the LM Studio server.

Common situations: Local-only provider selected without configuring the server URL, the LM Studio server not running yet, or a typo in the base path.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/1ca94495a16b4a0d. Report an issue: GitHub.