diff --git a/litellm/llms/azure/audio_transcriptions.py b/litellm/llms/azure/audio_transcriptions.py index be7d0fa30da..1f09ac7574a 100644 --- a/litellm/llms/azure/audio_transcriptions.py +++ b/litellm/llms/azure/audio_transcriptions.py @@ -94,7 +94,7 @@ class AzureAudioTranscription(AzureChatCompletion): additional_args={"complete_input_dict": data}, original_response=stringified_response, ) - hidden_params = {"model": "whisper-1", "custom_llm_provider": "azure"} + hidden_params = {"model": model, "custom_llm_provider": "azure"} final_response: TranscriptionResponse = convert_to_model_response_object(response_object=stringified_response, model_response_object=model_response, hidden_params=hidden_params, response_type="audio_transcription") # type: ignore return final_response @@ -174,7 +174,7 @@ class AzureAudioTranscription(AzureChatCompletion): }, original_response=stringified_response, ) - hidden_params = {"model": "whisper-1", "custom_llm_provider": "azure"} + hidden_params = {"model": model, "custom_llm_provider": "azure"} response = convert_to_model_response_object( _response_headers=headers, response_object=stringified_response, diff --git a/litellm/llms/openai/transcriptions/handler.py b/litellm/llms/openai/transcriptions/handler.py index 78a913cbf38..c2747222fc0 100644 --- a/litellm/llms/openai/transcriptions/handler.py +++ b/litellm/llms/openai/transcriptions/handler.py @@ -155,7 +155,7 @@ class OpenAIAudioTranscription(OpenAIChatCompletion): additional_args={"complete_input_dict": data}, original_response=stringified_response, ) - hidden_params = {"model": "whisper-1", "custom_llm_provider": "openai"} + hidden_params = {"model": model, "custom_llm_provider": "openai"} final_response: TranscriptionResponse = convert_to_model_response_object(response_object=stringified_response, model_response_object=model_response, hidden_params=hidden_params, response_type="audio_transcription") # type: ignore return final_response @@ -210,7 +210,9 @@ class OpenAIAudioTranscription(OpenAIChatCompletion): additional_args={"complete_input_dict": data}, original_response=stringified_response, ) - hidden_params = {"model": "whisper-1", "custom_llm_provider": "openai"} + # Extract the actual model from data instead of hardcoding "whisper-1" + actual_model = data.get("model", "whisper-1") + hidden_params = {"model": actual_model, "custom_llm_provider": "openai"} return convert_to_model_response_object(response_object=stringified_response, model_response_object=model_response, hidden_params=hidden_params, response_type="audio_transcription") # type: ignore except Exception as e: ## LOGGING diff --git a/tests/local_testing/test_whisper.py b/tests/local_testing/test_whisper.py index bca7ae2addd..54bbcaa93dc 100644 --- a/tests/local_testing/test_whisper.py +++ b/tests/local_testing/test_whisper.py @@ -164,3 +164,72 @@ async def test_gpt_4o_transcribe(): await litellm.atranscription( model="openai/gpt-4o-transcribe", file=audio_file, response_format="json" ) + + +@pytest.mark.asyncio +async def test_gpt_4o_transcribe_model_mapping(): + """Test that GPT-4o transcription models are correctly mapped and not hardcoded to whisper-1""" + + # Test GPT-4o mini transcribe + response = await litellm.atranscription( + model="openai/gpt-4o-mini-transcribe", + file=audio_file, + response_format="json" + ) + + # Check that the response contains the correct model in hidden params + assert response._hidden_params is not None + assert response._hidden_params["model"] == "gpt-4o-mini-transcribe" + assert response._hidden_params["custom_llm_provider"] == "openai" + assert response.text is not None + + # Test GPT-4o transcribe + response2 = await litellm.atranscription( + model="openai/gpt-4o-transcribe", + file=audio_file, + response_format="json" + ) + + # Check that the response contains the correct model in hidden params + assert response2._hidden_params is not None + assert response2._hidden_params["model"] == "gpt-4o-transcribe" + assert response2._hidden_params["custom_llm_provider"] == "openai" + assert response2.text is not None + + # Test traditional whisper-1 still works + response3 = await litellm.atranscription( + model="openai/whisper-1", + file=audio_file, + response_format="json" + ) + + # Check that the response contains the correct model in hidden params + assert response3._hidden_params is not None + assert response3._hidden_params["model"] == "whisper-1" + assert response3._hidden_params["custom_llm_provider"] == "openai" + assert response3.text is not None + + +@pytest.mark.asyncio +async def test_azure_transcribe_model_mapping(): + """Test that Azure transcription models are correctly mapped and not hardcoded to whisper-1""" + + # Test Azure whisper-1 + try: + response = await litellm.atranscription( + model="azure/whisper-1", + file=audio_file, + response_format="json", + api_key=os.getenv("AZURE_EUROPE_API_KEY"), + api_base="https://my-endpoint-europe-berri-992.openai.azure.com/", + drop_params=True + ) + + # Check that the response contains the correct model in hidden params + assert response._hidden_params is not None + assert response._hidden_params["model"] == "whisper-1" + assert response._hidden_params["custom_llm_provider"] == "azure" + assert response.text is not None + except Exception as e: + # If Azure credentials are not available, skip this test + pytest.skip(f"Azure credentials not available: {str(e)}")