Mintplex-Labs/anything-llm · error · Error

Anthropic API key must be provided to use agents.

Error message

Anthropic API key must be provided to use agents.

What it means

Setup guard in checkSetup(): provider is 'anthropic' but ANTHROPIC_API_KEY is unset. The agent framework cannot authenticate to Anthropic, so initialization is aborted before any API call is attempted. This is a missing-configuration sentinel keyed on the selected provider.

Solutions

  1. Set the ANTHROPIC_API_KEY environment variable.
  2. Or select a different agent provider.
Defensive patterns

Strategy: validation

When it happens

Trigger: Anthropic was selected as the agent provider but no API key is configured.

Common situations: This error is raised at runtime in server/utils/agents/index.js. It occurs when the required configuration for this provider is missing or invalid (unset environment variables, empty API key or base path), when the external service is unreachable or returns an unexpected response, or when invalid input reaches the call site. To prevent it, validate the relevant provider settings and environment variables at startup and confirm the service is reachable before this code path executes.


AI-assisted analysis of Mintplex-Labs/anything-llm@20f6d3546c (2026-08-18). Data as JSON: /api/errors/415cc66a3b08c589. Report an issue: GitHub.

Appendix: source

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

          }
        );
      });
      return agentHistory;
    } catch (e) {
      this.log("Error loading chat history", e.message);
      return [];
    }
  }

  checkSetup() {
    switch (this.provider) {
      case "openai":
        if (!process.env.OPEN_AI_KEY)
          throw new Error("OpenAI API key must be provided to use agents.");
        break;
      case "anthropic":
        if (!process.env.ANTHROPIC_API_KEY)
          throw new Error("Anthropic API key must be provided to use agents.");
        break;
      case "lmstudio":
        if (!process.env.LMSTUDIO_BASE_PATH)
          throw new Error("LMStudio base path must be provided to use agents.");
        break;
      case "ollama":
        if (!process.env.OLLAMA_BASE_PATH)
          throw new Error("Ollama base path must be provided to use agents.");
        break;
      case "groq":
        if (!process.env.GROQ_API_KEY)
          throw new Error("Groq API key must be provided to use agents.");
        break;
      case "togetherai":
        if (!process.env.TOGETHER_AI_API_KEY)
          throw new Error("TogetherAI API key must be provided to use agents.");
        break;
      case "azure":

View on GitHub (pinned to 20f6d3546c)