create_guardrail
async
¶
create_guardrail(
name: GuardrailName,
blocked_input_messaging: GuardrailBlockedMessaging,
blocked_outputs_messaging: GuardrailBlockedMessaging,
*,
config_overrides: Optional[AsyncBedrockClientConfig] = None,
description: Optional[GuardrailDescription] = None,
topic_policy_config: Optional[GuardrailTopicPolicyConfig] = None,
content_policy_config: Optional[GuardrailContentPolicyConfig] = None,
word_policy_config: Optional[GuardrailWordPolicyConfig] = None,
sensitive_information_policy_config: Optional[
GuardrailSensitiveInformationPolicyConfig
] = None,
contextual_grounding_policy_config: Optional[
GuardrailContextualGroundingPolicyConfig
] = None,
automated_reasoning_policy_config: Optional[
GuardrailAutomatedReasoningPolicyConfig
] = None,
cross_region_config: Optional[GuardrailCrossRegionConfig] = None,
kms_key_id: Optional[KmsKeyId] = None,
tags: Optional[TagList] = None,
client_request_token: Optional[IdempotencyToken] = None,
) -> CreateGuardrailResponse
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(GuardrailName) –The name to give the guardrail.
-
description(Optional[GuardrailDescription], default:None) –A description of the guardrail.
-
topic_policy_config(Optional[GuardrailTopicPolicyConfig], default:None) –The topic policies to configure for the guardrail.
-
content_policy_config(Optional[GuardrailContentPolicyConfig], default:None) –The content filter policies to configure for the guardrail.
-
word_policy_config(Optional[GuardrailWordPolicyConfig], default:None) –The word policy you configure for the guardrail.
-
sensitive_information_policy_config(Optional[GuardrailSensitiveInformationPolicyConfig], default:None) –The sensitive information policy to configure for the guardrail.
-
contextual_grounding_policy_config(Optional[GuardrailContextualGroundingPolicyConfig], default:None) –The contextual grounding policy configuration used to create a guardrail.
-
automated_reasoning_policy_config(Optional[GuardrailAutomatedReasoningPolicyConfig], default:None) –Optional configuration for integrating Automated Reasoning policies with the new guardrail.
-
cross_region_config(Optional[GuardrailCrossRegionConfig], default: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.
-
blocked_input_messaging(GuardrailBlockedMessaging) –The message to return when the guardrail blocks a prompt.
-
blocked_outputs_messaging(GuardrailBlockedMessaging) –The message to return when the guardrail blocks a model response.
-
kms_key_id(Optional[KmsKeyId], default:None) –The ARN of the KMS key that you use to encrypt the guardrail.
-
tags(Optional[TagList], default:None) –The tags that you want to attach to the guardrail.
-
client_request_token(Optional[IdempotencyToken], default: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.
Raises:
-
AccessDeniedException–The request is denied because of missing access permissions.
-
ConflictException–Error occurred because of a conflict while performing an operation.
-
InternalServerException–An internal server error occurred. Retry your request.
-
ResourceNotFoundException–The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.
-
ServiceQuotaExceededException–The number of requests exceeds the service quota. Resubmit your request later.
-
ThrottlingException–The number of requests exceeds the limit. Resubmit your request later.
-
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.
-
ValidationException–Input validation failed. Check your request parameters and retry the request.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_bedrock/_services/async_bedrock.py
4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 | |