create_guardrail¶
Operation¶
create_guardrail
async
¶
create_guardrail(input: CreateGuardrailInput, plugins: list[Plugin] | None = None) -> CreateGuardrailOutput
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.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
CreateGuardrailInput
|
An instance of |
required |
plugins
|
list[Plugin] | None
|
A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations. |
None
|
Returns:
| Type | Description |
|---|---|
CreateGuardrailOutput
|
An instance of |
Input¶
CreateGuardrailInput
dataclass
¶
Dataclass for CreateGuardrailInput structure.
Attributes¶
automated_reasoning_policy_config
class-attribute
instance-attribute
¶
automated_reasoning_policy_config: GuardrailAutomatedReasoningPolicyConfig | None = None
Optional configuration for integrating Automated Reasoning policies with the new guardrail.
blocked_input_messaging
class-attribute
instance-attribute
¶
blocked_input_messaging: str | None = field(repr=False, default=None)
The message to return when the guardrail blocks a prompt.
blocked_outputs_messaging
class-attribute
instance-attribute
¶
blocked_outputs_messaging: str | None = field(repr=False, default=None)
The message to return when the guardrail blocks a model response.
client_request_token
class-attribute
instance-attribute
¶
client_request_token: str | None = None
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.
content_policy_config
class-attribute
instance-attribute
¶
content_policy_config: GuardrailContentPolicyConfig | None = None
The content filter policies to configure for the guardrail.
contextual_grounding_policy_config
class-attribute
instance-attribute
¶
contextual_grounding_policy_config: GuardrailContextualGroundingPolicyConfig | None = None
The contextual grounding policy configuration used to create a guardrail.
cross_region_config
class-attribute
instance-attribute
¶
cross_region_config: GuardrailCrossRegionConfig | None = None
The system-defined guardrail profile that you're using with your guardrail. Guardrail profiles define the destination Amazon Web Services Regions where guardrail inference requests can be automatically routed.
For more information, see the Amazon Bedrock User Guide.
description
class-attribute
instance-attribute
¶
description: str | None = field(repr=False, default=None)
A description of the guardrail.
kms_key_id
class-attribute
instance-attribute
¶
kms_key_id: str | None = None
The ARN of the KMS key that you use to encrypt the guardrail.
name
class-attribute
instance-attribute
¶
name: str | None = field(repr=False, default=None)
The name to give the guardrail.
sensitive_information_policy_config
class-attribute
instance-attribute
¶
sensitive_information_policy_config: GuardrailSensitiveInformationPolicyConfig | None = None
The sensitive information policy to configure for the guardrail.
tags
class-attribute
instance-attribute
¶
tags: list[Tag] | None = None
The tags that you want to attach to the guardrail.
topic_policy_config
class-attribute
instance-attribute
¶
topic_policy_config: GuardrailTopicPolicyConfig | None = None
The topic policies to configure for the guardrail.
word_policy_config
class-attribute
instance-attribute
¶
word_policy_config: GuardrailWordPolicyConfig | None = None
The word policy you configure for the guardrail.