{"record":{"id":"bb0d39a2907f6cd5","repo":"Mintplex-Labs/anything-llm","slug":"no-cohere-api-key-was-set-bb0d39","errorCode":null,"errorMessage":"No Cohere API key was set.","messagePattern":"No Cohere API key was set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/EmbeddingEngines/cohere/index.js","lineNumber":6,"sourceCode":"const { toChunks, reportEmbeddingProgress } = require(\"../../helpers\");\n\nclass CohereEmbedder {\n  constructor() {\n    if (!process.env.COHERE_API_KEY)\n      throw new Error(\"No Cohere API key was set.\");\n    this.className = \"CohereEmbedder\";\n\n    // Cohere exposes an OpenAI-compatible API which lets us reuse the OpenAI SDK\n    // across the app instead of the cohere-ai package. The compatibility endpoint\n    // manages the embedding `input_type` internally so we do not set it ourselves.\n    // https://docs.cohere.com/docs/compatibility-api\n    const { OpenAI: OpenAIApi } = require(\"openai\");\n    this.openai = new OpenAIApi({\n      baseURL: \"https://api.cohere.ai/compatibility/v1\",\n      apiKey: process.env.COHERE_API_KEY,\n    });\n\n    this.model = process.env.EMBEDDING_MODEL_PREF || \"embed-english-v3.0\";\n\n    // Limit of how many strings we can process in a single pass to stay with resource or network limits\n    this.maxConcurrentChunks = 96; // Cohere's limit per request is 96\n    this.embeddingMaxChunkLength = 1945; // https://docs.cohere.com/docs/embed-2 - assume a token is roughly 4 letters with some padding\n  }","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/EmbeddingEngines/cohere/index.js#L1-L24","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function assertCohereEnv() {\n  if (!process.env.COHERE_API_KEY) {\n    throw new Error('Missing env COHERE_API_KEY');\n  }\n}\nassertCohereEnv();","typeGuard":null,"tryCatchPattern":"try {\n  new CohereEmbedder();\n} catch (e) {\n  if (/cohere api key/i.test(e.message)) { /* surface config error */ }\n  throw e;\n}","preventionTips":["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."],"tags":["cohere","embeddings","config","env","auth","startup"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}