{"record":{"id":"df5d53c602137a81","repo":"vercel/ai","slug":"amazon-bedrock-request-was-moderated-reasons-jo","errorCode":null,"errorMessage":"Amazon Bedrock request was moderated: ${reasons.join(', ')}","messagePattern":"Amazon Bedrock request was moderated: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/amazon-bedrock/src/amazon-bedrock-image-model.ts","lineNumber":279,"sourceCode":"      body: args,\n      failedResponseHandler: createJsonErrorResponseHandler({\n        errorSchema: AmazonBedrockErrorSchema,\n        errorToMessage: error => `${error.type}: ${error.message}`,\n      }),\n      successfulResponseHandler: createJsonResponseHandler(\n        amazonBedrockImageResponseSchema,\n      ),\n      abortSignal,\n      fetch: this.config.fetch,\n    });\n\n    // Handle moderated/blocked requests\n    if (response.status === 'Request Moderated') {\n      const moderationReasons = response.details?.['Moderation Reasons'];\n      const reasons = Array.isArray(moderationReasons)\n        ? moderationReasons\n        : ['Unknown'];\n      throw new Error(\n        `Amazon Bedrock request was moderated: ${reasons.join(', ')}`,\n      );\n    }\n\n    // Check if images are present\n    if (!response.images || response.images.length === 0) {\n      throw new Error(\n        'Amazon Bedrock returned no images. ' +\n          (response.status ? `Status: ${response.status}` : ''),\n      );\n    }\n\n    return {\n      images: response.images,\n      warnings,\n      response: {\n        timestamp: currentDate,\n        modelId: this.modelId,","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/amazon-bedrock/src/amazon-bedrock-image-model.ts#L261-L297","documentation":"Nova Canvas can return a response whose status is 'Request Moderated', meaning Bedrock's content moderation blocked the prompt (and optionally images). The provider reads details['Moderation Reasons'] and throws with the joined reasons so the developer knows why generation was refused. This is a provider-side policy rejection, not an SDK malfunction.","triggerScenarios":"generateImage with a bedrock image model where the prompt (or reference images) trips Amazon Bedrock's content moderation guardrails, producing response.status === 'Request Moderated'.","commonSituations":"Prompts containing violence, sexual content, real-person likenesses, or other policy-sensitive content; occasionally false positives on borderline wording; regional policy differences.","solutions":["Reword the prompt to remove policy-sensitive content and retry","Remove or replace reference images that may trigger moderation","Read the moderation reasons in the error message and adjust accordingly","If you believe it's a false positive, test the same prompt directly in the Bedrock console and contact AWS if confirmed"],"exampleFix":"// before\nawait generateImage({ model, prompt: 'graphic violent battle scene' });\n// after\nawait generateImage({ model, prompt: 'epic fantasy warriors, stylized illustration' });","handlingStrategy":"try-catch","validationCode":"// pre-screen prompts client-side against your content policy before sending","typeGuard":null,"tryCatchPattern":"try {\n  await generateImage({ model, prompt });\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Amazon Bedrock request was moderated')) {\n    // surface the reasons to the user / sanitize the prompt\n  }\n}","preventionTips":["Screen prompts for policy-sensitive content before calling the API","Show moderation reasons from the error message to end users","Keep reference images policy-compliant"],"tags":["bedrock","image-generation","content-moderation"],"backgroundTag":"content-moderated","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}