Mintplex-Labs/anything-llm · error · Error
Voyage AI failed to embed: Rate limit reached
Error message
Voyage AI failed to embed: Rate limit reached
What it means
A heuristic reinterpretation thrown inside embedChunks' catch block. Voyage AI's LangChain connector does not always surface rate-limit responses as a clean 429; under throttling embedDocuments can throw a TypeError ('Cannot read properties of undefined (reading 0)') when the SDK tries to index into an empty/absent response body. This code pattern-matches that opaque message and rewrites it to a human-readable rate-limit error. Any other error message is re-thrown unchanged.
Source
Thrown at server/utils/EmbeddingEngines/voyageAi/index.js:63
);
// If given an array return the native Array[Array] format since that should be the outcome.
// But if given a single string, we need to flatten it so that we have a 1D array.
return (Array.isArray(textInput) ? result : result.flat()) || [];
}
async embedChunks(textChunks = []) {
try {
const embeddings = await this.voyage.embedDocuments(textChunks);
return embeddings;
} catch (error) {
console.error("Voyage AI Failed to embed:", error);
if (
error.message.includes(
"Cannot read properties of undefined (reading '0')"
)
)
throw new Error("Voyage AI failed to embed: Rate limit reached");
throw error;
}
}
}
module.exports = {
VoyageAiEmbedder,
};
View on GitHub (pinned to 526360e320)
Solutions
- Wait and retry — Voyage rate limits reset on a rolling window; reduce the number of chunks embedded concurrently.
- Upgrade your Voyage AI plan to raise RPM/TPM ceilings.
- If the raw TypeError leaks (SDK version changed the wording), this is a catch-gap bug — report it; meanwhile treat any TypeError from embedChunks as a likely throttle.
- Pre-aggregate small chunks to reduce total request count against the RPM limit.
Example fix
// before: fire-and-forget on a huge workspace, hits throttle
await embedder.embedChunks(allChunks);
// after: batch with delay to respect RPM
const BATCH = 128;
for (let i = 0; i < allChunks.length; i += BATCH) {
await embedder.embedChunks(allChunks.slice(i, i + BATCH));
await new Promise(r => setTimeout(r, 1000)); // throttle pacing
} Defensive patterns
Strategy: retry
Validate before calling
// No pre-call validation can detect a server-side rate limit.
// Instead, cap batch cadence to stay under Voyage RPM:
const MAX_RPM = 50; // example ceiling — set to your plan's limit
let callsThisMinute = 0;
function canCall() { return callsThisMinute < MAX_RPM; } Type guard
/** @param {unknown} e */
function isVoyageRateLimit(e) {
return e instanceof Error && /Voyage AI failed to embed: Rate limit reached/.test(e.message);
} Try / catch
async function embedWithRetry(chunks, retries = 3) {
for (let i = 0; i < retries; i++) {
try { return await embedder.embedChunks(chunks); }
catch (e) {
if (/Rate limit reached/.test(e.message) && i < retries - 1) {
await new Promise(r => setTimeout(r, 2000 * (i + 1))); // exponential backoff
continue;
}
throw e;
}
}
} Prevention
- Pace embed calls to stay under your Voyage plan's RPM/TPM.
- Treat any TypeError from embedChunks as a probable throttle (the heuristic only matches one wording).
- Reduce total request count by merging tiny chunks.
- Upgrade the Voyage tier for higher concurrency when embedding large workspaces.
When it happens
Trigger: Calling embedChunks when Voyage AI throttles the request (RPM or TPM exceeded, batchSize capped at 128 per request). Specifically when the underlying error.message exactly equals 'Cannot read properties of undefined (reading 0)'. The batchSize of 128 matches Voyage's documented per-request limit, so large workspaces fire many sequential batches that accumulate against the rate limit.
Common situations: Embedding a large workspace against a low Voyage AI tier; concurrent embedding jobs sharing the same key; using voyage-3-lite at scale on the free/trial quota; the SDK version returning a differently-worded TypeError (in which case the raw TypeError leaks through instead of this friendly message).
Related errors
- OpenRouter Failed to embed: ${error}
- No Voyage AI API key was set.
- Could not find indexes.
- No Azure API endpoint was set.
- No Azure API key was set.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/66abed9bbf5f8114.
Report an issue: GitHub.