{"record":{"id":"ff2e6dab5a876fc7","repo":"Mintplex-Labs/anything-llm","slug":"no-deepseek-api-key-was-set","errorCode":null,"errorMessage":"No DeepSeek API key was set.","messagePattern":"No DeepSeek API key was set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/AiProviders/deepseek/index.js","lineNumber":13,"sourceCode":"const { NativeEmbedder } = require(\"../../EmbeddingEngines/native\");\nconst {\n  LLMPerformanceMonitor,\n} = require(\"../../helpers/chat/LLMPerformanceMonitor\");\nconst { MODEL_MAP } = require(\"../modelMap\");\nconst {\n  handleDefaultStreamResponseV2,\n} = require(\"../../helpers/chat/responses\");\n\nclass DeepSeekLLM {\n  constructor(embedder = null, modelPreference = null) {\n    if (!process.env.DEEPSEEK_API_KEY)\n      throw new Error(\"No DeepSeek API key was set.\");\n    this.className = \"DeepSeekLLM\";\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n\n    this.openai = new OpenAIApi({\n      apiKey: process.env.DEEPSEEK_API_KEY,\n      baseURL: \"https://api.deepseek.com/v1\",\n    });\n    this.model =\n      modelPreference || process.env.DEEPSEEK_MODEL_PREF || \"deepseek-chat\";\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();\n    this.defaultTemp = 0.7;\n    this.log(","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/AiProviders/deepseek/index.js#L1-L31","documentation":"Constructor guard that prevents DeepSeekLLM instantiation when DEEPSEEK_API_KEY is missing from the environment. The key is required to configure the OpenAI-compatible client pointed at https://api.deepseek.com/v1, so the class aborts immediately if it cannot authenticate.","triggerScenarios":"Instantiating `new DeepSeekLLM()` with DEEPSEEK_API_KEY unset or empty; selecting DeepSeek as the LLM provider without saving an API key; env var name typo (e.g. DEEPSEEKKEY vs DEEPSEEK_API_KEY).","commonSituations":"New deployment that selected DeepSeek but never entered a key; .env not reloaded after adding the key; key was revoked on the DeepSeek platform; container restart with an env file that omits the variable.","solutions":["Set DEEPSEEK_API_KEY in the .env file to a valid key from platform.deepseek.com.","Restart the server so the process picks up the new env var.","Re-enter the key in the AnythingLLM UI DeepSeek provider settings and save."],"exampleFix":"# .env\nDEEPSEEK_API_KEY=sk-your-deepseek-key-here","handlingStrategy":"validation","validationCode":"const DEEPSEEK_KEY = process.env.DEEPSEEK_API_KEY;\nif (!DEEPSEEK_KEY || DEEPSEEK_KEY.trim() === '')\n  throw new Error('DEEPSEEK_API_KEY must be set before using the DeepSeek provider');","typeGuard":null,"tryCatchPattern":"try {\n  provider = new DeepSeekLLM(embedder, modelPref);\n} catch (e) {\n  if (/No DeepSeek API key/i.test(e.message))\n    return respondConfigError('Set DEEPSEEK_API_KEY in the DeepSeek provider settings.');\n  throw e;\n}","preventionTips":["Validate the key on startup with a health-check endpoint.","Store the key in .env and confirm dotenv loads it.","Re-enter the key in the UI provider settings after any rotation."],"tags":["deepseek","missing-api-key","constructor-guard","env-var"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}