{"record":{"id":"8319981ad2c580a3","repo":"vercel/ai","slug":"ai-toomanyembeddingvaluesforcallerror-831998","errorCode":"AI_TooManyEmbeddingValuesForCallError","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/amazon-bedrock/src/amazon-bedrock-embedding-model.ts","lineNumber":79,"sourceCode":"\n  constructor(\n    readonly modelId: AmazonBedrockEmbeddingModelId,\n    private readonly config: AmazonBedrockEmbeddingConfig,\n  ) {}\n\n  private getUrl(modelId: string): string {\n    const encodedModelId = encodeURIComponent(modelId);\n    return `${this.config.baseUrl()}/model/${encodedModelId}/invoke`;\n  }\n\n  async doEmbed({\n    values,\n    headers,\n    abortSignal,\n    providerOptions,\n  }: Parameters<EmbeddingModelV4['doEmbed']>[0]): Promise<DoEmbedResponse> {\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    // Parse provider options. Prefer `amazonBedrock`; fall back to legacy\n    // `bedrock` key for backward compatibility.\n    const amazonBedrockOptions =\n      (await parseProviderOptions({\n        provider: 'amazonBedrock',\n        providerOptions,\n        schema: amazonBedrockEmbeddingModelOptionsSchema,\n      })) ??\n      (await parseProviderOptions({\n        provider: 'bedrock',\n        providerOptions,","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/amazon-bedrock/src/amazon-bedrock-embedding-model.ts#L61-L97","documentation":"Bedrock embedding models accept only maxEmbeddingsPerCall values per doEmbed request. When you pass more values than the model's per-call limit, the SDK throws AI_TooManyEmbeddingValuesForCallError instead of silently truncating. The `embedMany` helper normally batches automatically; this error surfaces when calling the model's doEmbed directly or when batch size is forced.","triggerScenarios":"Calling embedMany/embed with more input values than the model's maxEmbeddingsPerCall (Bedrock Titan models commonly cap at 1–32), or calling model.doEmbed directly with an oversized array.","commonSituations":"Batching thousands of documents into a single embed call; copying code from another provider whose models allow 2048 inputs per call; overriding maxEmbeddingsPerCall or using maxCallsPerRound/maxEntriesPerCall options incorrectly.","solutions":["Split your inputs into chunks no larger than the model's maxEmbeddingsPerCall (embedMany does this automatically — pass the full array to embedMany rather than calling doEmbed directly)","Check model.maxEmbeddingsPerCall before calling doEmbed and slice your values array accordingly","Use the top-level embed()/embedMany() API instead of the low-level doEmbed method","If you need larger batches, pick a Bedrock embedding model with a higher per-call limit"],"exampleFix":"// before\nawait model.doEmbed({ values: docs }); // 500 docs, limit 32\n// after\nconst BATCH = model.maxEmbeddingsPerCall;\nfor (let i = 0; i < docs.length; i += BATCH) {\n  await model.doEmbed({ values: docs.slice(i, i + BATCH) });\n}","handlingStrategy":"validation","validationCode":"const max = model.maxEmbeddingsPerCall;\nif (values.length > max) throw new Error(`Chunk inputs to <= ${max} values per call`);\n// or: chunk and call per chunk","typeGuard":null,"tryCatchPattern":"try {\n  await embedMany({ model, values });\n} catch (e) {\n  if (TooManyEmbeddingValuesForCallError.isInstance(e)) {\n    // chunk values by e.maxEmbeddingsPerCall and retry\n  }\n}","preventionTips":["Prefer embedMany/embed over direct doEmbed — it batches automatically","Check model.maxEmbeddingsPerCall before manual batching"],"tags":["embeddings","bedrock","batching","limits"],"backgroundTag":"embedding-batch-size-exceeded","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}