Mintplex-Labs/anything-llm · error · Error

CometAPI API Key must be provided to use agents.

Error message

CometAPI API Key must be provided to use agents.

What it means

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.

Source

Thrown at server/utils/agents/index.js:249

          throw new Error(
            "NVIDIA NIM base path must be provided to use agents."
          );
        break;
      case "ppio":
        if (!process.env.PPIO_API_KEY)
          throw new Error("PPIO API Key must be provided to use agents.");
        break;
      case "gemini":
        if (!process.env.GEMINI_API_KEY)
          throw new Error("Gemini API key must be provided to use agents.");
        break;
      case "moonshotai":
        if (!process.env.MOONSHOT_AI_MODEL_PREF)
          throw new Error("Moonshot AI model must be set to use agents.");
        break;
      case "cometapi":
        if (!process.env.COMETAPI_LLM_API_KEY)
          throw new Error("CometAPI API Key must be provided to use agents.");
        break;
      case "foundry":
        if (!process.env.FOUNDRY_BASE_PATH)
          throw new Error("Foundry base path must be provided to use agents.");
        break;
      case "giteeai":
        if (!process.env.GITEE_AI_API_KEY)
          throw new Error("GiteeAI API Key must be provided to use agents.");
        break;
      case "cohere":
        if (!process.env.COHERE_API_KEY)
          throw new Error("Cohere API key must be provided to use agents.");
        break;
      case "docker-model-runner":
        if (!process.env.DOCKER_MODEL_RUNNER_BASE_PATH)
          throw new Error(
            "Docker Model Runner base path must be provided to use agents."
          );

View on GitHub (pinned to 526360e320)

Solutions

  1. Create an API key in the CometAPI dashboard and set COMETAPI_LLM_API_KEY in .env.
  2. Restart AnythingLLM to reload process.env.
  3. Validate the key with curl -H 'Authorization: Bearer $COMETAPI_LLM_API_KEY' against the CometAPI models endpoint.
  4. Confirm the agent model is a CometAPI-supported model id.

Example fix

// before (.env)
// COMETAPI_LLM_API_KEY=

// after (.env)
COMETAPI_LLM_API_KEY=...your-cometapi-key
Defensive patterns

Strategy: validation

Validate before calling

const key = process.env.COMETAPI_LLM_API_KEY;
if (!key) {
  throw new Error(
    'Cannot start CometAPI agent: set COMETAPI_LLM_API_KEY (from the CometAPI dashboard) in .env.'
  );
}

Try / catch

try {
  await agentHandler.start();
} catch (e) {
  if (/CometAPI API Key must be provided/.test(e.message)) {
    return respondConfigError('cometapi', ['COMETAPI_LLM_API_KEY']);
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/145df1bc344f0545. Report an issue: GitHub.