Secure your AI applications with AWS Bedrock’s guardrail capabilities through Portkey.
AWS Bedrock Guardrails provides a comprehensive solution for securing your LLM applications, including content filtering, PII detection and redaction, and more.
To get started with AWS Bedrock Guardrails, visit their documentation:
AWS Bedrock
-> Guardrails
-> Create guardrail
PII redaction
, we recommend setting the Guardrail behavior as BLOCK for the required entity types. This is necessary because Bedrock does not apply PII checks on input (request message) if the behavior is set to MASKIntegration
page under Sidebar
Region
, AwsAuthType
, Role ARN
& External ID
credentials (refer to Bedrock’s documentation for how to obtain these credentials)Guardrails
page and click the Create
buttonApply bedrock guardrail
and click Add
Redact PII
toggle as neededCreate
Guardrail Actions allow you to orchestrate your guardrails logic. You can learn them here
before_request_hooks
or after_request_hooks
params in your Portkey ConfigHere’s an example configuration:
For more, refer to the Config documentation.
After setting up your guardrails, there are different ways to use them depending on your security requirements:
To simply detect but not redact content:
Redact PII
flag disabled when creating the guardrail on Portkeyhook_results
object with details for all checksTo automatically redact PII while still checking for other issues:
Redact PII
flag when creating the guardrail on Portkeyhook_results
object with all check detailstransformed
set to true
To completely block requests that violate your policies:
Deny
option in the guardrails action tabYou can define AWS Bedrock guardrails directly in your code for more programmatic control without using the Portkey UI. This “raw guardrails” approach lets you dynamically configure guardrails based on your application’s needs.
We recommend creating guardrails using the Portkey UI whenever possible. Raw guardrails are more complex and require you to manage credentials and configurations directly in your code.
Raw Guardrails Configuration Example
Guardrail Name | ID | Description | Parameters |
---|---|---|---|
Apply bedrock guardrail | bedrock.guard | Applies AWS Bedrock guardrail checks for LLM requests/responses | guardrailId (string), guardrailVersion (string), redact (boolean), timeout (number) |
type
: Always set to "guardrail"
for guardrail checksid
: A unique identifier for your guardrailcredentials
: Authentication details for AWS Bedrock (if using assumedRole)checks
: Array of guardrail checks to run
id
: The specific guardrail ID - in this case, bedrock.guard
parameters
: Configuration options for the guardraildeny
: Whether to block the request if guardrail fails (true/false)async
: Whether to run guardrail asynchronously (true/false)on_success
/on_fail
: Optional callbacks for success/failure scenarios
feedback
: Data for logging and analyticsweight
: Importance of this feedback (0-1)value
: Feedback score (-10 to 10)When using raw guardrails, you must provide valid credentials for AWS Bedrock directly in your config. Make sure to handle these credentials securely and consider using environment variables or secrets management.
If you face any issues with the AWS Bedrock Guardrails integration, just ping us on the community forum.