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: improve response api handling and cold storage configuration

soojin9fcad0382cbf
diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py
index 2f21d280899..07cb1d8662b 100644
--- a/litellm/litellm_core_utils/litellm_logging.py
+++ b/litellm/litellm_core_utils/litellm_logging.py
@@ -4150,15 +4150,24 @@ class StandardLoggingPayloadSetup:
from litellm.integrations.s3 import get_s3_object_key
# Only generate object key if cold storage is configured
- if litellm.configured_cold_storage_logger is None:
+ configured_cold_storage_logger = litellm.configured_cold_storage_logger
+ if configured_cold_storage_logger is None:
return None
try:
# Generate file name in same format as litellm.utils.get_logging_id
s3_file_name = f"time-{start_time.strftime('%H-%M-%S-%f')}_{response_id}"
+ # Get the actual s3_path from the configured cold storage logger instance
+ s3_path = "" # default value
+
+ # Get the actual logger instance from the logger name
+ custom_logger = litellm.logging_callback_manager.get_active_custom_logger_for_callback_name(configured_cold_storage_logger)
+ if custom_logger and hasattr(custom_logger, 's3_path') and custom_logger.s3_path:
+ s3_path = custom_logger.s3_path
+
s3_object_key = get_s3_object_key(
- s3_path="", # Use empty path as default
+ s3_path=s3_path, # Use actual s3_path from logger configuration
team_alias_prefix="", # Don't split by team alias for cold storage
start_time=start_time,
s3_file_name=s3_file_name,
diff --git a/litellm/responses/litellm_completion_transformation/session_handler.py b/litellm/responses/litellm_completion_transformation/session_handler.py
index bfb996a2385..d1e009e62dd 100644
--- a/litellm/responses/litellm_completion_transformation/session_handler.py
+++ b/litellm/responses/litellm_completion_transformation/session_handler.py
@@ -141,7 +141,7 @@ class ResponsesSessionHandler:
# Add Output messages for this Spend Log
############################################################
_response_output = spend_log.get("response", "{}")
- if isinstance(_response_output, dict):
+ if isinstance(_response_output, dict) and _response_output and _response_output != {}:
# transform `ChatCompletion Response` to `ResponsesAPIResponse`
model_response = ModelResponse(**_response_output)
for choice in model_response.choices: