Skip to content

create_guardrail

Operation

create_guardrail

create_guardrail(request: CreateGuardrailInput | CreateGuardrailInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[CreateGuardrailInputDict]) -> 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
request CreateGuardrailInput | CreateGuardrailInputDict | None

The input as a model or dictionary. Pass this or keyword arguments, not both.

None
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
**kwargs Unpack[CreateGuardrailInputDict]

The input fields as keyword arguments.

{}

Returns:

Type Description
CreateGuardrailOutput

An instance of CreateGuardrailOutput.

create_guardrail async

create_guardrail(request: CreateGuardrailInput | CreateGuardrailInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[CreateGuardrailInputDict]) -> 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
request CreateGuardrailInput | CreateGuardrailInputDict | None

The input as a model or dictionary. Pass this or keyword arguments, not both.

None
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
**kwargs Unpack[CreateGuardrailInputDict]

The input fields as keyword arguments.

{}

Returns:

Type Description
CreateGuardrailOutput

An instance of CreateGuardrailOutput.

Input

Pass the input as keyword arguments, a positional dictionary, or a positional model object. Pass plugins separately as a keyword argument.

CreateGuardrailInputDict

Bases: TypedDict

Dictionary form of CreateGuardrailInput.

Attributes

automated_reasoning_policy_config instance-attribute

Optional configuration for integrating Automated Reasoning policies with the new guardrail.

blocked_input_messaging instance-attribute
blocked_input_messaging: Required[str]

The message to return when the guardrail blocks a prompt.

blocked_outputs_messaging instance-attribute
blocked_outputs_messaging: Required[str]

The message to return when the guardrail blocks a model response.

client_request_token instance-attribute
client_request_token: str | 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.

This field is autopopulated if not provided.

content_policy_config instance-attribute

The content filter policies to configure for the guardrail.

contextual_grounding_policy_config instance-attribute

The contextual grounding policy configuration used to create a guardrail.

cross_region_config instance-attribute

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 instance-attribute
description: str | None

A description of the guardrail.

kms_key_id instance-attribute
kms_key_id: str | None

The ARN of the KMS key that you use to encrypt the guardrail.

name instance-attribute
name: Required[str]

The name to give the guardrail.

sensitive_information_policy_config instance-attribute

The sensitive information policy to configure for the guardrail.

tags instance-attribute
tags: Sequence[Tag | TagDict] | None

The tags that you want to attach to the guardrail.

topic_policy_config instance-attribute

The topic policies to configure for the guardrail.

word_policy_config instance-attribute

The word policy you configure for the guardrail.

CreateGuardrailInput dataclass

Bases: _SerdeShape

Dataclass for CreateGuardrailInput structure.

Attributes

automated_reasoning_policy_config class-attribute instance-attribute
automated_reasoning_policy_config: GuardrailAutomatedReasoningPolicyConfig | None = ...

Optional configuration for integrating Automated Reasoning policies with the new guardrail.

blocked_input_messaging class-attribute instance-attribute
blocked_input_messaging: str | None = ...

The message to return when the guardrail blocks a prompt.

blocked_outputs_messaging class-attribute instance-attribute
blocked_outputs_messaging: str | None = ...

The message to return when the guardrail blocks a model response.

client_request_token class-attribute instance-attribute
client_request_token: str | 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.

This field is autopopulated if not provided.

content_policy_config class-attribute instance-attribute
content_policy_config: GuardrailContentPolicyConfig | None = ...

The content filter policies to configure for the guardrail.

contextual_grounding_policy_config class-attribute instance-attribute
contextual_grounding_policy_config: GuardrailContextualGroundingPolicyConfig | None = ...

The contextual grounding policy configuration used to create a guardrail.

cross_region_config class-attribute instance-attribute
cross_region_config: GuardrailCrossRegionConfig | 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 = ...

A description of the guardrail.

kms_key_id class-attribute instance-attribute
kms_key_id: str | None = ...

The ARN of the KMS key that you use to encrypt the guardrail.

name class-attribute instance-attribute
name: str | None = ...

The name to give the guardrail.

sensitive_information_policy_config class-attribute instance-attribute
sensitive_information_policy_config: GuardrailSensitiveInformationPolicyConfig | None = ...

The sensitive information policy to configure for the guardrail.

tags class-attribute instance-attribute
tags: list[Tag] | None = ...

The tags that you want to attach to the guardrail.

topic_policy_config class-attribute instance-attribute
topic_policy_config: GuardrailTopicPolicyConfig | None = ...

The topic policies to configure for the guardrail.

word_policy_config class-attribute instance-attribute
word_policy_config: GuardrailWordPolicyConfig | None = ...

The word policy you configure for the guardrail.

Output

CreateGuardrailOutput dataclass

Bases: _SerdeShape

Dataclass for CreateGuardrailOutput structure.

Attributes

created_at instance-attribute
created_at: datetime

The time at which the guardrail was created.

guardrail_arn instance-attribute
guardrail_arn: str

The ARN of the guardrail.

guardrail_id instance-attribute
guardrail_id: str

The unique identifier of the guardrail that was created.

response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.

version instance-attribute
version: str

The version of the guardrail that was created. This value will always be DRAFT.