Mintplex-Labs/anything-llm · error · Error

No Cohere API key was set.

Error message

No Cohere API key was set.

What it means

Configuration guard thrown by the CohereEmbedder constructor: the Cohere embedding engine was selected but the COHERE_API_KEY environment variable is empty/unset, so the OpenAI-compatible Cohere endpoint cannot be authenticated.

Solutions

  1. Set the Cohere API key in embedder settings.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at embedder construction when no Cohere API key is configured.

Common situations: Cohere embedder selected without an API key.


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/bb0d39a2907f6cd5. Report an issue: GitHub.

Appendix: source

Thrown at server/utils/EmbeddingEngines/cohere/index.js:6

const { toChunks, reportEmbeddingProgress } = require("../../helpers");

class CohereEmbedder {
  constructor() {
    if (!process.env.COHERE_API_KEY)
      throw new Error("No Cohere API key was set.");
    this.className = "CohereEmbedder";

    // Cohere exposes an OpenAI-compatible API which lets us reuse the OpenAI SDK
    // across the app instead of the cohere-ai package. The compatibility endpoint
    // manages the embedding `input_type` internally so we do not set it ourselves.
    // https://docs.cohere.com/docs/compatibility-api
    const { OpenAI: OpenAIApi } = require("openai");
    this.openai = new OpenAIApi({
      baseURL: "https://api.cohere.ai/compatibility/v1",
      apiKey: process.env.COHERE_API_KEY,
    });

    this.model = process.env.EMBEDDING_MODEL_PREF || "embed-english-v3.0";

    // Limit of how many strings we can process in a single pass to stay with resource or network limits
    this.maxConcurrentChunks = 96; // Cohere's limit per request is 96
    this.embeddingMaxChunkLength = 1945; // https://docs.cohere.com/docs/embed-2 - assume a token is roughly 4 letters with some padding
  }

View on GitHub (pinned to 3aec848f28)