Use a guardrail - Amazon Bedrock

Use a guardrail

After you create a guardrail, you can use it in in the following ways:

  • Model inference – In the Amazon Bedrock console, select your guardrail when you use a playground. With Amazon Bedrock API, you can use a guardrail with the base inference operations or the Converse API.

  • Add a guardrail to your agent – You can associate a guardrail with your agent when you create or update an agent. In the Amazon Bedrock console, you add a guardrail in the Guardrail details section of the Agent builder. In the Amazon Bedrock API, you specify a GuardrailConfiguration when you send a CreateAgent or UpdateAgent request.

  • Use a guardrail when you query your knowledge base – Follow the steps in the Guardrails section of the query configurations. In the Amazon Bedrock console, add a guardrail when you set Configurations. In the Amazon Bedrock API, include a GuardrailConfiguration when you send a RetrieveAndGenerate request.

This section covers using a guardrail with model inference and the Amazon Bedrock API. You can use the base inference operations (InvokeModel and InvokeModelWithResponseStream) and the Converse API (Converse and ConverseStream). With both sets of operations you can use a guardrail with synchronous and streaming model inference. You can also selectively evaluate user input and can configure streaming response behavior.