fix(litellm_logging.py): correctly log token usage for audio transcription calls to langfuse

This commit is contained in:
Krrish Dholakia 2025-11-08 16:47:48 -08:00
parent 08cfc2bf7e
commit 0640949333

View file

@ -1597,7 +1597,16 @@ class Logging(LiteLLMLoggingBaseClass):
if hasattr(result, "model_dump")
else dict(result)
)
elif isinstance(result, TranscriptionResponse):
from litellm.litellm_core_utils.llm_cost_calc.usage_object_transformation import (
TranscriptionUsageObjectTransformation,
)
result = result.model_copy()
transformed_usage = TranscriptionUsageObjectTransformation.transform_transcription_usage_object(
result.usage # type: ignore
)
setattr(result, "usage", transformed_usage)
if (
litellm.max_budget
and self.stream is False