For the complete documentation index, see llms.txt. Markdown versions of all docs pages are available by appending .md to any docs URL.
AWS Bedrock Guardrails
Apply AWS Bedrock Guardrails to filter LLM requests and responses for policy-violating content.
AWS Bedrock Guardrails provide content filtering, PII detection, topic restrictions, and word filters. You must create the guardrail policies in the AWS console and then apply them to LLM route that you want to protect. When a request or response violates a guardrail policy, the agentgateway proxy blocks the interaction and returns an error.
AWS Bedrock Guardrails are model-agnostic and can be applied to any Large Language Model (LLM), whether it is hosted on AWS Bedrock, another cloud provider (like Google or Azure), or on-premises.
Before you begin
Set up AWS Bedrock guardrails
Warning
These steps store the gateway’s credentials in AGW_-prefixed environment variables, as opposed to the standard AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and AWS_SESSION_TOKEN variables that the aws CLI and the AWS SDKs read. This way, when you export the variables, you do not replace your own personal user identity for the rest of the shell session, which could lead to unexpected auth errors. To use the standard names anyway, set them in a subshell, or store the gateway’s credentials in a named AWS profile and select that profile with AWS_PROFILE for the agentgateway process only.
Create a guardrail in the AWS console or via the AWS CLI.
Retrieve your guardrail identifier and version. For more information, see the AWS documentation.
aws bedrock list-guardrails --region <aws-region>Example output:
{ "guardrails": [ { "id": "a1aaaa11aa1a", "arn": "arn:aws:bedrock:us-west-2:11111111111:guardrail/a1aaaa11aa1a", "status": "READY", "name": "my-guardrail", "description": "Testing agentgateway bedrock guardrail integration ", "version": "DRAFT", "createdAt": "2026-02-09T17:59:29+00:00", "updatedAt": "2026-02-09T18:01:29.567223+00:00" } ] }Save the AWS credentials that the gateway uses to invoke the Bedrock Guardrails API as environment variables.
export AGW_AWS_ACCESS_KEY_ID="<aws-access-key-id>" export AGW_AWS_SECRET_ACCESS_KEY="<aws-secret-access-key>" export AGW_AWS_SESSION_TOKEN="<aws-session-token>"Create a Kubernetes secret with those AWS credentials. Make sure that you have permission to invoke the Bedrock Guardrails API.
kubectl create secret generic aws-secret \ -n agentgateway-system \ --from-literal=accessKey="$AGW_AWS_ACCESS_KEY_ID" \ --from-literal=secretKey="$AGW_AWS_SECRET_ACCESS_KEY" \ --from-literal=sessionToken="$AGW_AWS_SESSION_TOKEN" \ --type=Opaque \ --dry-run=client -o yaml | kubectl apply -f -Configure the prompt guard. Add the ID, version, and region of your guardrail.
kubectl apply -f - <<EOF apiVersion: agentgateway.dev/v1alpha1 kind: AgentgatewayPolicy metadata: name: openai-prompt-guard namespace: agentgateway-system spec: targetRefs: - group: gateway.networking.k8s.io kind: HTTPRoute name: openai backend: ai: promptGuard: request: - bedrockGuardrails: identifier: <guardrail-ID> version: "<version>" region: <region>> policies: auth: aws: secretRef: name: aws-secret response: - bedrockGuardrails: identifier: <guardrail-ID> version: "<version>" region: <region>> policies: auth: aws: secretRef: name: aws-secret EOFTheaws: {}configuration uses the default AWS credential chain (IAM role, environment variables, or instance profile). For authentication details, see the AWS authentication documentation.Test the guardrail. The following commands assume that you set up your guardrail to block requests that contain email information.
Cloud Provider LoadBalancer:
curl "$INGRESS_GW_ADDRESS/v1/chat/completions" -H content-type:application/json -d '{ "model": "", "messages": [ { "role": "user", "content": "My email is test@solo.io" } ] }' | jqLocalhost:
curl "localhost:8080/v1/chat/completions" -H content-type:application/json -d '{ "model": "", "messages": [ { "role": "user", "content": "My email is test@solo.io" } ] }' | jqExample output:
The request was rejected due to inappropriate content
Cleanup
You can remove the resources that you created in this guide.kubectl delete AgentgatewayPolicy openai-prompt-guard -n agentgateway-system
kubectl delete secret aws-secret -n agentgateway-system