Mintplex-Labs/anything-llm · error
No CometAPI API key was set.
Error message
No CometAPI API key was set.
What it means
Constructor guard in CometApiLLM: the COMETAPI_LLM_API_KEY (or equivalent) environment variable is unset, so the CometAPI client cannot be authenticated and provider construction fails before any model or chat operation.
Solutions
- Set the CometAPI API key in provider settings or env.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at provider construction when no CometAPI key is configured.
Common situations: CometAPI selected as LLM provider without an API key.
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/ad7cd5d90108b75d.
Report an issue: GitHub.
Appendix: source
Thrown at server/utils/AiProviders/cometapi/index.js:25
} = require("../../helpers/chat/responses");
const fs = require("fs");
const path = require("path");
const { safeJsonParse } = require("../../http");
const {
LLMPerformanceMonitor,
} = require("../../helpers/chat/LLMPerformanceMonitor");
const { COMETAPI_IGNORE_PATTERNS } = require("./constants");
const cacheFolder = path.resolve(
process.env.STORAGE_DIR
? path.resolve(process.env.STORAGE_DIR, "models", "cometapi")
: path.resolve(__dirname, `../../../storage/models/cometapi`)
);
class CometApiLLM {
defaultTimeout = 3_000;
constructor(embedder = null, modelPreference = null) {
if (!process.env.COMETAPI_LLM_API_KEY)
throw new Error("No CometAPI API key was set.");
this.className = "CometApiLLM";
const { OpenAI: OpenAIApi } = require("openai");
this.basePath = "https://api.cometapi.com/v1";
this.openai = new OpenAIApi({
baseURL: this.basePath,
apiKey: process.env.COMETAPI_LLM_API_KEY ?? null,
defaultHeaders: {
"HTTP-Referer": "https://anythingllm.com",
"X-CometAPI-Source": "anythingllm",
},
});
this.model =
modelPreference || process.env.COMETAPI_LLM_MODEL_PREF || "gpt-5-mini";
this.limits = {
history: this.promptWindowLimit() * 0.15,
system: this.promptWindowLimit() * 0.15,
user: this.promptWindowLimit() * 0.7,View on GitHub (pinned to 3aec848f28)