vercel/ai · error · Error

Amazon Bedrock request was moderated: ${reasons.join(', ')}

Error message

Amazon Bedrock request was moderated: ${reasons.join(', ')}

What it means

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.

Source

Thrown at packages/amazon-bedrock/src/amazon-bedrock-image-model.ts:279

      body: args,
      failedResponseHandler: createJsonErrorResponseHandler({
        errorSchema: AmazonBedrockErrorSchema,
        errorToMessage: error => `${error.type}: ${error.message}`,
      }),
      successfulResponseHandler: createJsonResponseHandler(
        amazonBedrockImageResponseSchema,
      ),
      abortSignal,
      fetch: this.config.fetch,
    });

    // Handle moderated/blocked requests
    if (response.status === 'Request Moderated') {
      const moderationReasons = response.details?.['Moderation Reasons'];
      const reasons = Array.isArray(moderationReasons)
        ? moderationReasons
        : ['Unknown'];
      throw new Error(
        `Amazon Bedrock request was moderated: ${reasons.join(', ')}`,
      );
    }

    // Check if images are present
    if (!response.images || response.images.length === 0) {
      throw new Error(
        'Amazon Bedrock returned no images. ' +
          (response.status ? `Status: ${response.status}` : ''),
      );
    }

    return {
      images: response.images,
      warnings,
      response: {
        timestamp: currentDate,
        modelId: this.modelId,

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Reword the prompt to remove policy-sensitive content and retry
  2. Remove or replace reference images that may trigger moderation
  3. Read the moderation reasons in the error message and adjust accordingly
  4. If you believe it's a false positive, test the same prompt directly in the Bedrock console and contact AWS if confirmed

Example fix

// before
await generateImage({ model, prompt: 'graphic violent battle scene' });
// after
await generateImage({ model, prompt: 'epic fantasy warriors, stylized illustration' });
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-screen prompts client-side against your content policy before sending

Try / catch

try {
  await generateImage({ model, prompt });
} catch (e) {
  if (e instanceof Error && e.message.startsWith('Amazon Bedrock request was moderated')) {
    // surface the reasons to the user / sanitize the prompt
  }
}

Prevention

When it happens

Trigger: generateImage with a bedrock image model where the prompt (or reference images) trips Amazon Bedrock's content moderation guardrails, producing response.status === 'Request Moderated'.

Common situations: Prompts containing violence, sexual content, real-person likenesses, or other policy-sensitive content; occasionally false positives on borderline wording; regional policy differences.

Related errors


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