Skip to content

BedrockRuntimeClient.apply_guardrail

rboto-bedrock-runtime==0.4.0 · Service index · Types

Model summary (excerpt): 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

Install and imports

python -m pip install "rboto[bedrock-runtime]==0.4.0"
from rboto import BedrockRuntimeClient
from collections.abc import Sequence
from rboto_bedrock_runtime.types import (
    ApplyGuardrailOutput,
    GuardrailContentBlock,
    GuardrailContentSource,
    GuardrailOutputScope,
)

Signature

async def apply_guardrail(
    *,
    guardrail_identifier: str,
    guardrail_version: str,
    source: GuardrailContentSource,
    content: Sequence[GuardrailContentBlock],
    output_scope: GuardrailOutputScope | None = None,
) -> ApplyGuardrailOutput: ...

Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.

Arguments

Argument Required Model notes (excerpt)
guardrail_identifier Yes The guardrail identifier used in the request to apply the guardrail.
guardrail_version Yes The guardrail version used in the request to apply the guardrail.
source Yes The source of data used in the request to apply the guardrail.
content Yes The content details used in the request to apply the guardrail.
output_scope No 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...

Output

ApplyGuardrailOutput.

Read-only native attributes, accessed as response.field. Collection getters materialize Python values; to_dict() recursively materializes a mapping. Streams are consumed once.

Field Type Presence References
usage GuardrailUsageOutput | None Always present GuardrailUsageOutput
action GuardrailActionOutput Always present GuardrailActionOutput
action_reason str | None Always present —
outputs list[GuardrailOutputContentOutput] Always present GuardrailOutputContentOutput
assessments list[GuardrailAssessmentOutput] Always present GuardrailAssessmentOutput
guardrail_coverage GuardrailCoverageOutput | None Always present GuardrailCoverageOutput

| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.

ApplyGuardrailOutput, GuardrailContentBlock, GuardrailContentSource, GuardrailOutputScope

Follow these links for nested inputs and outputs; recursive types link back to the same type page.

Pagination and streaming

No generated paginator for this operation.

No output stream.

Errors

Import from rboto_bedrock_runtime.exceptions:

AccessDeniedError, InternalServerError, ResourceNotFoundError, ServiceQuotaExceededError, ServiceUnavailableError, ThrottlingError, ValidationError.

Other service failures use the service base error; credential, transport and timeout failures use shared errors.

Service guide · Pinned model