AI AWS Guardrails Policy

Related Documentation
Made by
Kong Inc.
Incompatible with
on-prem
Minimum Version
AI Gateway - 2.0
Tags

The AI AWS Guardrails Policy enforces introspection on both inbound requests and outbound responses handled by the AI Model entity. It integrates with the AWS Bedrock Guardrails service to apply compliance and safety policies at the AI Gateway level. This ensures all data exchanged between clients and upstream LLMs adheres to the configured security standards.

Prerequisites

Before using the AI AWS Guardrails Policy, you must define your guardrail policies in AWS. You can do this through:

How it works

The AI AWS Guardrails Policy includes a configurable response_buffer_size parameter. This setting controls how many tokens from the upstream LLM response are buffered during streaming before being sent to the AWS Guardrails service for inspection. For example, setting response_buffer_size to 50 means the AI AWS Guardrails Policy will collect 50 tokens from the upstream model before sending them to AWS Guardrails for evaluation. Guardrail evaluation runs in chunks as tokens stream in.

A smaller buffer size allows faster policy evaluation and quicker response rejection but may increase the number of guardrail calls. Larger sizes reduce API calls but may delay policy enforcement.

For response and request inspection, the Policy by default guards input only. You can change this behavior with the guarding_mode field, which supports INPUT, OUTPUT, or BOTH. To control which parts of the conversation are sent for content evaluation, use the text_source field. Set it to concatenate_user_content to inspect only user input, or concatenate_all_content to include the full exchange, including system and assistant messages.

Format

This Policy works with all of the AI Model entity’s model.capabilities settings.

AWS IAM roles

The AI AWS Guardrails Policy supports AWS Identity and Access Management (IAM) roles. This allows the AWS Bedrock Guardrails service to be accessed using role assumption instead of static credentials.

To use AWS IAM roles with the Policy, set the config.aws_assume_role_arn, and config.aws_role_session_name.

Note: These fields can be used with or without static AWS credentials (config.aws_access_key_id and config.aws_secret_access_key).

TLS verification

config.ssl_verify is enabled by default. The Policy verifies the TLS certificate when connecting to the AWS Bedrock service. To disable this, set ssl_verify: false.

Logging

The AI AWS Guardrails Policy emits structured log data for every inspected request and response. For the full list of log fields, see the AI Gateway audit log reference.

To log the raw content of blocked requests and responses, enable config.log_blocked_content. When enabled, the blocked prompt or response body appears under ai.proxy.aws-guardrails.input_faulty_prompt and ai.proxy.aws-guardrails.output_faulty_response in each log entry.

Forward proxy support

Set config.proxy on this entity to route its outbound requests through an HTTP forward proxy. Use this in network-isolated deployments where AI Gateway cannot open direct connections to LLM providers or auxiliary services.

The proxy record is identical for AI Model, AI MCP Server, and supported AI Policy entities. Existing capabilities such as load balancing, health checking, streaming, WebSocket, and HTTP/2 continue to work when the proxy is active.

For the full field reference, traffic flow, and limitations, see Forward proxy support.

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!