CreateGuardrail
Creates a guardrail to block topics and to implement safeguards for your generative AI applications.
You can configure the following policies in a guardrail to avoid undesirable and harmful content, filter out denied topics and words, and remove sensitive information for privacy protection.
-
Content filters - Adjust filter strengths to block input prompts or model responses containing harmful content.
-
Denied topics - Define a set of topics that are undesirable in the context of your application. These topics will be blocked if detected in user queries or model responses.
-
Word filters - Configure filters to block undesirable words, phrases, and profanity. Such words can include offensive terms, competitor names etc.
-
Sensitive information filters - Block or mask sensitive information such as personally identifiable information (PII) or custom regex in user inputs and model responses.
In addition to the above policies, you can also configure the messages to be returned to the user if a user input or model response is in violation of the policies defined in the guardrail.
For more information, see Amazon Bedrock Guardrails in the Amazon Bedrock User Guide.
Request Syntax
POST /guardrails HTTP/1.1
Content-type: application/json
{
"blockedInputMessaging": "string
",
"blockedOutputsMessaging": "string
",
"clientRequestToken": "string
",
"contentPolicyConfig": {
"filtersConfig": [
{
"inputModalities": [ "string
" ],
"inputStrength": "string
",
"outputModalities": [ "string
" ],
"outputStrength": "string
",
"type": "string
"
}
]
},
"contextualGroundingPolicyConfig": {
"filtersConfig": [
{
"threshold": number
,
"type": "string
"
}
]
},
"description": "string
",
"kmsKeyId": "string
",
"name": "string
",
"sensitiveInformationPolicyConfig": {
"piiEntitiesConfig": [
{
"action": "string
",
"type": "string
"
}
],
"regexesConfig": [
{
"action": "string
",
"description": "string
",
"name": "string
",
"pattern": "string
"
}
]
},
"tags": [
{
"key": "string
",
"value": "string
"
}
],
"topicPolicyConfig": {
"topicsConfig": [
{
"definition": "string
",
"examples": [ "string
" ],
"name": "string
",
"type": "string
"
}
]
},
"wordPolicyConfig": {
"managedWordListsConfig": [
{
"type": "string
"
}
],
"wordsConfig": [
{
"text": "string
"
}
]
}
}
URI Request Parameters
The request does not use any URI parameters.
Request Body
The request accepts the following data in JSON format.
- blockedInputMessaging
-
The message to return when the guardrail blocks a prompt.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 500.
Required: Yes
- blockedOutputsMessaging
-
The message to return when the guardrail blocks a model response.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 500.
Required: Yes
- clientRequestToken
-
A unique, case-sensitive identifier to ensure that the API request completes no more than once. If this token matches a previous request, Amazon Bedrock ignores the request, but does not return an error. For more information, see Ensuring idempotency in the Amazon S3 User Guide.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 256.
Pattern:
^[a-zA-Z0-9](-*[a-zA-Z0-9])*$
Required: No
- contentPolicyConfig
-
The content filter policies to configure for the guardrail.
Type: GuardrailContentPolicyConfig object
Required: No
- contextualGroundingPolicyConfig
-
The contextual grounding policy configuration used to create a guardrail.
Type: GuardrailContextualGroundingPolicyConfig object
Required: No
- description
-
A description of the guardrail.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 200.
Required: No
- kmsKeyId
-
The ARN of the AWS KMS key that you use to encrypt the guardrail.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 2048.
Pattern:
^(arn:aws(-[^:]+)?:kms:[a-zA-Z0-9-]*:[0-9]{12}:((key/[a-zA-Z0-9-]{36})|(alias/[a-zA-Z0-9-_/]+)))|([a-zA-Z0-9-]{36})|(alias/[a-zA-Z0-9-_/]+)$
Required: No
- name
-
The name to give the guardrail.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 50.
Pattern:
^[0-9a-zA-Z-_]+$
Required: Yes
- sensitiveInformationPolicyConfig
-
The sensitive information policy to configure for the guardrail.
Type: GuardrailSensitiveInformationPolicyConfig object
Required: No
-
The tags that you want to attach to the guardrail.
Type: Array of Tag objects
Array Members: Minimum number of 0 items. Maximum number of 200 items.
Required: No
- topicPolicyConfig
-
The topic policies to configure for the guardrail.
Type: GuardrailTopicPolicyConfig object
Required: No
- wordPolicyConfig
-
The word policy you configure for the guardrail.
Type: GuardrailWordPolicyConfig object
Required: No
Response Syntax
HTTP/1.1 202
Content-type: application/json
{
"createdAt": "string",
"guardrailArn": "string",
"guardrailId": "string",
"version": "string"
}
Response Elements
If the action is successful, the service sends back an HTTP 202 response.
The following data is returned in JSON format by the service.
- createdAt
-
The time at which the guardrail was created.
Type: Timestamp
- guardrailArn
-
The ARN of the guardrail.
Type: String
Length Constraints: Minimum length of 0. Maximum length of 2048.
Pattern:
^arn:aws(-[^:]+)?:bedrock:[a-z0-9-]{1,20}:[0-9]{12}:guardrail/[a-z0-9]+$
- guardrailId
-
The unique identifier of the guardrail that was created.
Type: String
Length Constraints: Minimum length of 0. Maximum length of 64.
Pattern:
^[a-z0-9]+$
- version
-
The version of the guardrail that was created. This value will always be
DRAFT
.Type: String
Length Constraints: Fixed length of 5.
Pattern:
^DRAFT$
Errors
For information about the errors that are common to all actions, see Common Errors.
- AccessDeniedException
-
The request is denied because of missing access permissions.
HTTP Status Code: 403
- ConflictException
-
Error occurred because of a conflict while performing an operation.
HTTP Status Code: 400
- InternalServerException
-
An internal server error occurred. Retry your request.
HTTP Status Code: 500
- ResourceNotFoundException
-
The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.
HTTP Status Code: 404
- ServiceQuotaExceededException
-
The number of requests exceeds the service quota. Resubmit your request later.
HTTP Status Code: 400
- ThrottlingException
-
The number of requests exceeds the limit. Resubmit your request later.
HTTP Status Code: 429
- TooManyTagsException
-
The request contains more tags than can be associated with a resource (50 tags per resource). The maximum number of tags includes both existing tags and those included in your current request.
HTTP Status Code: 400
- ValidationException
-
Input validation failed. Check your request parameters and retry the request.
HTTP Status Code: 400
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: