AWS Bedrock Guardrails

AWS Bedrock Guardrails let you define content policies in the AWS console and apply them to LLM traffic passing through agentgateway. When a request or response violates a guardrail policy, agentgateway blocks the interaction and returns an error.

Before you begin

  1. Install the agentgateway binary.
  2. Create a guardrail in the AWS console or via the AWS CLI.
  3. Retrieve your guardrail identifier by running: aws bedrock list-guardrails --region <aws-region>
  4. Authenticate with AWS Bedrock using the standard AWS authentication sources. Make sure that you have permission to invoke the Bedrock Guardrails API.

Configure Bedrock Guardrails

Configure the promptGuard policy under policies.ai in your agentgateway configuration. You can apply guardrails to the request phase, the response phase, or both.

cat <<EOF > config.yaml
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
binds:
- port: 3000
  listeners:
  - routes:
    - backends:
       - ai:
          name: bedrock
          provider:
            openAI:
              model: amazon.titan-text-express-v1
      policies:
        backendAuth:
          key: "$BEDROCK_API_KEY"
        ai:
          promptGuard:
            request:
            - bedrockGuardrails:
                guardrailIdentifier: <your-guardrail-id>
                guardrailVersion: DRAFT
                region: us-west-2
                policies:
                  backendAuth:
                    aws: {}
            response:
            - bedrockGuardrails:
                guardrailIdentifier: <your-guardrail-id>
                guardrailVersion: DRAFT
                region: us-west-2
                policies:
                  backendAuth:
                    aws: {}
EOF
SettingDescription
guardrailIdentifierThe identifier of the Bedrock guardrail to apply. Retrieve this by running aws bedrock list-guardrails.
guardrailVersionThe version of the guardrail. Use DRAFT for development or a specific version number for production.
regionThe AWS region where the guardrail is configured, such as us-west-2.
policies.backendAuth.awsAWS authentication configuration. Agentgateway uses the credentials available in the environment, such as environment variables or an instance profile.

When a request or response matches a guardrail policy, agentgateway blocks the interaction and returns an error such as: The request was rejected due to inappropriate content.

Agentgateway assistant

Ask me anything about agentgateway configuration, features, or usage.

Note: AI-generated content might contain errors; please verify and test all returned information.

Tip: one topic per conversation gives the best results. Use the + button in the chat header to start a new conversation.

Switching topics? Starting a new conversation improves accuracy.
↑↓ navigate select esc dismiss

What could be improved?

Your feedback helps us improve assistant answers and identify docs gaps we should fix.

Need more help? Join us on Discord: https://discord.gg/y9efgEmppm

Want to use your own agent? Add the Solo MCP server to query our docs directly. Get started here: https://search.solo.io/.