{"record":{"id":"45d4beb183836819","repo":"Mintplex-Labs/anything-llm","slug":"cohere-api-key-must-be-provided-to-use-agents","errorCode":null,"errorMessage":"Cohere API key must be provided to use agents.","messagePattern":"Cohere API key must be provided to use agents\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/agents/index.js","lineNumber":261,"sourceCode":"      case \"moonshotai\":\n        if (!process.env.MOONSHOT_AI_MODEL_PREF)\n          throw new Error(\"Moonshot AI model must be set to use agents.\");\n        break;\n      case \"cometapi\":\n        if (!process.env.COMETAPI_LLM_API_KEY)\n          throw new Error(\"CometAPI API Key must be provided to use agents.\");\n        break;\n      case \"foundry\":\n        if (!process.env.FOUNDRY_BASE_PATH)\n          throw new Error(\"Foundry base path must be provided to use agents.\");\n        break;\n      case \"giteeai\":\n        if (!process.env.GITEE_AI_API_KEY)\n          throw new Error(\"GiteeAI API Key must be provided to use agents.\");\n        break;\n      case \"cohere\":\n        if (!process.env.COHERE_API_KEY)\n          throw new Error(\"Cohere API key must be provided to use agents.\");\n        break;\n      case \"docker-model-runner\":\n        if (!process.env.DOCKER_MODEL_RUNNER_BASE_PATH)\n          throw new Error(\n            \"Docker Model Runner base path must be provided to use agents.\"\n          );\n        break;\n      case \"privatemode\":\n        if (!process.env.PRIVATEMODE_LLM_BASE_PATH)\n          throw new Error(\n            \"Privatemode base path must be provided to use agents.\"\n          );\n        break;\n      case \"sambanova\":\n        if (!process.env.SAMBANOVA_LLM_API_KEY)\n          throw new Error(\"SambaNova API key must be provided to use agents.\");\n        break;\n      case \"lemonade\":","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/index.js#L243-L279","documentation":"Thrown by checkSetup() (server/utils/agents/index.js:128) when the resolved agent provider is 'cohere' but process.env.COHERE_API_KEY is unset/empty. It is a precondition gate in agent.init() ensuring the Cohere client is never built without an API key.","triggerScenarios":"A chat turn calls agent.init(); this.provider resolves to 'cohere'; case 'cohere' runs and process.env.COHERE_API_KEY is falsy.","commonSituations":"Cohere selected as agent provider but the key was not saved; key removed/expired and not rotated into .env; server not restarted after .env change.","solutions":["Set COHERE_API_KEY in .env to a valid Cohere key and restart the server.","Confirm the process loaded the key (check exit code/status of a probe, never print the value).","Switch provider if Cohere is no longer intended."],"exampleFix":"// before (.env)\nCOHERE_API_KEY=\n// after (.env)\nCOHERE_API_KEY=<your-cohere-key>","handlingStrategy":"validation","validationCode":"function assertCohereReady(workspaceAgentProvider) {\n  const using = workspaceAgentProvider === 'cohere' || process.env.LLM_PROVIDER === 'cohere';\n  if (using && !process.env.COHERE_API_KEY)\n    throw new Error('COHERE_API_KEY missing - set it before starting an agent.');\n}","typeGuard":null,"tryCatchPattern":"try { await agent.init(); } catch (e) { if (/Cohere API key must be provided/.test(e.message)) return showProviderConfig('cohere'); throw e; }","preventionTips":["Map each provider to its required env and validate at boot.","Restart after .env edits.","Never log key values."],"tags":["config","env","agent-provider","cohere","api-key","agents"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}