{"record":{"id":"415cc66a3b08c589","repo":"Mintplex-Labs/anything-llm","slug":"anthropic-api-key-must-be-provided-to-use-agents","errorCode":null,"errorMessage":"Anthropic API key must be provided to use agents.","messagePattern":"Anthropic API key must be provided to use agents\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/agents/index.js","lineNumber":136,"sourceCode":"          }\n        );\n      });\n      return agentHistory;\n    } catch (e) {\n      this.log(\"Error loading chat history\", e.message);\n      return [];\n    }\n  }\n\n  checkSetup() {\n    switch (this.provider) {\n      case \"openai\":\n        if (!process.env.OPEN_AI_KEY)\n          throw new Error(\"OpenAI API key must be provided to use agents.\");\n        break;\n      case \"anthropic\":\n        if (!process.env.ANTHROPIC_API_KEY)\n          throw new Error(\"Anthropic API key must be provided to use agents.\");\n        break;\n      case \"lmstudio\":\n        if (!process.env.LMSTUDIO_BASE_PATH)\n          throw new Error(\"LMStudio base path must be provided to use agents.\");\n        break;\n      case \"ollama\":\n        if (!process.env.OLLAMA_BASE_PATH)\n          throw new Error(\"Ollama base path must be provided to use agents.\");\n        break;\n      case \"groq\":\n        if (!process.env.GROQ_API_KEY)\n          throw new Error(\"Groq API key must be provided to use agents.\");\n        break;\n      case \"togetherai\":\n        if (!process.env.TOGETHER_AI_API_KEY)\n          throw new Error(\"TogetherAI API key must be provided to use agents.\");\n        break;\n      case \"azure\":","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/index.js#L118-L154","documentation":"checkSetup() (index.js:134-137) throws for provider === \"anthropic\" when process.env.ANTHROPIC_API_KEY is falsy. The agent layer refuses to proceed rather than sending an unauthenticated request.","triggerScenarios":"Selecting the anthropic agent provider while ANTHROPIC_API_KEY is unset or empty in the server environment.","commonSituations":"Anthropic provider chosen without configuring the key, a renamed env var, or a deployment that didn't propagate the secret to the server container.","solutions":["Set ANTHROPIC_API_KEY in .env to a valid Anthropic API key.","Restart the server so the env is reloaded.","For Docker, inject the key via the compose env block or -e.","Confirm the key is active in the Anthropic console."],"exampleFix":"# before (.env)\n# ANTHROPIC_API_KEY=\n\n# after (.env)\nANTHROPIC_API_KEY=sk-ant-...validkey...","handlingStrategy":"validation","validationCode":"function anthropicAgentReady() {\n  return Boolean(process.env.ANTHROPIC_API_KEY && process.env.ANTHROPIC_API_KEY.trim());\n}\nif (provider === \"anthropic\" && !anthropicAgentReady())\n  throw new Error(\"Set ANTHROPIC_API_KEY before enabling the anthropic agent.\");","typeGuard":null,"tryCatchPattern":"try {\n  agent.checkSetup();\n} catch (e) {\n  if (/ANTHROPIC_API_KEY|API key must be provided/i.test(e.message)) {\n    throw new Error(\"Anthropic agent is not configured: set ANTHROPIC_API_KEY in .env and restart.\");\n  }\n  throw e;\n}","preventionTips":["Call checkSetup() at boot to fail fast.","Restart the server after setting the key.","Inject secrets via Docker env, never bake them into images.","Confirm the key is active in the Anthropic console."],"tags":["anthropic","config","env","auth","agents"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}