Mintplex-Labs/anything-llm · critical · Error

No Voyage AI API key was set.

Error message

No Voyage AI API key was set.

What it means

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.

Source

Thrown at server/utils/EmbeddingEngines/voyageAi/index.js:4

class VoyageAiEmbedder {
  constructor() {
    if (!process.env.VOYAGEAI_API_KEY)
      throw new Error("No Voyage AI API key was set.");

    const {
      VoyageEmbeddings,
    } = require("@langchain/community/embeddings/voyage");

    this.model = process.env.EMBEDDING_MODEL_PREF || "voyage-3-lite";
    this.voyage = new VoyageEmbeddings({
      apiKey: process.env.VOYAGEAI_API_KEY,
      modelName: this.model,
      // Voyage AI's limit per request is 128 https://docs.voyageai.com/docs/rate-limits#use-larger-batches
      batchSize: 128,
    });
    this.embeddingMaxChunkLength = this.#getMaxEmbeddingLength();
  }

  // https://docs.voyageai.com/docs/embeddings
  #getMaxEmbeddingLength() {
    switch (this.model) {

View on GitHub (pinned to 526360e320)

Solutions

  1. Set VOYAGEAI_API_KEY in your environment / .env to a valid key from https://dash.voyageai.com/.
  2. Restart the server after setting the env var so the constructor re-reads it.
  3. If using Docker, ensure the variable is passed via -e or your compose env_file.
  4. Verify the exact variable name is VOYAGEAI_API_KEY (not VOYAGE_API_KEY).

Example fix

# before
# .env
EMBEDDING_ENGINE=voyageai
# (missing key)

# after
# .env
EMBEDDING_ENGINE=voyageai
VOYAGEAI_API_KEY=pa-xxxxxxxxxxxxxxxxxxxxxxxx
Defensive patterns

Strategy: validation

Validate before calling

function hasVoyageKey() {
  return typeof process.env.VOYAGEAI_API_KEY === 'string' && process.env.VOYAGEAI_API_KEY.length > 0;
}
// before constructing:
if (!hasVoyageKey()) {
  throw new Error('Set VOYAGEAI_API_KEY before selecting Voyage AI embeddings.');
}

Type guard

function isVoyageConfigured() {
  return !!process.env.VOYAGEAI_API_KEY && process.env.VOYAGEAI_API_KEY.trim().length > 0;
}

Try / catch

// Constructor throws synchronously — wrap instantiation, not the async call
let embedder;
try {
  embedder = new VoyageAiEmbedder();
} catch (e) {
  console.error('Voyage not configured:', e.message);
  return; // or fall back to another embedder
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/5602cd785cd7bc8d. Report an issue: GitHub.