{"record":{"id":"45e0054ed9fa3b0e","repo":"Mintplex-Labs/anything-llm","slug":"no-foundry-base-path-was-set","errorCode":null,"errorMessage":"No Foundry Base Path was set.","messagePattern":"No Foundry Base Path was set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/foundry/index.js","lineNumber":30,"sourceCode":"const { OpenAI: OpenAIApi } = require(\"openai\");\nconst ToolCallTextFilter = require(\"./toolCallFilter.js\");\n\nclass FoundryLLM {\n  /**\n   * The largest context window we will select on the user's behalf.\n   * Foundry runs on the user's own machine with no performance setting, so a\n   * model advertising 128K would make an average laptop crawl. A user who\n   * explicitly sets a larger limit still gets it, up to the model's real window.\n   * @type {number}\n   */\n  static MAX_DEFAULT_CONTEXT_WINDOW = 16_000;\n\n  /** @see FoundryLLM.cacheContextWindows */\n  static modelContextWindows = {};\n\n  constructor(embedder = null, modelPreference = null) {\n    if (!process.env.FOUNDRY_BASE_PATH)\n      throw new Error(\"No Foundry Base Path was set.\");\n\n    this.className = \"FoundryLLM\";\n    this.model = modelPreference || process.env.FOUNDRY_MODEL_PREF;\n    this.openai = new OpenAIApi({\n      baseURL: parseFoundryBasePath(process.env.FOUNDRY_BASE_PATH),\n      apiKey: null,\n    });\n\n    this.embedder = embedder ?? new NativeEmbedder();\n    this.defaultTemp = 0.7;\n    this.limits = null;\n    FoundryLLM.cacheContextWindows(true);\n    this.#log(`Loaded with model: ${this.model}`);\n  }\n\n  static #slog(text, ...args) {\n    console.log(`\\x1b[36m[FoundryLLM]\\x1b[0m ${text}`, ...args);\n  }","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/AiProviders/foundry/index.js#L12-L48","documentation":"The FoundryLLM constructor throws when the FOUNDRY_BASE_PATH environment variable is unset. Foundry Local is a user-hosted, OpenAI-compatible service, and this base path is the only way to locate it (there is no API key; apiKey is passed as null). Since the provider is constructed per request, the error appears when a chat selects Foundry Local as its LLM.","triggerScenarios":"Choosing Foundry Local as the workspace/provider LLM while FOUNDRY_BASE_PATH is not in the server environment. Typical valid value is the local service URL such as http://localhost:5273/v1 (the code normalizes it via parseFoundryBasePath).","commonSituations":"Foundry Local installed but AnythingLLM started without the env var (var added to .env after the server launched); Docker deployment where the host's localhost is wrong or the var was never passed into the container; typo'd variable name like FOUNDRY_ENDPOINT.","solutions":["Set FOUNDRY_BASE_PATH to your Foundry Local endpoint (e.g. http://localhost:5273/v1) in .env and restart the server","Run `foundry model list` or check the Foundry Local service is actually listening, then use that port in the path","In Docker, point FOUNDRY_BASE_PATH at host.docker.internal:<port> instead of localhost and pass the var into the container","Double-check the exact variable name FOUNDRY_BASE_PATH"],"exampleFix":"# before (.env)\n# FOUNDRY_BASE_PATH not set\n\n# after (.env)\nFOUNDRY_BASE_PATH=http://localhost:5273/v1","handlingStrategy":"validation","validationCode":"if (!process.env.FOUNDRY_BASE_PATH) {\n  return setupError(\"Set FOUNDRY_BASE_PATH (e.g. http://localhost:5273/v1) to use Foundry Local.\");\n}\nconst llm = new FoundryLLM(embedder, modelPref);","typeGuard":null,"tryCatchPattern":"try {\n  const llm = new FoundryLLM(embedder, modelPref);\n} catch (err) {\n  if (err.message === \"No Foundry Base Path was set.\") {\n    return respond(\"Configure FOUNDRY_BASE_PATH before using Foundry Local.\");\n  }\n  throw err;\n}","preventionTips":["Probe the Foundry service URL (curl <base>/models) at provider selection time","In containers, remember localhost points inside the container — use host.docker.internal","Group provider env validation into a boot-time report"],"tags":["foundry-local","missing-env-var","constructor","local-inference"],"backgroundTag":"missing-env-var","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}