Mintplex-Labs/anything-llm · critical · Error
No DeepSeek API key was set.
Error message
No DeepSeek API key was set.
What it means
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.
Source
Thrown at server/utils/AiProviders/deepseek/index.js:13
const { NativeEmbedder } = require("../../EmbeddingEngines/native");
const {
LLMPerformanceMonitor,
} = require("../../helpers/chat/LLMPerformanceMonitor");
const { MODEL_MAP } = require("../modelMap");
const {
handleDefaultStreamResponseV2,
} = require("../../helpers/chat/responses");
class DeepSeekLLM {
constructor(embedder = null, modelPreference = null) {
if (!process.env.DEEPSEEK_API_KEY)
throw new Error("No DeepSeek API key was set.");
this.className = "DeepSeekLLM";
const { OpenAI: OpenAIApi } = require("openai");
this.openai = new OpenAIApi({
apiKey: process.env.DEEPSEEK_API_KEY,
baseURL: "https://api.deepseek.com/v1",
});
this.model =
modelPreference || process.env.DEEPSEEK_MODEL_PREF || "deepseek-chat";
this.limits = {
history: this.promptWindowLimit() * 0.15,
system: this.promptWindowLimit() * 0.15,
user: this.promptWindowLimit() * 0.7,
};
this.embedder = embedder ?? new NativeEmbedder();
this.defaultTemp = 0.7;
this.log(View on GitHub (pinned to 526360e320)
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.
Example fix
# .env DEEPSEEK_API_KEY=sk-your-deepseek-key-here
Defensive patterns
Strategy: validation
Validate before calling
const DEEPSEEK_KEY = process.env.DEEPSEEK_API_KEY;
if (!DEEPSEEK_KEY || DEEPSEEK_KEY.trim() === '')
throw new Error('DEEPSEEK_API_KEY must be set before using the DeepSeek provider'); Try / catch
try {
provider = new DeepSeekLLM(embedder, modelPref);
} catch (e) {
if (/No DeepSeek API key/i.test(e.message))
return respondConfigError('Set DEEPSEEK_API_KEY in the DeepSeek provider settings.');
throw e;
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- No CometAPI API key was set.
- No FireworksAI API key was set.
- No Docker Model Runner API Base Path was set.
- No Docker Model Runner Model Pref was set.
- DeepSeek chat: ${this.model} is not valid for chat completio
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/ff2e6dab5a876fc7.
Report an issue: GitHub.