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]

refactor(xai): use derived provider set for transcription routing

kerrya124e079c369
diff --git a/litellm/constants.py b/litellm/constants.py
index 56d3f5450d7..55f92f29c96 100644
--- a/litellm/constants.py
+++ b/litellm/constants.py
@@ -1001,6 +1001,10 @@ openai_compatible_providers: Final[list] = [
OPENAI_COMPATIBLE_PROVIDERS_WITH_NATIVE_AUDIO_TRANSCRIPTION: Final = frozenset({"xai"})
+OPENAI_AUDIO_TRANSCRIPTION_PROVIDERS: Final = frozenset(
+ {"openai"} | (frozenset(openai_compatible_providers) - OPENAI_COMPATIBLE_PROVIDERS_WITH_NATIVE_AUDIO_TRANSCRIPTION)
+)
+
openai_text_completion_compatible_providers: Final[list] = [ # providers that support `/v1/completions`
"together_ai",
"fireworks_ai",
diff --git a/litellm/main.py b/litellm/main.py
index 1c3de8e766b..bd10c3924f7 100644
--- a/litellm/main.py
+++ b/litellm/main.py
@@ -64,7 +64,7 @@ from litellm.constants import (
AZURE_OPENAI_AUDIO_PROVIDERS,
DEFAULT_MOCK_RESPONSE_COMPLETION_TOKEN_COUNT,
DEFAULT_MOCK_RESPONSE_PROMPT_TOKEN_COUNT,
- OPENAI_COMPATIBLE_PROVIDERS_WITH_NATIVE_AUDIO_TRANSCRIPTION,
+ OPENAI_AUDIO_TRANSCRIPTION_PROVIDERS,
)
from litellm.exceptions import LiteLLMUnknownProvider
from litellm.integrations.custom_logger import CustomLogger
@@ -7860,10 +7860,7 @@ def transcription(
litellm_params=litellm_params_dict,
custom_llm_provider=custom_llm_provider,
)
- elif custom_llm_provider == "openai" or (
- custom_llm_provider in litellm.openai_compatible_providers
- and custom_llm_provider not in OPENAI_COMPATIBLE_PROVIDERS_WITH_NATIVE_AUDIO_TRANSCRIPTION
- ):
+ elif custom_llm_provider in OPENAI_AUDIO_TRANSCRIPTION_PROVIDERS:
api_base = (
api_base
or litellm.api_base
diff --git a/litellm/utils.py b/litellm/utils.py
index 97c074ce112..e30e8cde86d 100644
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@ -8731,9 +8731,7 @@ class ProviderConfigManager:
return ElevenLabsAudioTranscriptionConfig()
elif litellm.LlmProviders.XAI == provider:
- from litellm.llms.xai.audio_transcription.transformation import (
- XAIAudioTranscriptionConfig,
- )
+ from litellm.llms.xai.audio_transcription.transformation import XAIAudioTranscriptionConfig
return XAIAudioTranscriptionConfig()
elif litellm.LlmProviders.OPENAI == provider: