{"record":{"id":"8366325ee0dd2f24","repo":"vercel/ai","slug":"too-many-values-for-a-single-embedding-call-the-836632","errorCode":null,"errorMessage":"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.","messagePattern":"Too many values for a single embedding call\\. The (.+?) model \"(.+?)\" can only embed up to (.+?) values per call, but (.+?) values were provided\\.","errorType":"exception","errorClass":"TooManyEmbeddingValuesForCallError","httpStatus":null,"severity":"error","filePath":"packages/voyage/src/voyage-embedding-model.ts","lineNumber":76,"sourceCode":"    return this.config.provider;\n  }\n\n  async doEmbed({\n    values,\n    headers,\n    abortSignal,\n    providerOptions,\n  }: Parameters<EmbeddingModelV4['doEmbed']>[0]): Promise<\n    Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>\n  > {\n    const embeddingOptions = await parseProviderOptions({\n      provider: 'voyage',\n      providerOptions,\n      schema: voyageEmbeddingModelOptions,\n    });\n\n    if (values.length > this.maxEmbeddingsPerCall) {\n      throw new TooManyEmbeddingValuesForCallError({\n        provider: this.provider,\n        modelId: this.modelId,\n        maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,\n        values,\n      });\n    }\n\n    const {\n      responseHeaders,\n      value: response,\n      rawValue,\n    } = await postJsonToApi({\n      url: `${this.config.baseURL}/embeddings`,\n      headers: combineHeaders(this.config.headers?.(), headers),\n      body: {\n        input: values,\n        model: this.modelId,\n        input_type: embeddingOptions?.inputType,","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/voyage/src/voyage-embedding-model.ts#L58-L94","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nawait embedMany({ model: voyage.textEmbeddingModel('voyage-3'), values: bigArray });\n// after\nawait embedMany({\n  model: voyage.textEmbeddingModel('voyage-3'),\n  values: bigArray,\n  maxEmbeddingsPerCall: 128,\n});","handlingStrategy":"validation","validationCode":"const MAX = 128;\nif (values.length > MAX) {\n  throw new Error(`Voyage embeds at most ${MAX} values per call; got ${values.length}.`);\n}","typeGuard":"null","tryCatchPattern":"try {\n  await embed({ model, values });\n} catch (error) {\n  if (TooManyEmbeddingValuesForCallError.isInstance(error)) {\n    // chunk values and retry\n  } else throw error;\n}","preventionTips":["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."],"tags":["embeddings","limit-exceeded","voyage","api-misuse"],"backgroundTag":"batch-size-limit-exceeded","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}