{"record":{"id":"145df1bc344f0545","repo":"Mintplex-Labs/anything-llm","slug":"cometapi-api-key-must-be-provided-to-use-agents","errorCode":null,"errorMessage":"CometAPI API Key must be provided to use agents.","messagePattern":"CometAPI API Key must be provided to use agents\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/agents/index.js","lineNumber":249,"sourceCode":"          throw new Error(\n            \"NVIDIA NIM base path must be provided to use agents.\"\n          );\n        break;\n      case \"ppio\":\n        if (!process.env.PPIO_API_KEY)\n          throw new Error(\"PPIO API Key must be provided to use agents.\");\n        break;\n      case \"gemini\":\n        if (!process.env.GEMINI_API_KEY)\n          throw new Error(\"Gemini API key must be provided to use agents.\");\n        break;\n      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          );","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agents/index.js#L231-L267","documentation":"Thrown by AgentHandler.checkSetup() (server/utils/agents/index.js:248) when the workspace agent provider is 'cometapi' but COMETAPI_LLM_API_KEY is unset/empty. CometAPI is a hosted LLM gateway behind this single key, which is the only credential the guard validates.","triggerScenarios":"An agent invocation runs with workspace.agentProvider === 'cometapi' while COMETAPI_LLM_API_KEY is absent from process.env. Path: #providerSetupAndCheck() -> checkSetup() at index.js:476.","commonSituations":"CometAPI selected in System > LLM Preference without a key; key from the CometAPI dashboard not pasted into .env; .env edited but the server not restarted; key revoked.","solutions":["Create an API key in the CometAPI dashboard and set COMETAPI_LLM_API_KEY in .env.","Restart AnythingLLM to reload process.env.","Validate the key with curl -H 'Authorization: Bearer $COMETAPI_LLM_API_KEY' against the CometAPI models endpoint.","Confirm the agent model is a CometAPI-supported model id."],"exampleFix":"// before (.env)\n// COMETAPI_LLM_API_KEY=\n\n// after (.env)\nCOMETAPI_LLM_API_KEY=...your-cometapi-key","handlingStrategy":"validation","validationCode":"const key = process.env.COMETAPI_LLM_API_KEY;\nif (!key) {\n  throw new Error(\n    'Cannot start CometAPI agent: set COMETAPI_LLM_API_KEY (from the CometAPI dashboard) in .env.'\n  );\n}","typeGuard":null,"tryCatchPattern":"try {\n  await agentHandler.start();\n} catch (e) {\n  if (/CometAPI API Key must be provided/.test(e.message)) {\n    return respondConfigError('cometapi', ['COMETAPI_LLM_API_KEY']);\n  }\n  throw e;\n}","preventionTips":["Create the key in the CometAPI dashboard and paste it into .env in one step.","Restart AnythingLLM so process.env reloads.","Add a startup provider->env-var validator.","Keep .env out of version control; rotate keys periodically."],"tags":["agents","llm-provider","cometapi","api-key","environment-variables","config"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}