CreateAIGuardrailCommand

Creates an Amazon Q in Connect AI Guardrail.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { QConnectClient, CreateAIGuardrailCommand } from "@aws-sdk/client-qconnect"; // ES Modules import
// const { QConnectClient, CreateAIGuardrailCommand } = require("@aws-sdk/client-qconnect"); // CommonJS import
const client = new QConnectClient(config);
const input = { // CreateAIGuardrailRequest
  clientToken: "STRING_VALUE",
  assistantId: "STRING_VALUE", // required
  name: "STRING_VALUE", // required
  blockedInputMessaging: "STRING_VALUE", // required
  blockedOutputsMessaging: "STRING_VALUE", // required
  visibilityStatus: "STRING_VALUE", // required
  description: "STRING_VALUE",
  topicPolicyConfig: { // AIGuardrailTopicPolicyConfig
    topicsConfig: [ // GuardrailTopicsConfig // required
      { // GuardrailTopicConfig
        name: "STRING_VALUE", // required
        definition: "STRING_VALUE", // required
        examples: [ // GuardrailTopicExamples
          "STRING_VALUE",
        ],
        type: "STRING_VALUE", // required
      },
    ],
  },
  contentPolicyConfig: { // AIGuardrailContentPolicyConfig
    filtersConfig: [ // GuardrailContentFiltersConfig // required
      { // GuardrailContentFilterConfig
        type: "STRING_VALUE", // required
        inputStrength: "STRING_VALUE", // required
        outputStrength: "STRING_VALUE", // required
      },
    ],
  },
  wordPolicyConfig: { // AIGuardrailWordPolicyConfig
    wordsConfig: [ // GuardrailWordsConfig
      { // GuardrailWordConfig
        text: "STRING_VALUE", // required
      },
    ],
    managedWordListsConfig: [ // GuardrailManagedWordListsConfig
      { // GuardrailManagedWordsConfig
        type: "STRING_VALUE", // required
      },
    ],
  },
  sensitiveInformationPolicyConfig: { // AIGuardrailSensitiveInformationPolicyConfig
    piiEntitiesConfig: [ // GuardrailPiiEntitiesConfig
      { // GuardrailPiiEntityConfig
        type: "STRING_VALUE", // required
        action: "STRING_VALUE", // required
      },
    ],
    regexesConfig: [ // GuardrailRegexesConfig
      { // GuardrailRegexConfig
        name: "STRING_VALUE", // required
        description: "STRING_VALUE",
        pattern: "STRING_VALUE", // required
        action: "STRING_VALUE", // required
      },
    ],
  },
  contextualGroundingPolicyConfig: { // AIGuardrailContextualGroundingPolicyConfig
    filtersConfig: [ // GuardrailContextualGroundingFiltersConfig // required
      { // GuardrailContextualGroundingFilterConfig
        type: "STRING_VALUE", // required
        threshold: Number("double"), // required
      },
    ],
  },
  tags: { // Tags
    "<keys>": "STRING_VALUE",
  },
};
const command = new CreateAIGuardrailCommand(input);
const response = await client.send(command);
// { // CreateAIGuardrailResponse
//   aiGuardrail: { // AIGuardrailData
//     assistantId: "STRING_VALUE", // required
//     assistantArn: "STRING_VALUE", // required
//     aiGuardrailArn: "STRING_VALUE", // required
//     aiGuardrailId: "STRING_VALUE", // required
//     name: "STRING_VALUE", // required
//     visibilityStatus: "STRING_VALUE", // required
//     blockedInputMessaging: "STRING_VALUE", // required
//     blockedOutputsMessaging: "STRING_VALUE", // required
//     description: "STRING_VALUE",
//     topicPolicyConfig: { // AIGuardrailTopicPolicyConfig
//       topicsConfig: [ // GuardrailTopicsConfig // required
//         { // GuardrailTopicConfig
//           name: "STRING_VALUE", // required
//           definition: "STRING_VALUE", // required
//           examples: [ // GuardrailTopicExamples
//             "STRING_VALUE",
//           ],
//           type: "STRING_VALUE", // required
//         },
//       ],
//     },
//     contentPolicyConfig: { // AIGuardrailContentPolicyConfig
//       filtersConfig: [ // GuardrailContentFiltersConfig // required
//         { // GuardrailContentFilterConfig
//           type: "STRING_VALUE", // required
//           inputStrength: "STRING_VALUE", // required
//           outputStrength: "STRING_VALUE", // required
//         },
//       ],
//     },
//     wordPolicyConfig: { // AIGuardrailWordPolicyConfig
//       wordsConfig: [ // GuardrailWordsConfig
//         { // GuardrailWordConfig
//           text: "STRING_VALUE", // required
//         },
//       ],
//       managedWordListsConfig: [ // GuardrailManagedWordListsConfig
//         { // GuardrailManagedWordsConfig
//           type: "STRING_VALUE", // required
//         },
//       ],
//     },
//     sensitiveInformationPolicyConfig: { // AIGuardrailSensitiveInformationPolicyConfig
//       piiEntitiesConfig: [ // GuardrailPiiEntitiesConfig
//         { // GuardrailPiiEntityConfig
//           type: "STRING_VALUE", // required
//           action: "STRING_VALUE", // required
//         },
//       ],
//       regexesConfig: [ // GuardrailRegexesConfig
//         { // GuardrailRegexConfig
//           name: "STRING_VALUE", // required
//           description: "STRING_VALUE",
//           pattern: "STRING_VALUE", // required
//           action: "STRING_VALUE", // required
//         },
//       ],
//     },
//     contextualGroundingPolicyConfig: { // AIGuardrailContextualGroundingPolicyConfig
//       filtersConfig: [ // GuardrailContextualGroundingFiltersConfig // required
//         { // GuardrailContextualGroundingFilterConfig
//           type: "STRING_VALUE", // required
//           threshold: Number("double"), // required
//         },
//       ],
//     },
//     tags: { // Tags
//       "<keys>": "STRING_VALUE",
//     },
//     status: "STRING_VALUE",
//     modifiedTime: new Date("TIMESTAMP"),
//   },
// };

