Mintplex-Labs/anything-llm · critical · Error
No Cohere API key was set.
Error message
No Cohere API key was set.
What it means
Thrown in the CohereEmbedder constructor when process.env.COHERE_API_KEY is falsy. Cohere is used via its OpenAI-compatible endpoint (https://api.cohere.ai/compatibility/v1) through the OpenAI SDK, so the key gates client construction.
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 526360e320)
Solutions
- Set COHERE_API_KEY to a valid key from https://dashboard.cohere.com.
- Use the exact var name COHERE_API_KEY and restart the process.
- Confirm the key has embed scope/permission in the Cohere dashboard.
- Verify the var reaches the running process (log the boolean, not the value).
Defensive patterns
Strategy: validation
Validate before calling
function assertCohereEnv() {
if (!process.env.COHERE_API_KEY) {
throw new Error('Missing env COHERE_API_KEY');
}
}
assertCohereEnv(); Try / catch
try {
new CohereEmbedder();
} catch (e) {
if (/cohere api key/i.test(e.message)) { /* surface config error */ }
throw e;
} Prevention
- Use the exact name COHERE_API_KEY (no _EMBEDDING_ segment).
- Confirm the key has embed permission in the Cohere dashboard.
- Restart the process after setting the var.
When it happens
Trigger: Constructing CohereEmbedder while COHERE_API_KEY is unset/empty; selecting Cohere embeddings before provisioning a production key; using a trial key name under a different env var.
Common situations: Confusing COHERE_API_KEY with COHERE_EMBEDDING_API_KEY or another provider's key; .env not reloaded; CI without secrets; key revoked after usage policy change.
Related errors
- No Azure API key was set.
- No Gemini API key was set.
- No xAI API key was set.
- No Z.AI API key was set.
- No Azure API endpoint was set.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/bb0d39a2907f6cd5.
Report an issue: GitHub.