> For the complete documentation index, see [llms.txt](https://docs.maiagent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.maiagent.ai/tech/en/ai-agents/aws-guardrails.md).

# AWS Guardrails

AWS Guardrails provides configurable safeguards that help you securely build generative AI applications at scale. It uses automated reasoning to help prevent factual errors caused by hallucinations. I

AWS Guardrails provides the following features:

* Content filtering (for sexually explicit, violent, and other content)
* Off-topic response prevention
* Word filtering
* Sensitive data removal
* Hallucination prevention

## <mark style="color:blue;">Instructions</mark>

### Step 1: Configure the settings (name, description, and the message returned when content is blocked)

<figure><img src="https://3415477754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNBTi475lqozGpB7xObpE%2Fuploads%2Fgit-blob-8538be2a81c4517b7802c6058d643a91224bad8d%2Fimage%20(11).png?alt=media" alt=""><figcaption></figcaption></figure>

Configuration from another project

<figure><img src="https://3415477754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNBTi475lqozGpB7xObpE%2Fuploads%2Fgit-blob-266b5fb0c56e003aa48b16694c892f6ae325ce4e%2Fimage%20(25).png?alt=media" alt=""><figcaption></figcaption></figure>

### Step 2: Configure content filters (User Input, Assistant Response)

<figure><img src="https://3415477754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNBTi475lqozGpB7xObpE%2Fuploads%2Fgit-blob-817bad48f8cc391c9329afc86518d5f2afa56a82%2Fimage%20(12).png?alt=media" alt=""><figcaption></figcaption></figure>

You can specify severity levels and even include image input.

<figure><img src="https://3415477754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNBTi475lqozGpB7xObpE%2Fuploads%2Fgit-blob-9c2b169d350da8843878d25ea1edc76a5d8d61a4%2Fimage%20(13).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3415477754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNBTi475lqozGpB7xObpE%2Fuploads%2Fgit-blob-b7add55e33c6117e775e63ee662f1731da1c37ab%2Fimage%20(14).png?alt=media" alt=""><figcaption></figcaption></figure>

Configuration from another project

<figure><img src="https://3415477754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNBTi475lqozGpB7xObpE%2Fuploads%2Fgit-blob-955647ed56819a1404526281ae3798773759cb8e%2Fimage%20(26).png?alt=media" alt=""><figcaption></figcaption></figure>

### Step 3: Deny topics to prevent off-topic responses

<figure><img src="https://3415477754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNBTi475lqozGpB7xObpE%2Fuploads%2Fgit-blob-c0f27367cee961794c435635b6a9f9ca7c25a3c8%2Fimage%20(16).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3415477754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNBTi475lqozGpB7xObpE%2Fuploads%2Fgit-blob-f81e19ea32f80ded2199f9fda73d8c61da256fb8%2Fimage%20(20).png?alt=media" alt=""><figcaption></figcaption></figure>

You can prevent off-topic responses by adding descriptions, definitions, and examples.

Configuration from another project

<figure><img src="https://3415477754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNBTi475lqozGpB7xObpE%2Fuploads%2Fgit-blob-418c511fc8b4ad57ca71eb1d18516bbec875dc2f%2Fimage%20(27).png?alt=media" alt=""><figcaption></figcaption></figure>

### Step 4: Apply strict word filters (prohibit profanity or mentions of XXX)

For example, if you do not want the model to mention Voldemort, add it as a blocked word. You can import multiple words at once (csv, txt, ctrl + c).

<figure><img src="https://3415477754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNBTi475lqozGpB7xObpE%2Fuploads%2Fgit-blob-2981df6b34bae947a8cd422c1eaf731cd2b1ee0b%2Fimage%20(22).png?alt=media" alt=""><figcaption></figcaption></figure>

Configuration from another project

![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXcb-3vRt-Q0UkPhKEbzpygdBa4ALAaKUsXTil3m5PS3PHLQcR_3jpXXkn6T6-YoaONvnCc0H1RDrhIj-aq0WzCunLW99auRRCu36bNOEBnYqrsgK6Up5uehpKqqreKzXPWxSU0x?key=z1hebxFSyJWvHprMJ3hgOr8k)

### ![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXczJwuyAQ4-FbNaBymncor9v3HA9mUURj_ghPn8N1FyNUkNvr_hW9WXw1C9ZYX3gcR5s0uYS_IybmgQ_1pSfnHNf6GTiJCu8H7apoiIm2Bczjfe1csDR3WVDpRuYWRCPS22K2OdQQ?key=z1hebxFSyJWvHprMJ3hgOr8k)

### Step 5: Block sensitive data (PII) and apply regular-expression replacements

Several patterns are provided by default, including credit card numbers, license plate numbers, and national ID numbers.

<figure><img src="https://3415477754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNBTi475lqozGpB7xObpE%2Fuploads%2Fgit-blob-0e9a5418c49b3a5e0de2bb751aa336b1ccd76591%2Fimage%20(23).png?alt=media" alt=""><figcaption></figcaption></figure>

Configuration from another project

<figure><img src="https://3415477754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNBTi475lqozGpB7xObpE%2Fuploads%2Fgit-blob-97cf592fd943fa52fca67ac772ccf389ad94585c%2Fimage%20(28).png?alt=media" alt=""><figcaption></figcaption></figure>

Regular-expression replacement lets you replace unwanted structures in an AI assistant's response using a regular expression of your choice.

### Step 6: Prevent hallucinations and block responses using a relevance threshold

<figure><img src="https://3415477754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNBTi475lqozGpB7xObpE%2Fuploads%2Fgit-blob-5fce88e0b2eab851da8e62e9d38c02d3a76b1338%2Fimage%20(24).png?alt=media" alt=""><figcaption></figcaption></figure>

Configuration from another project

<figure><img src="https://3415477754-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNBTi475lqozGpB7xObpE%2Fuploads%2Fgit-blob-77c3a326f8b00a5e6442f8fd33e195609e5e1ea9%2Fimage%20(29).png?alt=media" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.maiagent.ai/tech/en/ai-agents/aws-guardrails.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `build a script that syncs our docs to a CMS` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
