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]

fix(proxy): attach litellm_call_id to client disconnect log record

yucheng1b474b075f1b
diff --git a/litellm/proxy/common_request_processing.py b/litellm/proxy/common_request_processing.py
index 2cfcce2c11c..37c1ab39632 100644
--- a/litellm/proxy/common_request_processing.py
+++ b/litellm/proxy/common_request_processing.py
@@ -1457,6 +1457,7 @@ def _log_llm_api_exception(e: Exception, litellm_call_id: str | None) -> None:
"litellm.proxy.proxy_server._handle_llm_api_exception(): client disconnected, "
"upstream LLM request cancelled - litellm_call_id=%s",
litellm_call_id,
+ extra=MappingProxyType({"litellm_call_id": litellm_call_id}),
)
return
log_fn: Final = (
diff --git a/tests/test_litellm/proxy/test_common_request_processing.py b/tests/test_litellm/proxy/test_common_request_processing.py
index cdf2118a1c5..735b0dee3dc 100644
--- a/tests/test_litellm/proxy/test_common_request_processing.py
+++ b/tests/test_litellm/proxy/test_common_request_processing.py
@@ -8741,4 +8741,6 @@ class TestErrorLogCarriesCallId:
finally:
verbose_proxy_logger.propagate = False
- assert call_id in caplog.records[-1].getMessage()
+ record: Final = caplog.records[-1]
+ assert record.litellm_call_id == call_id
+ assert call_id in record.getMessage()