CreateAIGuardrailCommand Input

See CreateAIGuardrailCommandInput for more details

Parameter
Type
Description
assistantId
Required
string | undefined

The identifier of the Amazon Q in Connect assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.

blockedInputMessaging
Required
string | undefined

The message to return when the AI Guardrail blocks a prompt.

blockedOutputsMessaging
Required
string | undefined

The message to return when the AI Guardrail blocks a model response.

name
Required
string | undefined

The name of the AI Guardrail.

visibilityStatus
Required
VisibilityStatus | undefined

The visibility status of the AI Guardrail.

clientToken
string | undefined

A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see Making retries safe with idempotent APIs ..

contentPolicyConfig
AIGuardrailContentPolicyConfig | undefined

The content filter policies to configure for the AI Guardrail.

contextualGroundingPolicyConfig
AIGuardrailContextualGroundingPolicyConfig | undefined

The contextual grounding policy configuration used to create an AI Guardrail.

description
string | undefined

A description of the AI Guardrail.

sensitiveInformationPolicyConfig
AIGuardrailSensitiveInformationPolicyConfig | undefined

The sensitive information policy to configure for the AI Guardrail.

tags
Record<string, string> | undefined

The tags used to organize, track, or control access for this resource.

topicPolicyConfig
AIGuardrailTopicPolicyConfig | undefined

The topic policies to configure for the AI Guardrail.

wordPolicyConfig
AIGuardrailWordPolicyConfig | undefined

The word policy you configure for the AI Guardrail.

CreateAIGuardrailCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
aiGuardrail
AIGuardrailData | undefined

The data of the AI Guardrail.

Throws

Name
Fault
Details
AccessDeniedException
client

You do not have sufficient access to perform this action.

ConflictException
client

The request could not be processed because of conflict in the current state of the resource. For example, if you're using a Create API (such as CreateAssistant) that accepts name, a conflicting resource (usually with the same name) is being created or mutated.

ResourceNotFoundException
client

The specified resource does not exist.

ServiceQuotaExceededException
client

You've exceeded your service quota. To perform the requested action, remove some of the relevant resources, or use service quotas to request a service quota increase.

ThrottlingException
client

The throttling limit has been exceeded.

ValidationException
client

The input fails to satisfy the constraints specified by a service.

QConnectServiceException
Base exception class for all service exceptions from QConnect service.