Mintplex-Labs/anything-llm · critical · Error
KoboldCPP must have a valid base path to use for the api.
Error message
KoboldCPP must have a valid base path to use for the api.
What it means
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.
Source
Thrown at server/utils/AiProviders/koboldCPP/index.js:16
const { NativeEmbedder } = require("../../EmbeddingEngines/native");
const {
clientAbortedHandler,
writeResponseChunk,
formatChatHistory,
} = require("../../helpers/chat/responses");
const {
LLMPerformanceMonitor,
} = require("../../helpers/chat/LLMPerformanceMonitor");
const { v4: uuidv4 } = require("uuid");
class KoboldCPPLLM {
constructor(embedder = null, modelPreference = null) {
const { OpenAI: OpenAIApi } = require("openai");
if (!process.env.KOBOLD_CPP_BASE_PATH)
throw new Error(
"KoboldCPP must have a valid base path to use for the api."
);
this.className = "KoboldCPPLLM";
this.basePath = process.env.KOBOLD_CPP_BASE_PATH;
this.openai = new OpenAIApi({
baseURL: this.basePath,
apiKey: null,
});
this.model = modelPreference ?? process.env.KOBOLD_CPP_MODEL_PREF ?? null;
if (!this.model) throw new Error("KoboldCPP must have a valid model set.");
this.limits = {
history: this.promptWindowLimit() * 0.15,
system: this.promptWindowLimit() * 0.15,
user: this.promptWindowLimit() * 0.7,
};
this.embedder = embedder ?? new NativeEmbedder();View on GitHub (pinned to 526360e320)
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
Example fix
// before // .env: KOBOLD_CPP_MODEL_PREF=<loaded model> // no base path // after // .env: // KOBOLD_CPP_BASE_PATH=http://localhost:5001/v1 // KOBOLD_CPP_MODEL_PREF=<loaded model>
Defensive patterns
Strategy: validation
Validate before calling
function hasKoboldBasePath() {
try {
const u = new URL(process.env.KOBOLD_CPP_BASE_PATH);
return u.protocol.startsWith('http');
} catch { return false; }
}
if (!hasKoboldBasePath()) {
throw new ConfigError('Start KoboldCPP in OpenAI mode and set KOBOLD_CPP_BASE_PATH.');
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No Foundry Base Path was set.
- 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.
- No Groq API key was set.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/d0a829932f0e724d.
Report an issue: GitHub.