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
fix(proxy): classify Azure Speech short audio behind a prefixed api base
yassinf1b9642c4108
diff --git a/litellm/proxy/pass_through_endpoints/llm_provider_handlers/azure_speech_passthrough_logging_handler.py b/litellm/proxy/pass_through_endpoints/llm_provider_handlers/azure_speech_passthrough_logging_handler.pyindex 8cd1b137de8..33d1815b3c4 100644--- a/litellm/proxy/pass_through_endpoints/llm_provider_handlers/azure_speech_passthrough_logging_handler.py+++ b/litellm/proxy/pass_through_endpoints/llm_provider_handlers/azure_speech_passthrough_logging_handler.py@@ -8,6 +8,7 @@ import httpxfrom litellm._logging import verbose_proxy_loggerfrom litellm.constants import (AZURE_SPEECH_BATCH_MODEL,+ AZURE_SPEECH_BATCH_PATH_PREFIX,AZURE_SPEECH_CUSTOM_LLM_PROVIDER,AZURE_SPEECH_FAST_TRANSCRIPTION_MODEL,AZURE_SPEECH_FAST_TRANSCRIPTION_PATH,@@ -30,7 +31,8 @@ from litellm.types.utils import StandardPassThroughResponseObjectclass AzureSpeechPassthroughLoggingHandler:@staticmethoddef _is_short_audio_route(url_route: str) -> bool:- return urlparse(url_route).path.startswith(AZURE_SPEECH_SHORT_AUDIO_PATH_PREFIX)+ path: Final = urlparse(url_route).path+ return path.rfind(AZURE_SPEECH_SHORT_AUDIO_PATH_PREFIX) > path.rfind(AZURE_SPEECH_BATCH_PATH_PREFIX)@staticmethoddef _is_fast_transcription_route(url_route: str) -> bool:diff --git a/tests/test_litellm/proxy/pass_through_endpoints/llm_provider_handlers/test_azure_speech_passthrough_logging_handler.py b/tests/test_litellm/proxy/pass_through_endpoints/llm_provider_handlers/test_azure_speech_passthrough_logging_handler.pyindex 670f8e65823..a0d27e618f9 100644--- a/tests/test_litellm/proxy/pass_through_endpoints/llm_provider_handlers/test_azure_speech_passthrough_logging_handler.py+++ b/tests/test_litellm/proxy/pass_through_endpoints/llm_provider_handlers/test_azure_speech_passthrough_logging_handler.py@@ -21,6 +21,11 @@ SHORT_AUDIO_URL = ()BATCH_URL = "https://eastus.api.cognitive.microsoft.com/speechtotext/v3.2/transcriptions"FAST_URL = "https://eastus.api.cognitive.microsoft.com/speechtotext/transcriptions:transcribe?api-version=2024-11-15"+PREFIXED_SHORT_AUDIO_URL = (+ "https://apim.example.com/speech-proxy/speech/recognition/conversation/cognitiveservices/v1?language=en-US"+)+PREFIXED_BATCH_URL = "https://apim.example.com/speech/speechtotext/v3.2/transcriptions"+PREFIXED_FAST_URL = "https://apim.example.com/speech/speechtotext/transcriptions:transcribe?api-version=2024-11-15"FAST_BODY = {"durationMilliseconds": 5061, "combinedPhrases": [{"text": "Hello world."}]}FAST_AUDIO_SECONDS = 5.061TRANSCRIPT_BODY = {@@ -87,6 +92,9 @@ class TestAzureSpeechPassthroughHandler:(FAST_URL, "azure_speech/fast-transcription", FAST_AUDIO_SECONDS * PRICE_PER_SECOND),(BATCH_URL, "azure_speech/batch-transcription", 0.0),(f"{BATCH_URL}/8a5d3f2c-0b1e-4c7d-9e6f-1234567890ab/files", "azure_speech/batch-transcription", 0.0),+ (PREFIXED_SHORT_AUDIO_URL, "azure_speech/short-audio", TRANSCRIPT_AUDIO_SECONDS * PRICE_PER_SECOND),+ (PREFIXED_FAST_URL, "azure_speech/fast-transcription", FAST_AUDIO_SECONDS * PRICE_PER_SECOND),+ (PREFIXED_BATCH_URL, "azure_speech/batch-transcription", 0.0),],)def test_records_model_provider_and_cost(self, url_route: str, expected_model: str, expected_cost: float):