- Newest
- Most votes
- Most comments
When you use guardrails with Amazon Bedrock model inference (via InvokeModel, InvokeModelWithResponseStream, Converse, or ConverseStream operations), the guardrail evaluation happens automatically as part of the inference process. This is different from explicitly calling the ApplyGuardrail API.
During model inference with guardrails:
- The input is evaluated against configured guardrail policies
- If the input passes, the model generates a response
- The model response is then evaluated against the guardrail policies
- The final response is returned based on guardrail evaluation results
The ApplyGuardrail API is a separate service that allows you to assess text against your guardrails without invoking foundation models. It's designed for use cases where you want to validate content independently from model inference, such as:
- Content validation before processing
- Flexible deployment anywhere in your application flow
- Evaluating text without calling a foundation model
Based on your description, you're making two separate calls:
- Model inference with guardrails (which includes guardrail evaluation)
- An additional ApplyGuardrail API call to mask PII in the response before logging
This explains why you're seeing charges for both model inference and ApplyGuardrail operations. The second ApplyGuardrail call is not automatically part of model inference - it's an additional API call you're making specifically to mask PII before storing the data.
If your ApplyGuardrail costs are significantly higher than your inference costs, you might want to review your implementation to see if there are opportunities to optimize how and when you're calling the ApplyGuardrail API.
Sources
How Amazon Bedrock Guardrails works - Amazon Bedrock
Use the ApplyGuardrail API in your application - Amazon Bedrock
ApplyGuardrail - Amazon Bedrock
Relevant content
asked 2 years ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 2 months ago

This makes sense, however for tracking inference costs, when I examine the response I get no information about which filters have been applied to the prompt and response. So for this cost https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-how.html#guardrails-charges how can I track this?