Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

return traces in bedrock guardrails when enabled

Ishaan Jaff9851fa7b1b3c
diff --git a/litellm/utils.py b/litellm/utils.py
index 414550be485..d915690fc6e 100644
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@ -10226,6 +10226,14 @@ class CustomStreamWrapper:
return
elif self.received_finish_reason is not None:
if self.sent_last_chunk is True:
+ # Bedrock returns the guardrail trace in the last chunk - we want to return this here
+ if (
+ self.custom_llm_provider == "bedrock"
+ and "trace" in model_response
+ ):
+ return model_response
+
+ # Default - return StopIteration
raise StopIteration
# flush any remaining holding chunk
if len(self.holding_chunk) > 0: