mem0ai/mem0 · critical
Zero Entropy API key is required. Set ZERO_ENTROPY_API_KEY e
Error message
Zero Entropy API key is required. Set ZERO_ENTROPY_API_KEY environment variable or pass apiKey in config.
What it means
Thrown by the ZeroEntropyReranker constructor when neither config.apiKey nor the ZERO_ENTROPY_API_KEY environment variable is set. ZeroEntropy's rerank API (default model zerank-1) requires authentication; the check happens at construction time when RerankerFactory builds the reranker from the memory config. The zeroentropy npm peer dependency is imported lazily, so the key is the only early failure.
Source
Thrown at mem0-ts/src/oss/src/rerankers/zeroentropy.ts:17
import { RerankerConfig } from "../types";
import { Reranker, RerankResult } from "./base";
import { loadPeer } from "../utils/load_peer";
const DEFAULT_MODEL = "zerank-1";
export class ZeroEntropyReranker implements Reranker {
private clientInstance?: any;
private clientPromise?: Promise<any>;
private readonly apiKey: string;
private model: string;
private topK?: number;
constructor(config: RerankerConfig) {
const apiKey = config.apiKey || process.env.ZERO_ENTROPY_API_KEY;
if (!apiKey) {
throw new Error(
"Zero Entropy API key is required. Set ZERO_ENTROPY_API_KEY environment variable or pass apiKey in config.",
);
}
this.apiKey = apiKey;
this.model = config.model || DEFAULT_MODEL;
this.topK = config.topK;
}
/**
* Lazily construct (or reuse) the ZeroEntropy client, importing the
* optional `zeroentropy` peer only when the reranker is first used so
* consumers that never touch ZeroEntropy don't need it installed.
*/
private async getClient(): Promise<any> {
if (this.clientInstance) return this.clientInstance;
if (!this.clientPromise) {
this.clientPromise = this.createClient();
}View on GitHub (pinned to 001c235229)
Solutions
- Set ZERO_ENTROPY_API_KEY in the runtime environment of the process
- Or pass it explicitly: reranker: { provider: 'zeroentropy', config: { apiKey: process.env.ZERO_ENTROPY_API_KEY } }
- Add a boot-time env assertion so misconfiguration fails at startup, not at first rerank
Example fix
// before
const memory = new Memory({ reranker: { provider: 'zeroentropy', config: {} } });
// after
const memory = new Memory({
reranker: { provider: 'zeroentropy', config: { apiKey: process.env.ZERO_ENTROPY_API_KEY } },
}); Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.ZERO_ENTROPY_API_KEY) {
throw new Error('ZERO_ENTROPY_API_KEY is not set — reranker unavailable');
} Try / catch
try { new Memory({ ...config, reranker: { provider: 'zeroentropy', config: {} } }); } catch (e) { if (e instanceof Error && e.message.includes('ZERO_ENTROPY_API_KEY')) { /* degrade to no reranker */ } else throw e; } Prevention
- Fail fast on missing secrets at boot with a startup checklist
- Copy the exact env var name (ZERO_ENTROPY_API_KEY with underscores) into every deployment target
When it happens
Trigger: Configuring reranker: { provider: 'zeroentropy', config: {...} } with no apiKey while ZERO_ENTROPY_API_KEY is absent from the process environment — env var missing in the deployed container, set in a shell the process never inherited, or misnamed.
Common situations: Secrets defined locally but not in Docker/CI/production; .env loaded after Memory construction; key name typo (ZEROENTROPY_API_KEY); new deployment target without copied secrets.
Related errors
- Cohere API key is required. Set COHERE_API_KEY environment v
- Zero Entropy API key is required. Set ZERO_ENTROPY_API_KEY e
- Cohere API key is required. Set COHERE_API_KEY environment v
- Unsupported reranker provider: ${provider}
- PGVector requires either connectionString or ${missingFields
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/c0a2824d7a9a4ca3.
Report an issue: GitHub.