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]

feature: add logging when passthrough return Result

KnyazSh52796fb060e4
diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py
index e84c1e13a8b..560f5478d76 100644
--- a/litellm/litellm_core_utils/litellm_logging.py
+++ b/litellm/litellm_core_utils/litellm_logging.py
@@ -1852,6 +1852,11 @@ class Logging(LiteLLMLoggingBaseClass):
logging_result = self.normalize_logging_result(result=result)
+ if isinstance(result, Response) and isinstance(
+ logging_result, ModelResponse
+ ):
+ result = logging_result
+
if (
standard_logging_object is None
and result is not None
@@ -5569,7 +5574,13 @@ def get_standard_logging_object_payload(
def emit_standard_logging_payload(payload: StandardLoggingPayload):
if os.getenv("LITELLM_PRINT_STANDARD_LOGGING_PAYLOAD"):
- print(json.dumps(payload, indent=4)) # noqa
+ try:
+ print(json.dumps(payload, indent=4, default=str)) # noqa
+ except Exception as e:
+ print(
+ "Error serializing standard logging payload for debug output:",
+ str(e),
+ )
def get_standard_logging_metadata(