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

  1. Split values into chunks of at most 128 and call embed per chunk (or set embedMany's maxEmbeddingsPerCall accordingly).
  2. Set maxEmbeddingsPerCall: 128 in the embedMany settings so batching is automatic.
  3. Add validation of values.length before calling embed.
  4. 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

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


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/8366325ee0dd2f24. Report an issue: GitHub.