QuestionQ103

VerifiedAI Safety, Security, and Governance

A social messaging company is building an AI chat assistant using Amazon Bedrock. The company must ensure that every inference complies with an approved safety policy. Specifically, the company wants to:

  • Block harmful prompts before model invocations
  • Filter streamed model outputs in real time
  • Route flagged cases for human review

Which solution will meet these requirements?

Explanation

Amazon Bedrock's ApplyGuardrail API can independently evaluate INPUT text (prompts) before a model is invoked and OUTPUT text (model responses) after generation, without requiring a model call — making it suitable for both a pre-inference block of harmful prompts and a post-inference check of generated content. Attaching a guardrail directly to the InvokeModelWithResponseStream API enables real-time filtering of streamed tokens as they are generated. Routing guardrail-flagged content to a queue such as Amazon SQS enables asynchronous human review of borderline or blocked cases. To guarantee that every inference request actually uses the approved guardrail (rather than relying on developers to remember to specify it), Bedrock supports the bedrock:GuardrailIdentifier IAM condition key, which can be enforced in an IAM policy attached to the InvokeModel/InvokeModelWithResponseStream/Converse/ConverseStream actions; any request lacking or mismatching the required guardrail identifier is denied. This combination — Step Functions orchestrating Lambda pre-check (ApplyGuardrail), streaming inference with an attached guardrail, Lambda post-check (ApplyGuardrail), SQS routing for review, and IAM-based enforcement — comprehensively satisfies all stated requirements.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!