Mintplex-Labs/anything-llm · critical · Error
No Foundry Base Path was set.
Error message
No Foundry Base Path was set.
What it means
Thrown by the FoundryLLM constructor when process.env.FOUNDRY_BASE_PATH is unset. Foundry Local is Microsoft's on-device inference runtime that exposes an OpenAI-compatible HTTP endpoint; AnythingLLM needs that endpoint URL (later passed through parseFoundryBasePath) to construct its internal OpenAI client. Without a base path there is no server to route completions to, so the provider refuses to instantiate.
Source
Thrown at server/utils/AiProviders/foundry/index.js:30
const { OpenAI: OpenAIApi } = require("openai");
const ToolCallTextFilter = require("./toolCallFilter.js");
class FoundryLLM {
/**
* The largest context window we will select on the user's behalf.
* Foundry runs on the user's own machine with no performance setting, so a
* model advertising 128K would make an average laptop crawl. A user who
* explicitly sets a larger limit still gets it, up to the model's real window.
* @type {number}
*/
static MAX_DEFAULT_CONTEXT_WINDOW = 16_000;
/** @see FoundryLLM.cacheContextWindows */
static modelContextWindows = {};
constructor(embedder = null, modelPreference = null) {
if (!process.env.FOUNDRY_BASE_PATH)
throw new Error("No Foundry Base Path was set.");
this.className = "FoundryLLM";
this.model = modelPreference || process.env.FOUNDRY_MODEL_PREF;
this.openai = new OpenAIApi({
baseURL: parseFoundryBasePath(process.env.FOUNDRY_BASE_PATH),
apiKey: null,
});
this.embedder = embedder ?? new NativeEmbedder();
this.defaultTemp = 0.7;
this.limits = null;
FoundryLLM.cacheContextWindows(true);
this.#log(`Loaded with model: ${this.model}`);
}
static #slog(text, ...args) {
console.log(`\x1b[36m[FoundryLLM]\x1b[0m ${text}`, ...args);
}View on GitHub (pinned to 526360e320)
Solutions
- Set FOUNDRY_BASE_PATH in .env (or the provider settings UI) to your Foundry Local OpenAI endpoint, e.g. http://localhost:5273/v1
- Confirm Foundry Local is installed and running with `foundry --status` (or the tray app) before starting AnythingLLM
- Restart the AnythingLLM server so the new environment variable is loaded into process.env
- Verify the endpoint with `curl $FOUNDRY_BASE_PATH/models` to confirm it answers before configuring AnythingLLM
Example fix
// before (server/.env has no Foundry vars) // selecting Foundry Local in the UI throws on construction // after // server/.env // FOUNDRY_BASE_PATH=http://localhost:5273/v1 // FOUNDRY_MODEL_PREF=Phi-3-mini-4k-instruct-cuda
Defensive patterns
Strategy: validation
Validate before calling
// before constructing the provider
function canUseFoundry() {
return Boolean(process.env.FOUNDRY_BASE_PATH);
}
if (!canUseFoundry()) {
// surface a user-facing config error instead of letting the constructor throw
throw new ConfigError('Set FOUNDRY_BASE_PATH to your Foundry Local endpoint.');
} Prevention
- Keep all FOUNDRY_* keys in a single block in .env and validate that block on startup
- Add a pre-flight check that pings $FOUNDRY_BASE_PATH/models before registering the provider
- Surface missing-env errors in the provider-settings UI rather than at first chat
When it happens
Trigger: Constructing `new FoundryLLM(embedder, modelPreference)` at provider-selection time while FOUNDRY_BASE_PATH is absent from process.env. In AnythingLLM this fires the moment a user picks the Foundry Local LLM provider but never supplied the endpoint in the UI or .env.
Common situations: Foundry Local not yet installed or not running; the .env file has no FOUNDRY_BASE_PATH line; the user selected Foundry as the provider before finishing setup; a Docker/PM2 deployment that did not pass the env var through to the process.
Related errors
- KoboldCPP must have a valid base path to use for the api.
- Could not load ${this.model} into Foundry Local: ${error}
- No Gemini API key was set.
- GenericOpenAI must have a valid base path to use for the api
- No Gitee AI API key was set.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/45e0054ed9fa3b0e.
Report an issue: GitHub.