{"record":{"id":"ad7cd5d90108b75d","repo":"Mintplex-Labs/anything-llm","slug":"no-cometapi-api-key-was-set","errorCode":null,"errorMessage":"No CometAPI API key was set.","messagePattern":"No CometAPI API key was set\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/utils/AiProviders/cometapi/index.js","lineNumber":25,"sourceCode":"} = require(\"../../helpers/chat/responses\");\nconst fs = require(\"fs\");\nconst path = require(\"path\");\nconst { safeJsonParse } = require(\"../../http\");\nconst {\n  LLMPerformanceMonitor,\n} = require(\"../../helpers/chat/LLMPerformanceMonitor\");\nconst { COMETAPI_IGNORE_PATTERNS } = require(\"./constants\");\nconst cacheFolder = path.resolve(\n  process.env.STORAGE_DIR\n    ? path.resolve(process.env.STORAGE_DIR, \"models\", \"cometapi\")\n    : path.resolve(__dirname, `../../../storage/models/cometapi`)\n);\n\nclass CometApiLLM {\n  defaultTimeout = 3_000;\n  constructor(embedder = null, modelPreference = null) {\n    if (!process.env.COMETAPI_LLM_API_KEY)\n      throw new Error(\"No CometAPI API key was set.\");\n\n    this.className = \"CometApiLLM\";\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n    this.basePath = \"https://api.cometapi.com/v1\";\n    this.openai = new OpenAIApi({\n      baseURL: this.basePath,\n      apiKey: process.env.COMETAPI_LLM_API_KEY ?? null,\n      defaultHeaders: {\n        \"HTTP-Referer\": \"https://anythingllm.com\",\n        \"X-CometAPI-Source\": \"anythingllm\",\n      },\n    });\n    this.model =\n      modelPreference || process.env.COMETAPI_LLM_MODEL_PREF || \"gpt-5-mini\";\n    this.limits = {\n      history: this.promptWindowLimit() * 0.15,\n      system: this.promptWindowLimit() * 0.15,\n      user: this.promptWindowLimit() * 0.7,","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/AiProviders/cometapi/index.js#L7-L43","documentation":"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.","triggerScenarios":"Thrown at provider construction when no CometAPI key is configured.","commonSituations":"CometAPI selected as LLM provider without an API key.","solutions":["Set the CometAPI API key in provider settings or env."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}