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
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" } ] }Create a Kubernetes secret with your 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="$AWS_ACCESS_KEY_ID" \ --from-literal=secretKey="$AWS_SECRET_ACCESS_KEY" \ --from-literal=sessionToken="$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: bedrock-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.The
policiesfield supports more than theawscredential source shown here. You can choose a different authentication method or tune the connection that agentgateway opens to Bedrock, such as setting a request timeout or custom TLS. For all the options, see Backend connection and authentication policies.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
Backend connection and authentication policies
The policies field configures how agentgateway connects and authenticates to the AWS Bedrock Guardrails service when it evaluates a request or response.
Authentication
Under policies.auth, set one credential source (aws, secretRef, or key). Optionally, set location to control where the credential is placed.
| Method | Description |
|---|---|
aws | Authenticate with AWS credentials. Set aws: {} to use the default AWS credential chain (IAM role, environment variables, or instance profile), or set aws.secretRef to read credentials from a Kubernetes secret. |
secretRef | Read the API key from a Kubernetes secret. By default, the key that matches the credential location is used, such as Authorization for the default header location. To use a different key, set secretRef.key. |
key | Send an inline API key in the Authorization header. This option is the least secure. Use a secret instead when possible. |
location | Where to place the credential. Defaults to the Authorization header with a Bearer prefix. To change it, set a header, queryParameter, or cookie. |
Backend connection settings
You can also tune the connection that agentgateway opens to the Bedrock Guardrails backend by setting the following BackendConnectionPolicy fields under policies.
| Setting | Description |
|---|---|
tls | TLS settings for the connection, such as a custom CA certificate or SNI. |
http | HTTP settings, such as the requestTimeout and HTTP protocol version. |
tcp | TCP connection settings. |
tunnel | Tunnel settings, such as an HTTPS_PROXY, used to reach the backend. |
For example, the following prompt guard authenticates with a secret and sets a request timeout for the calls to Bedrock.
- bedrockGuardrails:
identifier: <guardrail-ID>
version: "<version>"
region: <region>
policies:
auth:
aws:
secretRef:
name: aws-secret
http:
requestTimeout: 5sFor the full set of fields, see the API reference.
Cleanup
You can remove the resources that you created in this guide.kubectl delete AgentgatewayPolicy bedrock-prompt-guard -n agentgateway-system
kubectl delete secret aws-secret -n agentgateway-system