{"record":{"id":"5602cd785cd7bc8d","repo":"Mintplex-Labs/anything-llm","slug":"no-voyage-ai-api-key-was-set","errorCode":null,"errorMessage":"No Voyage AI API key was set.","messagePattern":"No Voyage AI API key was set\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"server/utils/EmbeddingEngines/voyageAi/index.js","lineNumber":4,"sourceCode":"class VoyageAiEmbedder {\n  constructor() {\n    if (!process.env.VOYAGEAI_API_KEY)\n      throw new Error(\"No Voyage AI API key was set.\");\n\n    const {\n      VoyageEmbeddings,\n    } = require(\"@langchain/community/embeddings/voyage\");\n\n    this.model = process.env.EMBEDDING_MODEL_PREF || \"voyage-3-lite\";\n    this.voyage = new VoyageEmbeddings({\n      apiKey: process.env.VOYAGEAI_API_KEY,\n      modelName: this.model,\n      // Voyage AI's limit per request is 128 https://docs.voyageai.com/docs/rate-limits#use-larger-batches\n      batchSize: 128,\n    });\n    this.embeddingMaxChunkLength = this.#getMaxEmbeddingLength();\n  }\n\n  // https://docs.voyageai.com/docs/embeddings\n  #getMaxEmbeddingLength() {\n    switch (this.model) {","sourceCodeStart":1,"sourceCodeEnd":22,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/EmbeddingEngines/voyageAi/index.js#L1-L22","documentation":"Thrown synchronously in the VoyageAiEmbedder constructor before any LangChain wiring is loaded. It is a hard precondition guard: the class cannot be instantiated without VOYAGEAI_API_KEY because VoyageEmbeddings needs the key for every authenticated request. Requiring @langchain/community happens after this check, so no heavy module loads occur on the failure path.","triggerScenarios":"Instantiating new VoyageAiEmbedder() when process.env.VOYAGEAI_API_KEY is undefined or empty. This happens at provider-selection time when the app constructs the configured embedding engine, typically during workspace embedding or system bootstrapping.","commonSituations":"Selecting Voyage AI as the embedding engine in AnythingLLM settings without pasting an API key; .env file missing VOYAGEAI_API_KEY after deployment; key set under a different variable name (e.g. VOYAGE_API_KEY); running in a container where the env var was not passed through.","solutions":["Set VOYAGEAI_API_KEY in your environment / .env to a valid key from https://dash.voyageai.com/.","Restart the server after setting the env var so the constructor re-reads it.","If using Docker, ensure the variable is passed via -e or your compose env_file.","Verify the exact variable name is VOYAGEAI_API_KEY (not VOYAGE_API_KEY)."],"exampleFix":"# before\n# .env\nEMBEDDING_ENGINE=voyageai\n# (missing key)\n\n# after\n# .env\nEMBEDDING_ENGINE=voyageai\nVOYAGEAI_API_KEY=pa-xxxxxxxxxxxxxxxxxxxxxxxx","handlingStrategy":"validation","validationCode":"function hasVoyageKey() {\n  return typeof process.env.VOYAGEAI_API_KEY === 'string' && process.env.VOYAGEAI_API_KEY.length > 0;\n}\n// before constructing:\nif (!hasVoyageKey()) {\n  throw new Error('Set VOYAGEAI_API_KEY before selecting Voyage AI embeddings.');\n}","typeGuard":"function isVoyageConfigured() {\n  return !!process.env.VOYAGEAI_API_KEY && process.env.VOYAGEAI_API_KEY.trim().length > 0;\n}","tryCatchPattern":"// Constructor throws synchronously — wrap instantiation, not the async call\nlet embedder;\ntry {\n  embedder = new VoyageAiEmbedder();\n} catch (e) {\n  console.error('Voyage not configured:', e.message);\n  return; // or fall back to another embedder\n}","preventionTips":["Centralize env-var checks in a startup config validator that runs before provider selection.","Document VOYAGEAI_API_KEY (note the exact spelling) wherever embedding engines are configured.","Add a smoke-test call on boot to fail fast with a clear message."],"tags":["voyage-ai","embeddings","configuration","missing-api-key","constructor"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}