Skip to content

apply_guardrail

Operation

apply_guardrail

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

The input fields as keyword arguments.

{}

Returns:

Type Description
ApplyGuardrailOutput

An instance of ApplyGuardrailOutput.

apply_guardrail async

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

The input fields as keyword arguments.

{}

Returns:

Type Description
ApplyGuardrailOutput

An instance of ApplyGuardrailOutput.

Input

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

ApplyGuardrailInputDict

Bases: TypedDict

Dictionary form of ApplyGuardrailInput.

Attributes

content instance-attribute

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

guardrail_identifier instance-attribute
guardrail_identifier: Required[str]

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

guardrail_version instance-attribute
guardrail_version: Required[str]

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

output_scope instance-attribute
output_scope: str | 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 instance-attribute
source: Required[str]

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

ApplyGuardrailInput dataclass

Bases: _SerdeShape

Dataclass for ApplyGuardrailInput structure.

Attributes

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

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

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

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

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

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

output_scope class-attribute instance-attribute
output_scope: str | 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: str | None = ...

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

Output

ApplyGuardrailOutput dataclass

Bases: _SerdeShape

Dataclass for ApplyGuardrailOutput structure.

Attributes

action instance-attribute
action: str

The action taken in the response from the guardrail.

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

The guardrail coverage details in the apply guardrail response.

outputs instance-attribute

The output details in the response from the guardrail.

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.

usage instance-attribute

The usage details in the response from the guardrail.