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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
[Bug Fix] Watsonx Audio Transcription - ensure only correct params are sent to API (#17840)
Ishaan Jaff8041e373d67a
diff --git a/litellm/llms/watsonx/audio_transcription/transformation.py b/litellm/llms/watsonx/audio_transcription/transformation.pyindex 368d755777c..186d858321a 100644--- a/litellm/llms/watsonx/audio_transcription/transformation.py+++ b/litellm/llms/watsonx/audio_transcription/transformation.py@@ -112,12 +112,6 @@ class IBMWatsonXAudioTranscriptionConfig(if key in supported_params and value is not None:form_data[key] = value # type: ignore- # Set default response_format for cost calculation- if "response_format" not in form_data or (- form_data.get("response_format") in ["text", "json"]- ):- form_data["response_format"] = "verbose_json"-# Prepare files dict with the audio filefiles = {"file": (diff --git a/tests/test_litellm/llms/watsonx/audio_transcription/test_watsonx_audio_transcription_transformation.py b/tests/test_litellm/llms/watsonx/audio_transcription/test_watsonx_audio_transcription_transformation.pyindex 049285343d4..e36a494998b 100644--- a/tests/test_litellm/llms/watsonx/audio_transcription/test_watsonx_audio_transcription_transformation.py+++ b/tests/test_litellm/llms/watsonx/audio_transcription/test_watsonx_audio_transcription_transformation.py@@ -128,9 +128,64 @@ class TestWatsonXAudioTranscription:# OpenAI params should be in form dataassert data.get("language") == "en"assert data.get("temperature") == 0.5- assert data.get("response_format") == "verbose_json" # Default for cost calculation+ # response_format should NOT be set by default - only send what user specifies+ assert "response_format" not in data# Validate file is in files dict (multipart/form-data)files = captured_request.get("files", {})assert "file" in filesassert isinstance(files["file"], tuple) # Should be (filename, content, content_type)++ @pytest.mark.asyncio+ async def test_watsonx_transcription_only_user_params_sent(self):+ """+ Test that only user-specified params are sent in request body to WatsonX.++ LiteLLM should NOT add extra params like response_format if user didn't specify them.+ """+ captured_request = {}++ async def mock_post(*args, **kwargs):+ captured_request["data"] = kwargs.get("data", {})+ captured_request["files"] = kwargs.get("files", {})++ mock_response = MagicMock()+ mock_response.json.return_value = {+ "text": "test transcription",+ "duration": 1.0,+ }+ mock_response.status_code = 200+ return mock_response++ with patch("litellm.llms.custom_httpx.http_handler.AsyncHTTPHandler.post", new=mock_post):+ try:+ # Minimal request - only required params+ await litellm.atranscription(+ model="watsonx/whisper-large-v3-turbo",+ file=b"fake_audio_data",+ api_base="https://us-south.ml.cloud.ibm.com",+ api_key="test-api-key",+ project_id="test-project-123",+ token="test-bearer-token",+ )+ except Exception:+ pass # We just want to capture the request++ data = captured_request.get("data", {})++ # These are the ONLY keys that should be in data+ expected_keys = {"model", "project_id"}+ actual_keys = set(data.keys())++ assert actual_keys == expected_keys, (+ f"Request body should only contain {expected_keys}, "+ f"but got {actual_keys}. "+ f"Extra keys: {actual_keys - expected_keys}"+ )++ # Specifically verify response_format is NOT added+ assert "response_format" not in data, "response_format should NOT be added by default"++ # Verify file is sent separately+ files = captured_request.get("files", {})+ assert "file" in files