vercel/ai · error · TooManyEmbeddingValuesForCallError
Too many values for a single embedding call. The ${provider}
Error message
Too many values for a single embedding call. The ${provider} model "${modelId}" can only embed up to ${maxEmbeddingsPerCall} values per call, but ${values.length} values were provided. What it means
The Voyage embedding model enforces a hard limit (maxEmbeddingsPerCall = 128) on how many values can be embedded in a single API call; exceeding it throws TooManyEmbeddingValuesForCallError before any request is sent. Higher-level embedMany batch settings must respect this per-call cap.
Source
Thrown at packages/voyage/src/voyage-embedding-model.ts:76
return this.config.provider;
}
async doEmbed({
values,
headers,
abortSignal,
providerOptions,
}: Parameters<EmbeddingModelV4['doEmbed']>[0]): Promise<
Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>
> {
const embeddingOptions = await parseProviderOptions({
provider: 'voyage',
providerOptions,
schema: voyageEmbeddingModelOptions,
});
if (values.length > this.maxEmbeddingsPerCall) {
throw new TooManyEmbeddingValuesForCallError({
provider: this.provider,
modelId: this.modelId,
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
values,
});
}
const {
responseHeaders,
value: response,
rawValue,
} = await postJsonToApi({
url: `${this.config.baseURL}/embeddings`,
headers: combineHeaders(this.config.headers?.(), headers),
body: {
input: values,
model: this.modelId,
input_type: embeddingOptions?.inputType,View on GitHub (pinned to 69428b1f8b)
Solutions
- Split values into chunks of at most 128 and call embed per chunk (or set embedMany's maxEmbeddingsPerCall accordingly).
- Set maxEmbeddingsPerCall: 128 in the embedMany settings so batching is automatic.
- Add validation of values.length before calling embed.
- Compare limits when migrating providers and adjust batch sizes per provider.
Example fix
// before
await embedMany({ model: voyage.textEmbeddingModel('voyage-3'), values: bigArray });
// after
await embedMany({
model: voyage.textEmbeddingModel('voyage-3'),
values: bigArray,
maxEmbeddingsPerCall: 128,
}); Defensive patterns
Strategy: validation
Validate before calling
const MAX = 128;
if (values.length > MAX) {
throw new Error(`Voyage embeds at most ${MAX} values per call; got ${values.length}.`);
} Type guard
null
Try / catch
try {
await embed({ model, values });
} catch (error) {
if (TooManyEmbeddingValuesForCallError.isInstance(error)) {
// chunk values and retry
} else throw error;
} Prevention
- Chunk large value arrays into <=128 before embedding.
- Set maxEmbeddingsPerCall in embedMany so batching is automatic.
- Check per-call limits when switching embedding providers.
- Add startup tests embedding a 129-item batch in CI.
When it happens
Trigger: Calling embed()/embedMany() with more than 128 values for a single call against a Voyage embedding model (or a maxEmbeddingsPerCall configured below the provided count).
Common situations: Bulk embedding of a large document set in one call; migrating from a provider with a higher per-call limit; incorrectly configured batch size in embedMany options.
Related errors
- 'element streams in no-schema mode' functionality not suppor
- 'element streams in object mode' functionality not supported
- 'element streams in enum mode' functionality not supported.
- Unsupported output: ${_exhaustiveCheck}
- Invalid argument for parameter output: Invalid output type.
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/8366325ee0dd2f24.
Report an issue: GitHub.