View a markdown version of this page

InvokeGuardrailChecks - Amazon Bedrock

InvokeGuardrailChecks

Evaluates messages against inline guardrail checks. You specify the check configurations directly in the request, and Amazon Bedrock returns per-check results with severity or confidence scores.

Request Syntax

POST /guardrail-checks/invoke HTTP/1.1 Content-type: application/json { "checks": { "contentFilter": { "categories": [ { "category": "string" } ] }, "promptAttack": { "categories": [ { "category": "string" } ] }, "sensitiveInformation": { "entities": [ { "type": "string" } ] } }, "messages": [ { "content": [ { ... } ], "role": "string" } ] }

URI Request Parameters

The request does not use any URI parameters.

Request Body

The request accepts the following data in JSON format.

checks

The inline check configurations that specify which guardrail checks to run against the messages.

Type: GuardrailChecksConfig object

Required: Yes

messages

The messages to evaluate against the specified guardrail checks. Each message includes a role and one or more content blocks.

Type: Array of GuardrailChecksMessage objects

Array Members: Minimum number of 1 item.

Required: Yes

Response Syntax

HTTP/1.1 200 Content-type: application/json { "results": { "contentFilter": { "results": [ { "category": "string", "severityScore": number } ] }, "promptAttack": { "results": [ { "category": "string", "severityScore": number } ] }, "sensitiveInformation": { "results": [ { "beginOffset": number, "confidenceScore": number, "contentIndex": number, "endOffset": number, "messageIndex": number, "type": "string" } ], "truncated": boolean } }, "usage": { "contentFilter": { "textUnits": number }, "promptAttack": { "textUnits": number }, "sensitiveInformation": { "textUnits": number } } }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

results

The per-check results containing findings from the guardrail evaluation.

Type: GuardrailChecksResults object

usage

The per-check text unit consumption for the guardrail evaluation.

Type: GuardrailChecksUsageResults object

Errors

For information about the errors that are common to all actions, see Common Error Types.

AccessDeniedException

The request is denied because you do not have sufficient permissions to perform the requested action. For troubleshooting this error, see AccessDeniedException in the Amazon Bedrock User Guide

HTTP Status Code: 403

InternalServerException

An internal server error occurred. For troubleshooting this error, see InternalFailure in the Amazon Bedrock User Guide

HTTP Status Code: 500

ServiceUnavailableException

The service isn't currently available. For troubleshooting this error, see ServiceUnavailable in the Amazon Bedrock User Guide

HTTP Status Code: 503

ThrottlingException

Your request was denied due to exceeding the account quotas for Amazon Bedrock. For troubleshooting this error, see ThrottlingException in the Amazon Bedrock User Guide

HTTP Status Code: 429

ValidationException

The input fails to satisfy the constraints specified by Amazon Bedrock. For troubleshooting this error, see ValidationError in the Amazon Bedrock User Guide

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: