mem0ai/mem0 · error · Error
DeepSeek LLM failed: ${message}
Error message
DeepSeek LLM failed: ${message} What it means
Thrown by DeepSeekLLM.generateResponse when the inherited OpenAILLM call to DeepSeek's OpenAI-compatible API fails for any reason. The wrapper preserves the original error text after the 'DeepSeek LLM failed:' prefix, so the suffix identifies whether it was auth (401), rate limit (429), model issues, JSON mode problems, or network.
Source
Thrown at mem0-ts/src/oss/src/llms/deepseek.ts:31
apiKey,
baseURL:
config.baseURL ||
process.env.DEEPSEEK_API_BASE ||
"https://api.deepseek.com",
model: config.model || "deepseek-chat",
});
}
async generateResponse(
messages: Message[],
responseFormat?: { type: string },
tools?: any[],
): Promise<string | LLMResponse> {
try {
return await super.generateResponse(messages, responseFormat, tools);
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
throw new Error(`DeepSeek LLM failed: ${message}`);
}
}
async generateChat(messages: Message[]): Promise<LLMResponse> {
try {
return await super.generateChat(messages);
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
throw new Error(`DeepSeek LLM failed: ${message}`);
}
}
}
View on GitHub (pinned to 001c235229)
Solutions
- Inspect the message after the prefix: 401 → fix the key, 402 → top up balance, 429 → back off, model errors → correct the model string.
- Verify the key works outside mem0: curl https://api.deepseek.com/models with Authorization: Bearer $DEEPSEEK_API_KEY.
- For 429s, wrap calls in exponential-backoff retry (DeepSeek rate limits are per-minute TPM/RPM).
- If using a custom baseURL, confirm the proxy is reachable and OpenAI-compatible from the runtime environment.
- Confirm the model value: defaults to deepseek-chat; deepseek-reasoner rejects some parameters (e.g. temperature).
Example fix
// before
const res = await deepSeekLlm.generateResponse(messages, { type: 'json_object' });
// DeepSeek LLM failed: 402 Insufficient Balance
// after (fail fast on balance/auth, retry on transient 429)
try {
const res = await deepSeekLlm.generateResponse(messages, { type: 'json_object' });
} catch (e) {
const msg = e instanceof Error ? e.message : String(e);
if (msg.includes('402') || msg.includes('401')) throw e; // fatal: billing/auth
if (msg.includes('429')) await backoffThenRetry(() => deepSeekLlm.generateResponse(messages));
else throw e;
} Defensive patterns
Strategy: retry
Validate before calling
async function deepSeekReachable(base = 'https://api.deepseek.com') {
const r = await fetch(`${base}/models`, { headers: { Authorization: `Bearer ${process.env.DEEPSEEK_API_KEY}` } });
if (r.status === 401) throw new Error('DeepSeek key invalid');
if (r.status === 402) throw new Error('DeepSeek balance exhausted');
return r.ok;
} Type guard
function isDeepSeekFatal(err: unknown): boolean {
const m = err instanceof Error ? err.message : String(err);
return m.startsWith('DeepSeek LLM failed:') && /401|402|invalid/i.test(m);
} Try / catch
try {
return await deepSeekLlm.generateResponse(messages, responseFormat);
} catch (err) {
const msg = String(err);
if (/429|timeout|ECONN/i.test(msg)) return retry(fn, { retries: 3 });
throw err; // 401/402/model errors are fatal
} Prevention
- Monitor DeepSeek credit balance; 402 surfaces as this wrapped error.
- Pin the model you validated (deepseek-chat vs deepseek-reasoner) and its supported params.
- Add circuit-breaking around memory.add loops that fan out many LLM calls.
When it happens
Trigger: Calling generateResponse() on DeepSeekLLM (directly or via Memory.add/search/ update flows) when DeepSeek returns 401 invalid key, 402 insufficient balance, 429 rate limit, an invalid model name, a malformed responseFormat for JSON mode, or when the network call to https://api.deepseek.com fails or times out.
Common situations: Expired or revoked DeepSeek key; DeepSeek account out of credits (402 is common on the free-trial exhaustion); switching model between deepseek-chat and deepseek-reasoner with parameters only one supports; concurrent requests exceeding the per-key rate limit; custom DEEPSEEK_API_BASE pointing at a proxy that returns HTML errors.
Related errors
- DeepSeek API key is required
- LiteLLM failed: ${message}
- LM Studio LLM failed: ${message}
- MiniMax LLM failed: ${message}
- Sarvam LLM failed: ${message}
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/833414bf94aa5bfa.
Report an issue: GitHub.