{"record":{"id":"d0a829932f0e724d","repo":"Mintplex-Labs/anything-llm","slug":"koboldcpp-must-have-a-valid-base-path-to-use-for-t","errorCode":null,"errorMessage":"KoboldCPP must have a valid base path to use for the api.","messagePattern":"KoboldCPP must have a valid base path to use for the api\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/AiProviders/koboldCPP/index.js","lineNumber":16,"sourceCode":"const { NativeEmbedder } = require(\"../../EmbeddingEngines/native\");\nconst {\n  clientAbortedHandler,\n  writeResponseChunk,\n  formatChatHistory,\n} = require(\"../../helpers/chat/responses\");\nconst {\n  LLMPerformanceMonitor,\n} = require(\"../../helpers/chat/LLMPerformanceMonitor\");\nconst { v4: uuidv4 } = require(\"uuid\");\n\nclass KoboldCPPLLM {\n  constructor(embedder = null, modelPreference = null) {\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n    if (!process.env.KOBOLD_CPP_BASE_PATH)\n      throw new Error(\n        \"KoboldCPP must have a valid base path to use for the api.\"\n      );\n\n    this.className = \"KoboldCPPLLM\";\n    this.basePath = process.env.KOBOLD_CPP_BASE_PATH;\n    this.openai = new OpenAIApi({\n      baseURL: this.basePath,\n      apiKey: null,\n    });\n    this.model = modelPreference ?? process.env.KOBOLD_CPP_MODEL_PREF ?? null;\n    if (!this.model) throw new Error(\"KoboldCPP must have a valid model set.\");\n    this.limits = {\n      history: this.promptWindowLimit() * 0.15,\n      system: this.promptWindowLimit() * 0.15,\n      user: this.promptWindowLimit() * 0.7,\n    };\n\n    this.embedder = embedder ?? new NativeEmbedder();","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/koboldCPP/index.js#L1-L34","documentation":"Thrown by the KoboldCPPLLM constructor when process.env.KOBOLD_CPP_BASE_PATH is unset. KoboldCPP exposes an OpenAI-compatible endpoint when run with its --openai compatible mode; AnythingLLM needs that URL as the OpenAI client baseURL. Without it the provider cannot target the local KoboldCPP server.","triggerScenarios":"Constructing `new KoboldCPPLLM(embedder, modelPreference)` while KOBOLD_CPP_BASE_PATH is absent. Fires at provider selection when the user picked KoboldCPP but supplied no endpoint.","commonSituations":"KoboldCPP started without the --openai flag (so no compatible endpoint); .env missing the line; wrong port in the URL; KoboldCPP process not running; path missing the /v1 suffix.","solutions":["Start KoboldCPP with OpenAI-compatible mode and set KOBOLD_CPP_BASE_PATH to its URL, e.g. http://localhost:5001/v1","Confirm KoboldCPP is listening with curl $KOBOLD_CPP_BASE_PATH/models","Restart AnythingLLM after editing .env","Ensure the URL includes the version path the OpenAI client expects"],"exampleFix":"// before\n// .env: KOBOLD_CPP_MODEL_PREF=<loaded model>   // no base path\n\n// after\n// .env:\n//   KOBOLD_CPP_BASE_PATH=http://localhost:5001/v1\n//   KOBOLD_CPP_MODEL_PREF=<loaded model>","handlingStrategy":"validation","validationCode":"function hasKoboldBasePath() {\n  try {\n    const u = new URL(process.env.KOBOLD_CPP_BASE_PATH);\n    return u.protocol.startsWith('http');\n  } catch { return false; }\n}\nif (!hasKoboldBasePath()) {\n  throw new ConfigError('Start KoboldCPP in OpenAI mode and set KOBOLD_CPP_BASE_PATH.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Start KoboldCPP with its OpenAI-compatible flag before configuring AnythingLLM","Validate the URL parses as http(s) and includes the version path","Ping GET $KOBOLD_CPP_BASE_PATH/models at setup"],"tags":["koboldcpp","configuration","environment-variables","local-inference","constructor"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}