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 type errors on transcription azure

Ishaan Jaff7384d45ef089
diff --git a/litellm/main.py b/litellm/main.py
index 85aa0e96a96..e75c23f0fc1 100644
--- a/litellm/main.py
+++ b/litellm/main.py
@@ -4951,6 +4951,10 @@ async def atranscription(*args, **kwargs) -> TranscriptionResponse:
else:
# Call the synchronous function using run_in_executor
response = await loop.run_in_executor(None, func_with_context)
+ if not isinstance(response, TranscriptionResponse):
+ raise ValueError(
+ f"Invalid response from transcription provider, expected TranscriptionResponse, but got {type(response)}"
+ )
return response
except Exception as e:
custom_llm_provider = custom_llm_provider or "openai"
@@ -4984,7 +4988,7 @@ def transcription(
max_retries: Optional[int] = None,
custom_llm_provider=None,
**kwargs,
-) -> TranscriptionResponse:
+) -> Union[TranscriptionResponse, Coroutine[Any, Any, TranscriptionResponse]]:
"""
Calls openai + azure whisper endpoints.
@@ -5053,7 +5057,9 @@ def transcription(
custom_llm_provider=custom_llm_provider,
)
- response: Optional[TranscriptionResponse] = None
+ response: Optional[
+ Union[TranscriptionResponse, Coroutine[Any, Any, TranscriptionResponse]]
+ ] = None
if custom_llm_provider == "azure":
# azure configs
api_base = api_base or litellm.api_base or get_secret_str("AZURE_API_BASE")