{"record":{"id":"6758eeab49cc18cb","repo":"supermemoryai/supermemory","slug":"supermemory-api-key-is-not-set-provide-it-via-o-6758ee","errorCode":null,"errorMessage":"SUPERMEMORY_API_KEY is not set — provide it via `options.apiKey` or set `process.env.SUPERMEMORY_API_KEY`","messagePattern":"SUPERMEMORY_API_KEY is not set — provide it via `options\\.apiKey` or set `process\\.env\\.SUPERMEMORY_API_KEY`","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"packages/tools/src/voltagent/middleware.ts","lineNumber":73,"sourceCode":"\t\trelatedMemories?: boolean\n\t\tsummaries?: boolean\n\t}\n\t// Storage parameters\n\tmetadata?: Record<string, string | number | boolean>\n\tsearchMode?: \"memories\" | \"documents\" | \"hybrid\"\n\tentityContext?: string\n}\n\n/**\n * Creates a Supermemory middleware context.\n */\nexport const createSupermemoryContext = (\n\tcontainerTag: string,\n\toptions: SupermemoryVoltAgent,\n): SupermemoryMiddlewareContext => {\n\tconst apiKey = options.apiKey ?? process.env.SUPERMEMORY_API_KEY\n\tif (!apiKey) {\n\t\tthrow new Error(\n\t\t\t\"SUPERMEMORY_API_KEY is not set — provide it via `options.apiKey` or set `process.env.SUPERMEMORY_API_KEY`\",\n\t\t)\n\t}\n\n\tconst {\n\t\tcustomId,\n\t\tmode = \"profile\",\n\t\taddMemory = \"always\", // VoltAgent default: save conversations by default for chat apps\n\t\tbaseUrl,\n\t\tpromptTemplate,\n\t\tthreshold,\n\t\tlimit,\n\t\trerank,\n\t\trewriteQuery,\n\t\tfilters,\n\t\tinclude,\n\t\tmetadata,\n\t\tsearchMode,","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/supermemoryai/supermemory/blob/d436792e777a99865939dd543c8d1a16d57f54ec/packages/tools/src/voltagent/middleware.ts#L55-L91","documentation":"createSupermemoryContext (VoltAgent middleware) resolves the API key from options.apiKey or process.env.SUPERMEMORY_API_KEY and throws immediately when absent, preventing middleware construction without credentials.","triggerScenarios":"Creating the Supermemory VoltAgent middleware without passing apiKey in an environment where SUPERMEMORY_API_KEY is not set.","commonSituations":"Env var present in dev shell but missing in the deployed agent runtime (Docker, serverless, orchestrator); .env file not copied into container; CI runs.","solutions":["Set SUPERMEMORY_API_KEY in the agent's runtime environment","Pass apiKey explicitly in the SupermemoryVoltAgent options","For containers, ensure the var is declared in compose/k8s/compose env mapping"],"exampleFix":"// before\ncreateSupermemoryContext('user-1', { customId: 'c1' })\n\n// after\ncreateSupermemoryContext('user-1', {\n  customId: 'c1',\n  apiKey: process.env.SUPERMEMORY_API_KEY!,\n})","handlingStrategy":"validation","validationCode":"if (!process.env.SUPERMEMORY_API_KEY && !options.apiKey) throw new Error('configure SUPERMEMORY_API_KEY in the agent runtime')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare env vars explicitly in Docker/k8s/serverless manifests","Run a config sanity check at agent startup"],"tags":["env-var","auth","voltagent","configuration","supermemory"],"backgroundTag":"missing-env-var","analyzedSha":"d436792e777a99865939dd543c8d1a16d57f54ec","analyzedAt":"2026-08-28T18:04:46.947Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}