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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test_redaction_responses_api
Ishaan Jaffer993c75d10bd0
diff --git a/tests/logging_callback_tests/test_logging_redaction_e2e_test.py b/tests/logging_callback_tests/test_logging_redaction_e2e_test.pyindex 3f432f91199..b261daab6a7 100644--- a/tests/logging_callback_tests/test_logging_redaction_e2e_test.py+++ b/tests/logging_callback_tests/test_logging_redaction_e2e_test.py@@ -151,10 +151,8 @@ async def test_redaction_responses_api():# Check that usage has been transformed to chat completion formatassert "prompt_tokens" in standard_logging_payload["response"]["usage"]assert "completion_tokens" in standard_logging_payload["response"]["usage"]- from litellm.types.utils import LiteLLMCommonStrings- redacted_str = LiteLLMCommonStrings.redacted_by_litellm.value- assert standard_logging_payload["messages"][0]["content"] == redacted_str+ assert standard_logging_payload["messages"][0]["content"] == "redacted-by-litellm"# Verify that output content is redactedassert "output" in standard_logging_payload["response"]@@ -163,7 +161,7 @@ async def test_redaction_responses_api():if "content" in output_item and isinstance(output_item["content"], list):for content_item in output_item["content"]:if "text" in content_item:- assert content_item["text"] == redacted_str, f"Expected redacted text but got: {content_item['text']}"+ assert content_item["text"] == "redacted-by-litellm", f"Expected redacted text but got: {content_item['text']}"print("logged standard logging payload for ResponsesAPIResponse",json.dumps(standard_logging_payload, indent=2),@@ -211,17 +209,14 @@ async def test_redaction_responses_api_stream():assert standard_logging_payload is not None# Verify redaction in ResponsesAPIResponse format- from litellm.types.utils import LiteLLMCommonStrings- redacted_str = LiteLLMCommonStrings.redacted_by_litellm.value-# The streaming response is in ModelResponse format (choices), not ResponsesAPIResponse format (output)assert isinstance(standard_logging_payload["response"], dict)- assert standard_logging_payload["messages"][0]["content"] == redacted_str+ assert standard_logging_payload["messages"][0]["content"] == "redacted-by-litellm"# Verify that response content is redacted (ModelResponse format)if "choices" in standard_logging_payload["response"]:# ModelResponse format- assert standard_logging_payload["response"]["choices"][0]["message"]["content"] == redacted_str+ assert standard_logging_payload["response"]["choices"][0]["message"]["content"] == "redacted-by-litellm"elif "output" in standard_logging_payload["response"]:# ResponsesAPIResponse formatoutput_items = standard_logging_payload["response"]["output"]@@ -229,7 +224,7 @@ async def test_redaction_responses_api_stream():if "content" in output_item and isinstance(output_item["content"], list):for content_item in output_item["content"]:if "text" in content_item:- assert content_item["text"] == redacted_str, f"Expected redacted text but got: {content_item['text']}"+ assert content_item["text"] == "redacted-by-litellm", f"Expected redacted text but got: {content_item['text']}"print("logged standard logging payload for ResponsesAPIResponse stream",json.dumps(standard_logging_payload, indent=2),