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(ovhcloud): use explicit None check for seconds field in STT response

KunalG67e55e73d69b0b
diff --git a/litellm/llms/ovhcloud/audio_transcription/transformation.py b/litellm/llms/ovhcloud/audio_transcription/transformation.py
index e3c8308d507..f49f31d7ecd 100644
--- a/litellm/llms/ovhcloud/audio_transcription/transformation.py
+++ b/litellm/llms/ovhcloud/audio_transcription/transformation.py
@@ -160,7 +160,11 @@ class OVHCloudAudioTranscriptionConfig(BaseAudioTranscriptionConfig):
# `duration` is replaced by `seconds` in STT responses.
# Prefer `seconds`, fall back to `duration`, normalize to `duration`
# so downstream consumers see a consistent key.
- duration = response_json.get("seconds") or response_json.get("duration")
+ duration = (
+ response_json["seconds"]
+ if "seconds" in response_json and response_json["seconds"] is not None
+ else response_json.get("duration")
+ )
if duration is not None:
response_json["duration"] = duration
diff --git a/tests/test_litellm/llms/ovhcloud/test_ovhcloud_audio_transcription_transformation.py b/tests/test_litellm/llms/ovhcloud/test_ovhcloud_audio_transcription_transformation.py
index e9abf50ba75..c8751fb2d95 100644
--- a/tests/test_litellm/llms/ovhcloud/test_ovhcloud_audio_transcription_transformation.py
+++ b/tests/test_litellm/llms/ovhcloud/test_ovhcloud_audio_transcription_transformation.py
@@ -96,4 +96,19 @@ class TestOVHCloudDurationFieldMigration:
result = config.transform_audio_transcription_response(mock_response)
assert result.text == "Hello world"
- assert result._hidden_params["duration"] == 2.71
\ No newline at end of file
+ assert result._hidden_params["duration"] == 2.71
+
+
+
+ def test_seconds_zero_mapped_to_duration(self):
+ """seconds=0.0 must not be treated as falsy and lost."""
+ from litellm.llms.ovhcloud.audio_transcription.transformation import (
+ OVHCloudAudioTranscriptionConfig,
+ )
+ from unittest.mock import MagicMock
+
+ config = OVHCloudAudioTranscriptionConfig()
+ mock_response = MagicMock()
+ mock_response.json.return_value = {"text": "silence", "seconds": 0.0}
+ result = config.transform_audio_transcription_response(mock_response)
+ assert result._hidden_params["duration"] == 0.0
\ No newline at end of file