{"record":{"id":"3bcfb50bc62c06fa","repo":"Mintplex-Labs/anything-llm","slug":"no-lemonade-model-pref-was-set","errorCode":null,"errorMessage":"No Lemonade Model Pref was set.","messagePattern":"No Lemonade Model Pref was set\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/lemonade/index.js","lineNumber":17,"sourceCode":"const { NativeEmbedder } = require(\"../../EmbeddingEngines/native\");\nconst {\n  handleDefaultStreamResponseV2,\n  formatChatHistory,\n} = require(\"../../helpers/chat/responses\");\nconst {\n  LLMPerformanceMonitor,\n} = require(\"../../helpers/chat/LLMPerformanceMonitor\");\nconst { OpenAI: OpenAIApi } = require(\"openai\");\nconst { humanFileSize } = require(\"../../helpers\");\n\nclass LemonadeLLM {\n  constructor(embedder = null, modelPreference = null) {\n    if (!process.env.LEMONADE_LLM_BASE_PATH)\n      throw new Error(\"No Lemonade API Base Path was set.\");\n    if (!process.env.LEMONADE_LLM_MODEL_PREF && !modelPreference)\n      throw new Error(\"No Lemonade Model Pref was set.\");\n\n    this.className = \"LemonadeLLM\";\n    this.lemonade = new OpenAIApi({\n      baseURL: parseLemonadeServerEndpoint(\n        process.env.LEMONADE_LLM_BASE_PATH,\n        \"openai\"\n      ),\n      apiKey: process.env.LEMONADE_LLM_API_KEY || null,\n    });\n\n    this.model = modelPreference || process.env.LEMONADE_LLM_MODEL_PREF;\n    this.embedder = embedder ?? new NativeEmbedder();\n    this.defaultTemp = 0.7;\n\n    // We can establish here since we cannot dynamically curl the context window limit from the API.\n    this.limits = {\n      history: this.promptWindowLimit() * 0.15,\n      system: this.promptWindowLimit() * 0.15,","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/AiProviders/lemonade/index.js#L1-L35","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before (.env)\nLEMONADE_LLM_BASE_PATH=http://127.0.0.1:8000\n\n# after (.env)\nLEMONADE_LLM_BASE_PATH=http://127.0.0.1:8000\nLEMONADE_LLM_MODEL_PREF=Llama-3.2-1B-Instruct-Hybrid","handlingStrategy":"validation","validationCode":"const lemonadeModel = modelPreference || process.env.LEMONADE_LLM_MODEL_PREF;\nif (!lemonadeModel) throw new Error(\"Set LEMONADE_LLM_MODEL_PREF or pass modelPreference\");\nconst llm = new LemonadeLLM(embedder, lemonadeModel);","typeGuard":"function hasLemonadeModel(arg) {\n  return typeof (arg || process.env.LEMONADE_LLM_MODEL_PREF) === \"string\" && (arg || process.env.LEMONADE_LLM_MODEL_PREF).length > 0;\n}","tryCatchPattern":"try {\n  new LemonadeLLM(embedder, pref);\n} catch (e) {\n  if (/Lemonade Model Pref/i.test(e.message)) throw new Error(\"LEMONADE_LLM_MODEL_PREF unset — add the loaded model tag\");\n  throw e;\n}","preventionTips":["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."],"tags":["lemonade","anythingllm","model-selection","env-var","configuration"],"backgroundTag":"model-not-configured","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"}