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
5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306 5307 5308 5309 5310 5311 5312 5313 5314 5315 5316 5317 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348 5349 5350 5351 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 5366 5367 5368 5369 5370 5371 5372 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 5406 5407 5408 5409 5410 5411 5412 5413 5414 5415 5416 5417 5418 5419 5420 | |