All Products
Search
Document Center

AI Guardrails:Library management

Last Updated:Mar 31, 2026

The built-in moderation rules cover most content risks, but some violations are specific to your business. Use keyword libraries to define custom terms that the Text Moderation API should flag or ignore during text analysis.

Prerequisites

Before you begin, ensure that you have:

  • Access to the Guardrails console

  • A service configured under Protection Configuration > Configuration (required to attach libraries)

Limits

ItemLimit
Libraries per account20
Total keywords per account100,000
Lines per library1,000
Characters per keyword50

To add more than 1,000 keywords at once, import them from a file.

Create a library

  1. Log on to the Guardrails console.

  2. In the left navigation pane, choose Protection Configuration > Library Management.

  3. On the Library Management tab, click Create Library.

  4. In the Create Library panel, enter the library details. Enter one keyword per line. Use logical operators to combine keywords:

    The & operator must appear before the ~ operator in a combined expression.
    OperatorMeaningExample
    &AND — match only when both keywords appearWeChat&part-time
    ~NOT — exclude the keyword from matchingloan~student
  5. Click OK.

If library creation fails, a detailed error message is displayed. Follow the instructions in the message and try again.

Attach libraries to a service

After creating libraries, attach them to a service rule to activate custom keyword detection.

  1. In the left navigation pane, choose Protection Configuration > Configuration.

  2. Select the target service. In the Actions column, click Set keyword library.

  3. On the Keyword blacklist or Keyword whitelist tab, add or remove libraries:

    • Keyword blacklist: Click Add keyword library to add a library. Click Remove to detach one.

    • Keyword whitelist: Click Add Library to add a library. Click Remove From Whitelist to detach one.

  4. Click OK to save the configuration.

How blacklists and whitelists work

Blacklists

When the Text Moderation API detects a keyword from a blacklist library in the submitted text, it returns C_customized in the labels parameter. Any labels triggered by built-in rules are also returned.

Example: You add Small Loans and Door-to-door Service to a blacklist library. If the submitted text is:

Our School Offers Small Loans, Safe, Fast, Convenient, No Collateral, Borrow Anytime, Same-day Funding, Door-to-door Service

The API flags both Small Loans and Door-to-door Service. The labels parameter returns C_customized along with any other built-in rule labels that matched.

Whitelists

When the Text Moderation API finds a keyword from a whitelist library in the submitted text, it skips that keyword during risk analysis. Use whitelists to prevent false positives for terms that are safe in your context.

Example: You add Convenient and Fast to a whitelist library. If the submitted text is:

Our School Offers Small Loans, Safe, Fast, Convenient, No Collateral, Borrow Anytime, Same-day Funding, Door-to-door Service

The API ignores Convenient and Fast and only analyzes the remaining text for risks: Our School Offers Small Loans, Safe, No Collateral, Borrow Anytime, Same-day Funding, Door-to-door Service.