n8n-io/n8n · error · OperationalError
NVIDIA embeddings API returned ${data.length} embeddings for
Error message
NVIDIA embeddings API returned ${data.length} embeddings for a batch of ${expected} inputs What it means
An OperationalError raised while flattening NVIDIA embeddings batch responses: each batch must return exactly one embedding per input so the caller can zip them by position. If data.length !== expected for any batch, embedding alignment would be corrupted, so the helper fails loudly instead of silently shifting vectors.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/embeddings/EmbeddingsNvidia/helpers.ts:70
model: this.model,
input: batch,
input_type: inputType,
};
if (this.dimensions) params.dimensions = this.dimensions;
if (this.encodingFormat) params.encoding_format = this.encodingFormat;
const { data } = await this.embeddingWithRetry(params);
return { expected: batch.length, data };
});
const batchResponses = await Promise.all(batchRequests);
// The caller maps each input text to the embedding at the same position, so every batch must
// return exactly one embedding per input. Flatten by input position (like the base class) and
// fail loudly on a malformed response rather than silently dropping or shifting embeddings.
const embeddings: number[][] = [];
for (const { expected, data } of batchResponses) {
if (data.length !== expected) {
throw new OperationalError(
`NVIDIA embeddings API returned ${data.length} embeddings for a batch of ${expected} inputs`,
);
}
for (const entry of data) {
embeddings.push(entry.embedding);
}
}
return embeddings;
}
}
View on GitHub (pinned to 5ac6606e81)
Solutions
- Reduce the batch size (chunk documents before calling embedDocuments) to stay under the NVIDIA model's limit.
- Sanitise inputs — remove empty/whitespace strings and de-duplicate before embedding, then re-expand the result.
- Confirm the NVIDIA model id is an embeddings model (e.g. NV-Embed-QA, nvidia/embedqa-4).
- Retry once; if intermittent, lower concurrency or add maxRetries/timeout options.
Defensive patterns
Strategy: validation
Validate before calling
// Chunk inputs to a safe batch size before calling embedDocuments
const MAX_BATCH = 16; // consult NVIDIA model docs
for (let i = 0; i < documents.length; i += MAX_BATCH) {
const batch = documents.slice(i, i + MAX_BATCH).filter(d => d.trim().length > 0);
// ... call embedWithRetry(batch)
} Type guard
const matchesBatchSize = (data: unknown[], expected: number): boolean => Array.isArray(data) && data.length === expected;
Try / catch
try {
return embedBatch(batch);
} catch (e) {
if (/returned \d+ embeddings for a batch of/i.test((e as Error).message)) {
// retry with batch size 1 to localise the failing input
return batch.map(one => embedBatch([one])[0]);
}
throw e;
} Prevention
- Cap batch size below the NVIDIA model's documented maximum.
- Sanitise and de-duplicate inputs before embedding.
- Confirm the model id is an embeddings model before invoking.
When it happens
Trigger: NVIDIA's /v1/embeddings endpoint returns fewer or more entries than the number of input texts in a batch — caused by the API dropping empty inputs, deduplicating identical texts, a rate-limit returning a partial body, or a model cap on batch size that truncates the response.
Common situations: Sending a batch larger than the model's max batch size; sending duplicate or whitespace-only strings the API collapses; endpoint misbehaviour under load; using a non-embedding NVIDIA model that returns a single aggregate vector.
Related errors
- Unexpected embedding response from Bedrock
- Cannot embed empty or undefined text
- Documents must be an array
- Model output doesn't fit required format
- Model output doesn't fit required format
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/05bd1b56db80f3b5.
Report an issue: GitHub.