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): move native stt routing opt-out behind the provider config

kerry4e38f1845d8e
diff --git a/litellm/constants.py b/litellm/constants.py
index 55f92f29c96..83dd91c9b7d 100644
--- a/litellm/constants.py
+++ b/litellm/constants.py
@@ -999,11 +999,7 @@ openai_compatible_providers: Final[list] = [
"scx-ai",
]
-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_AUDIO_TRANSCRIPTION_PROVIDERS: Final = frozenset({"openai"} | frozenset(openai_compatible_providers))
openai_text_completion_compatible_providers: Final[list] = [ # providers that support `/v1/completions`
"together_ai",
diff --git a/litellm/llms/base_llm/audio_transcription/transformation.py b/litellm/llms/base_llm/audio_transcription/transformation.py
index b323c4812b5..2296909cfe1 100644
--- a/litellm/llms/base_llm/audio_transcription/transformation.py
+++ b/litellm/llms/base_llm/audio_transcription/transformation.py
@@ -52,6 +52,15 @@ class BaseAudioTranscriptionConfig(BaseConfig, ABC):
"""
return False
+ @property
+ def has_native_transcription_endpoint(self) -> bool:
+ """
+ Opt-in for OpenAI-compatible providers whose transcription lives on a
+ non-OpenAI route: when True the request skips the OpenAI SDK transport
+ and goes through this config via the shared http handler.
+ """
+ return False
+
def get_complete_url(
self,
api_base: str | None,
diff --git a/litellm/llms/xai/audio_transcription/transformation.py b/litellm/llms/xai/audio_transcription/transformation.py
index 7b648fc8084..feeabed0d9c 100644
--- a/litellm/llms/xai/audio_transcription/transformation.py
+++ b/litellm/llms/xai/audio_transcription/transformation.py
@@ -63,6 +63,10 @@ class XAIAudioTranscriptionConfig(BaseAudioTranscriptionConfig):
def custom_llm_provider(self) -> str:
return litellm.LlmProviders.XAI.value
+ @property
+ def has_native_transcription_endpoint(self) -> bool:
+ return True
+
def get_supported_openai_params(
self, model: str
) -> list[OpenAIAudioTranscriptionOptionalParams]: # mutable-ok: base class signature returns list
diff --git a/litellm/main.py b/litellm/main.py
index bd10c3924f7..38184db1d10 100644
--- a/litellm/main.py
+++ b/litellm/main.py
@@ -7831,6 +7831,10 @@ def transcription(
provider=LlmProviders(custom_llm_provider),
)
+ uses_openai_transport: Final = custom_llm_provider in OPENAI_AUDIO_TRANSCRIPTION_PROVIDERS and not (
+ provider_config is not None and provider_config.has_native_transcription_endpoint
+ )
+
if custom_llm_provider in AZURE_OPENAI_AUDIO_PROVIDERS and provider_config is None:
# azure configs
api_base = api_base or litellm.api_base or get_secret_str("AZURE_API_BASE")
@@ -7860,7 +7864,7 @@ def transcription(
litellm_params=litellm_params_dict,
custom_llm_provider=custom_llm_provider,
)
- elif custom_llm_provider in OPENAI_AUDIO_TRANSCRIPTION_PROVIDERS:
+ elif uses_openai_transport:
api_base = (
api_base
or litellm.api_base