Mintplex-Labs/anything-llm · error
No Lemonade Model Pref was set.
Error message
No Lemonade Model Pref was set.
What it means
LemonadeLLM requires a model id before construction completes: it throws when neither the modelPreference argument nor LEMONADE_LLM_MODEL_PREF is present. The check runs before the OpenAI client is even built, and this.model = modelPreference || LEMONADE_LLM_MODEL_PREF afterwards. Lemonade needs a concrete model tag (e.g., a GGUF/Hybrid variant name it has loaded) for every completion request.
Solutions
- Set LEMONADE_LLM_MODEL_PREF to the exact model tag Lemonade has loaded (query its models endpoint or server logs).
- Or pass the model explicitly: new LemonadeLLM(embedder, "Llama-3.2-1B-Instruct-Hybrid").
- Confirm spelling/case matches the server's registered tag, then restart AnythingLLM.
Example fix
# before (.env) LEMONADE_LLM_BASE_PATH=http://127.0.0.1:8000 # after (.env) LEMONADE_LLM_BASE_PATH=http://127.0.0.1:8000 LEMONADE_LLM_MODEL_PREF=Llama-3.2-1B-Instruct-Hybrid
Defensive patterns
Strategy: validation
Validate before calling
const lemonadeModel = modelPreference || process.env.LEMONADE_LLM_MODEL_PREF;
if (!lemonadeModel) throw new Error("Set LEMONADE_LLM_MODEL_PREF or pass modelPreference");
const llm = new LemonadeLLM(embedder, lemonadeModel); Type guard
function hasLemonadeModel(arg) {
return typeof (arg || process.env.LEMONADE_LLM_MODEL_PREF) === "string" && (arg || process.env.LEMONADE_LLM_MODEL_PREF).length > 0;
} Try / catch
try {
new LemonadeLLM(embedder, pref);
} catch (e) {
if (/Lemonade Model Pref/i.test(e.message)) throw new Error("LEMONADE_LLM_MODEL_PREF unset — add the loaded model tag");
throw e;
} Prevention
- Query Lemonade's models endpoint after server start and store the exact tag in env.
- Treat base path + model as one configuration unit; validate both in a single pre-flight.
- Avoid whitespace-padded values in .env — trim when loading.
When it happens
Trigger: new LemonadeLLM(embedder) with no second argument while LEMONADE_LLM_MODEL_PREF is unset — i.e., choosing the Lemonade provider with only LEMONADE_LLM_BASE_PATH configured. The guard is `!env && !arg`, so unlike KoboldCPP's ?? variant, an empty-string modelPreference here still falls through to env; the throw needs both to be absent.
Common situations: Env templates that ship the base path but comment out the model line; using a model name from a different Lemonade install/version (wrong, but that fails later at HTTP, not here); programmatic construction that assumes a default model exists — Lemonade has none.
Related errors
- KoboldCPP must have a valid model set.
- LiteLLM must have a valid model set.
- LMStudio must have a valid model set.
- No Lemonade API Base Path was set.
- KoboldCPP must have a valid base path to use for the api.
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/3bcfb50bc62c06fa.
Report an issue: GitHub.
Appendix: source
Thrown at server/utils/AiProviders/lemonade/index.js:17
const { NativeEmbedder } = require("../../EmbeddingEngines/native");
const {
handleDefaultStreamResponseV2,
formatChatHistory,
} = require("../../helpers/chat/responses");
const {
LLMPerformanceMonitor,
} = require("../../helpers/chat/LLMPerformanceMonitor");
const { OpenAI: OpenAIApi } = require("openai");
const { humanFileSize } = require("../../helpers");
class LemonadeLLM {
constructor(embedder = null, modelPreference = null) {
if (!process.env.LEMONADE_LLM_BASE_PATH)
throw new Error("No Lemonade API Base Path was set.");
if (!process.env.LEMONADE_LLM_MODEL_PREF && !modelPreference)
throw new Error("No Lemonade Model Pref was set.");
this.className = "LemonadeLLM";
this.lemonade = new OpenAIApi({
baseURL: parseLemonadeServerEndpoint(
process.env.LEMONADE_LLM_BASE_PATH,
"openai"
),
apiKey: process.env.LEMONADE_LLM_API_KEY || null,
});
this.model = modelPreference || process.env.LEMONADE_LLM_MODEL_PREF;
this.embedder = embedder ?? new NativeEmbedder();
this.defaultTemp = 0.7;
// We can establish here since we cannot dynamically curl the context window limit from the API.
this.limits = {
history: this.promptWindowLimit() * 0.15,
system: this.promptWindowLimit() * 0.15,View on GitHub (pinned to 3aec848f28)