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(mistral): ensure /v1 on the Voxtral TTS base URL

mateo-berri7c91b0120fad
diff --git a/litellm/llms/mistral/audio_speech/transformation.py b/litellm/llms/mistral/audio_speech/transformation.py
index e7f7d510346..7f5a659bd08 100644
--- a/litellm/llms/mistral/audio_speech/transformation.py
+++ b/litellm/llms/mistral/audio_speech/transformation.py
@@ -115,8 +115,9 @@ class MistralTextToSpeechConfig(BaseTextToSpeechConfig):
api_base: str | None,
litellm_params: Mapping[str, object],
) -> str:
- base_url: Final = api_base or get_secret_str("MISTRAL_API_BASE") or self.TTS_BASE_URL
- return f"{base_url.rstrip('/')}/audio/speech"
+ configured_base: Final = (api_base or get_secret_str("MISTRAL_API_BASE") or self.TTS_BASE_URL).rstrip("/")
+ versioned_base: Final = configured_base if configured_base.endswith("/v1") else f"{configured_base}/v1"
+ return f"{versioned_base}/audio/speech"
def transform_text_to_speech_request(
self,
diff --git a/tests/test_litellm/llms/mistral/audio_speech/test_mistral_audio_speech_transformation.py b/tests/test_litellm/llms/mistral/audio_speech/test_mistral_audio_speech_transformation.py
index 6d250901e50..108d4107db1 100644
--- a/tests/test_litellm/llms/mistral/audio_speech/test_mistral_audio_speech_transformation.py
+++ b/tests/test_litellm/llms/mistral/audio_speech/test_mistral_audio_speech_transformation.py
@@ -91,16 +91,23 @@ def test_get_complete_url_default_base(monkeypatch: pytest.MonkeyPatch):
assert url == SPEECH_URL
-def test_get_complete_url_custom_base():
+ "api_base",
+ ["https://custom.api.example.com/v1/", "https://custom.api.example.com/v1", "https://custom.api.example.com"],
+)
+def test_get_complete_url_custom_base_always_versioned(api_base: str):
config: Final = MistralTextToSpeechConfig()
- url: Final = config.get_complete_url(
- model="voxtral-mini-tts-2603",
- api_base="https://custom.api.example.com/v1/",
- litellm_params={},
- )
+ url: Final = config.get_complete_url(model="voxtral-mini-tts-2603", api_base=api_base, litellm_params={})
assert url == "https://custom.api.example.com/v1/audio/speech"
+def test_get_complete_url_host_only_env_base_gets_v1(monkeypatch: pytest.MonkeyPatch):
+ monkeypatch.setenv("MISTRAL_API_BASE", "https://api.mistral.ai")
+ config: Final = MistralTextToSpeechConfig()
+ url: Final = config.get_complete_url(model="voxtral-mini-tts-2603", api_base=None, litellm_params={})
+ assert url == SPEECH_URL
+
+
def test_validate_environment_sets_bearer_header():
config: Final = MistralTextToSpeechConfig()
headers: Final = config.validate_environment(