applyGuardrail method
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
May throw AccessDeniedException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ServiceQuotaExceededException.
May throw ServiceUnavailableException.
May throw ThrottlingException.
May throw ValidationException.
Parameter content :
The content details used in the request to apply the guardrail.
Parameter guardrailIdentifier :
The guardrail identifier used in the request to apply the guardrail.
Parameter guardrailVersion :
The guardrail version used in the request to apply the guardrail.
Parameter source :
The source of data used in the request to apply the guardrail.
Parameter outputScope :
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).
Implementation
Future<ApplyGuardrailResponse> applyGuardrail({
required List<GuardrailContentBlock> content,
required String guardrailIdentifier,
required String guardrailVersion,
required GuardrailContentSource source,
GuardrailOutputScope? outputScope,
}) async {
final $payload = <String, dynamic>{
'content': content,
'source': source.value,
if (outputScope != null) 'outputScope': outputScope.value,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri:
'/guardrail/${Uri.encodeComponent(guardrailIdentifier)}/version/${Uri.encodeComponent(guardrailVersion)}/apply',
exceptionFnMap: _exceptionFns,
);
return ApplyGuardrailResponse.fromJson(response);
}