Skip to content

Bedrock Runtime  >  Operations  >  apply_guardrail

apply_guardrail

Operation

apply_guardrail async

apply_guardrail(input: ApplyGuardrailInput, plugins: list[Plugin] | None = None) -> ApplyGuardrailOutput

The action to apply a guardrail.

For troubleshooting some of the common errors you might encounter when using the ApplyGuardrail API, see Troubleshooting Amazon Bedrock API Error Codes in the Amazon Bedrock User Guide

Parameters:

Name Type Description Default
input ApplyGuardrailInput

An instance of ApplyGuardrailInput.

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
ApplyGuardrailOutput

An instance of ApplyGuardrailOutput.

Input

ApplyGuardrailInput dataclass

Dataclass for ApplyGuardrailInput structure.

Attributes

content class-attribute instance-attribute
content: list[GuardrailContentBlock] | None = None

The content details used in the request to apply the guardrail.

guardrail_identifier class-attribute instance-attribute
guardrail_identifier: str | None = None

The guardrail identifier used in the request to apply the guardrail.

guardrail_version class-attribute instance-attribute
guardrail_version: str | None = None

The guardrail version used in the request to apply the guardrail.

output_scope class-attribute instance-attribute
output_scope: GuardrailOutputScope | None = None

Specifies the scope of the output that you get in the response. Set to FULL to return the entire output, including any detected and non-detected entries in the response for enhanced debugging.

Note that the full output scope doesn't apply to word filters or regex in sensitive information filters. It does apply to all other filtering policies, including sensitive information with filters that can detect personally identifiable information (PII).

source class-attribute instance-attribute
source: GuardrailContentSource | None = None

The source of data used in the request to apply the guardrail.

Output

ApplyGuardrailOutput dataclass

Dataclass for ApplyGuardrailOutput structure.

Attributes

action instance-attribute

The action taken in the response from the guardrail.

action_reason class-attribute instance-attribute
action_reason: str | None = None

The reason for the action taken when harmful content is detected.

assessments instance-attribute
assessments: list[GuardrailAssessment]

The assessment details in the response from the guardrail.

guardrail_coverage class-attribute instance-attribute
guardrail_coverage: GuardrailCoverage | None = None

The guardrail coverage details in the apply guardrail response.

outputs instance-attribute
outputs: list[GuardrailOutputContent]

The output details in the response from the guardrail.

usage instance-attribute

The usage details in the response from the guardrail.