Skip to content

feat(mistral): add text-to-speech support for /v1/audio/speech - #38755

Merged
mateo-berri merged 14 commits into
litellm_internal_stagingfrom
litellm_mistral_voxtral_tts_speech
Sep 7, 2026
Merged

mateo-berri merged 14 commits into
litellm_internal_stagingfrom
litellm_mistral_voxtral_tts_speech

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Mistral Voxtral TTS models fail on /v1/audio/speech with a 500
  • Proxy log shows "Unable to map the custom llm provider=mistral"
  • Transcription through mistral works, so users expect speech to work too

How it solves it:

  • Adds a mistral text-to-speech config targeting POST /v1/audio/speech at api.mistral.ai
  • Maps OpenAI voice to Mistral voice_id, drops speed/instructions (Mistral 422s on them)
  • Translates OpenAI voice names (alloy, nova, ...) to real Mistral voices
  • Decodes Mistral's base64 JSON audio into the binary audio bytes clients expect
  • Fixes the Voxtral TTS cost map key so speech calls bill per input character
  • Makes voice optional on router.aspeech so ref_audio voice cloning works, and leaves a deployment's configured voice alone when the caller omits one

User Flow

Before: a developer who routes Mistral through LiteLLM gets a 500 on every text-to-speech call, while transcription with the same key works

  1. They add mistral/voxtral-mini-tts-2603 to their proxy's model list and start the proxy
  2. They send POST https://litellm-domain/v1/audio/speech with {"model": "voxtral-mini-tts-2603", "input": "hello", "voice": "en_paul_neutral"}
  3. The call comes back 500 {"error": {"message": "Internal server error", "type": "internal_server_error"}}, and the proxy log shows "Unable to map the custom llm provider=mistral to a known provider"
  4. The same key transcribes fine: POST https://litellm-domain/v1/audio/transcriptions with voxtral-mini-2602 returns 200 with the spoken text

After: the same speech call returns playable audio with real spend attached

  1. They add mistral/voxtral-mini-tts-2603 to their proxy's model list and start the proxy
  2. They send POST https://litellm-domain/v1/audio/speech with {"model": "voxtral-mini-tts-2603", "input": "hello", "voice": "en_paul_neutral"}
  3. The call comes back 200 with playable MP3 bytes and a non-zero x-litellm-response-cost header; sending "response_format": "wav" returns WAV instead
  4. Sending "voice": "alloy" (the OpenAI default many clients hardcode) also returns audio instead of a Mistral 400 about an unknown voice
  5. If they put a voice on the deployment itself, leaving voice out of the request uses that configured voice rather than failing
  6. Transcription keeps working exactly as before

Relevant issues

Linear ticket

Resolves LIT-6367

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

QA run at the PR tip 93fa989238 (with litellm_internal_staging merged in at df3b8a699d) against that merge base df3b8a699d. Both legs ran the same way: own worktree and .venv (make bootstrap), 2 uvicorn workers, own Postgres container, real Mistral and OpenAI keys, the same config and the same 16 steps in the same order. Env vars: OPENAI_API_KEY, MISTRAL_API_KEY, LITELLM_MASTER_KEY=sk-lit6367drive, LITELLM_LOCAL_MODEL_COST_MAP=True, DATABASE_URL. Boot, with the worktree's .venv/bin prepended to PATH so the prisma migrations run:

.venv/bin/python litellm/proxy/proxy_cli.py --config config.yaml --port <port> --num_workers 2 --detailed_debug
model_list:
  - model_name: voxtral-mini-tts-2603
    litellm_params:
      model: mistral/voxtral-mini-tts-2603
  - model_name: voxtral-mini-tts-latest
    litellm_params:
      model: mistral/voxtral-mini-tts-latest
  - model_name: voxtral-mini-2602
    litellm_params:
      model: mistral/voxtral-mini-2602
  - model_name: tts-1
    litellm_params:
      model: openai/tts-1
  - model_name: voxtral-tts-default-voice
    litellm_params:
      model: mistral/voxtral-mini-tts-2603
      voice: en_paul_neutral
  - model_name: voxtral-tts-hostbase
    litellm_params:
      model: mistral/voxtral-mini-tts-2603
      api_base: https://api.mistral.ai
  - model_name: voxtral-tts-badkey
    litellm_params:
      model: mistral/voxtral-mini-tts-2603
      api_key: not-a-real-mistral-key
  - model_name: voxtral-tts-health
    litellm_params:
      model: mistral/voxtral-mini-tts-2603
    model_info:
      mode: audio_speech

Every step below uses H='Authorization: Bearer sk-lit6367drive' and J='Content-Type: application/json', $S is the leg's scratch dir, and every speech input is hello there (11 characters, 10 without the space). Each speech step is the same curl shape, followed by the response headers and file on the saved body:

curl -sS --max-time 90 -D $S/stepN.headers -o $S/stepN.out -w '%{http_code}\n' -X POST http://localhost:<port>/v1/audio/speech -H "$H" -H "$J" -d '<body>'
grep -i -E '^(HTTP|content-type|x-litellm-response-cost|x-litellm-model-id)' $S/stepN.headers
file $S/stepN.out

Before (df3b8a6, the merge base, port 41842)

Steps 1 to 5, 12 and 13, every Mistral speech call with a voice:

-d '{"model":"voxtral-mini-tts-2603","input":"hello there","voice":"en_paul_neutral"}'                        # step 1
-d '{"model":"voxtral-mini-tts-2603","input":"hello there","voice":"en_paul_neutral","response_format":"mp3"}' # step 2
-d '{"model":"voxtral-mini-tts-latest","input":"hello there","voice":"en_paul_neutral","response_format":"wav"}' # step 3
-d '{"model":"voxtral-mini-tts-2603","input":"hello there","voice":"alloy"}'                                  # step 4
-d '{"model":"voxtral-tts-hostbase","input":"hello there","voice":"en_paul_neutral"}'                         # step 5
-d '{"model":"voxtral-tts-badkey","input":"hello there","voice":"en_paul_neutral"}'                           # step 12
-d '{"model":"voxtral-mini-tts-2603","input":"hello there","voice":"totally_not_a_voice_id"}'                 # step 13

All seven came back the same way (6289 to 6294 bytes, only the Model Group differs), no cost or model-id header:

500
HTTP/1.1 500 Internal Server Error
content-type: application/json
{"error":{"message":"litellm.APIConnectionError: APIConnectionError: MistralException - Unable to map the custom llm provider=mistral to a known provider=[<LlmProviders.MISTRAL: 'openai'>, <LlmProviders.CHATGPT: 'chatgpt'>, <LlmProviders.MISTRAL_LIKE: 'openai_like'>, <LlmProviders.JINA_AI: 'jina_ai'>, <LlmProviders.XAI: 'xai'>, <LlmProviders.ZAI: 'zai'>, <LlmProviders.CUSTOM_MISTRAL: 'custom_openai'>, <LlmProviders.TEXT_COMPLETION_MISTRAL: 'text-completion-openai'>, <LlmProviders.COHERE: 'cohere'>, <LlmProviders.COHERE_CHAT: 'cohere_chat'>, <LlmProviders.CLARIFAI: 'clarifai'>, <LlmProviders.AN
[... trimmed, 6292 bytes total; body ends with: gdc'>].. Received Model Group=voxtral-mini-tts-2603\nAvailable Model Group Fallbacks=None","type":null,"param":null,"code":"500"}}]

Step 6a, reference audio from the OpenAI control model:

-d '{"model":"tts-1","input":"hello there","voice":"alloy","response_format":"wav"}'
200
HTTP/1.1 200 OK
x-litellm-model-id: c2cb74129a4207b4a83d0508501a7ece9d5b8f6c25aaa08dc6e573716f1bd5a4
x-litellm-response-cost: 0.00015000000000000001
content-type: audio/wav
bytes written: 31244
step6a.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 24000 Hz

Steps 6b (voice cloning: ref_audio = standard base64 of ref.wav, no voice), 7 (deployment default voice, no voice in the request), 8 (no voice, no ref_audio) and 10 (OpenAI tts-1, no voice):

-d @$S/refaudio_body.json                                            # step 6b: {"model":"voxtral-mini-tts-2603","input":"hello there","ref_audio":"<base64, 41660 chars>"}
-d '{"model":"voxtral-tts-default-voice","input":"hello there"}'   # step 7
-d '{"model":"voxtral-mini-tts-2603","input":"hello there"}'       # step 8
-d '{"model":"tts-1","input":"hello there"}'                       # step 10

All four:

500
HTTP/1.1 500 Internal Server Error
content-type: application/json
bytes written: 130
{"error":{"message":"Router.aspeech() missing 1 required positional argument: 'voice'","type":"None","param":"None","code":"500"}}

Step 9, OpenAI control:

-d '{"model":"tts-1","input":"hello there","voice":"alloy"}'
200
HTTP/1.1 200 OK
x-litellm-model-id: c2cb74129a4207b4a83d0508501a7ece9d5b8f6c25aaa08dc6e573716f1bd5a4
x-litellm-response-cost: 0.00015000000000000001
content-type: audio/mpeg
bytes written: 11520
step9.mp3: MPEG ADTS, layer III, v2, 128 kbps, 24 kHz, Monaural

Step 11, transcription control with the same key:

curl -sS --max-time 90 -D $S/step11.headers -o $S/step11.out -w '%{http_code}\n' -X POST http://localhost:41842/v1/audio/transcriptions -H "$H" -F model=voxtral-mini-2602 -F file=@$S/ref.wav
200
HTTP/1.1 200 OK
content-type: application/json
x-litellm-model-id: ebcad605643229e296e1f817b46f9bf4abdcf547a091afb9555aaee281b91009
x-litellm-response-cost: 3.2500000000000004e-05
{"text":"Hello there.","usage":null,"segments":[],"language":null}

After (93fa989, the PR tip, port 25589)

Step 1, default format:

-d '{"model":"voxtral-mini-tts-2603","input":"hello there","voice":"en_paul_neutral"}'
200
HTTP/1.1 200 OK
x-litellm-model-id: 50398717a0cc6e0032162e17b41f658bc954f7714eac0e431b71ff454c15c53f
x-litellm-response-cost: 0.00015999999999999999
content-type: audio/mpeg
bytes written: 5979 (saved as $S/step1.mp3)
step1.mp3: Audio file with ID3 version 2.4.0, contains:
- MPEG ADTS, layer III, v2,  96 kbps, 22.05 kHz, Monaural

Step 2, response_format: mp3:

-d '{"model":"voxtral-mini-tts-2603","input":"hello there","voice":"en_paul_neutral","response_format":"mp3"}'
200
HTTP/1.1 200 OK
x-litellm-model-id: 50398717a0cc6e0032162e17b41f658bc954f7714eac0e431b71ff454c15c53f
x-litellm-response-cost: 0.00015999999999999999
content-type: audio/mpeg
bytes written: 4834 (saved as $S/step2.mp3)
step2.mp3: Audio file with ID3 version 2.4.0, contains:
- MPEG ADTS, layer III, v2,  96 kbps, 22.05 kHz, Monaural

Step 3, voxtral-mini-tts-latest as wav:

-d '{"model":"voxtral-mini-tts-latest","input":"hello there","voice":"en_paul_neutral","response_format":"wav"}'
200
HTTP/1.1 200 OK
x-litellm-model-id: f28534750d8f50622a6a5db362c64d77bf85363f94e0ff13dcfda35117b660bf
x-litellm-response-cost: 0.00015999999999999999
content-type: audio/wav
bytes written: 30764 (saved as $S/step3.wav)
step3.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 24000 Hz

Step 4, the OpenAI voice name alloy on the Mistral model:

-d '{"model":"voxtral-mini-tts-2603","input":"hello there","voice":"alloy"}'
200
HTTP/1.1 200 OK
x-litellm-model-id: 50398717a0cc6e0032162e17b41f658bc954f7714eac0e431b71ff454c15c53f
x-litellm-response-cost: 0.00015999999999999999
content-type: audio/mpeg
bytes written: 7121 (saved as $S/step4.mp3)
step4.mp3: Audio file with ID3 version 2.4.0, contains:
- MPEG ADTS, layer III, v2,  80 kbps, 22.05 kHz, Monaural

Step 5, deployment with api_base: https://api.mistral.ai (no /v1):

-d '{"model":"voxtral-tts-hostbase","input":"hello there","voice":"en_paul_neutral"}'
200
HTTP/1.1 200 OK
x-litellm-model-id: c017f1a0f4575e823960a7c0289a99ebe42588d09ca153143c8dc6a9e7c32167
x-litellm-response-cost: 0.00015999999999999999
content-type: audio/mpeg
bytes written: 5093 (saved as $S/step5.mp3)
step5.mp3: Audio file with ID3 version 2.4.0, contains:
- MPEG ADTS, layer III, v2,  96 kbps, 22.05 kHz, Monaural

Step 6a, reference audio from the OpenAI control model:

-d '{"model":"tts-1","input":"hello there","voice":"alloy","response_format":"wav"}'
200
HTTP/1.1 200 OK
x-litellm-model-id: c2cb74129a4207b4a83d0508501a7ece9d5b8f6c25aaa08dc6e573716f1bd5a4
x-litellm-response-cost: 0.00015000000000000001
content-type: audio/wav
bytes written: 27644 (saved as $S/step6a.wav)
step6a.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 24000 Hz

Step 6b, voice cloning with ref_audio (standard base64 of ref.wav, 36860 chars, no newlines) and no voice:

-d @$S/refaudio_body.json   # {"model":"voxtral-mini-tts-2603","input":"hello there","ref_audio":"<base64>"}
200
HTTP/1.1 200 OK
x-litellm-model-id: 50398717a0cc6e0032162e17b41f658bc954f7714eac0e431b71ff454c15c53f
x-litellm-response-cost: 0.00015999999999999999
content-type: audio/mpeg
bytes written: 4703 (saved as $S/step6b.mp3)
step6b.mp3: Audio file with ID3 version 2.4.0, contains:
- MPEG ADTS, layer III, v2,  80 kbps, 22.05 kHz, Monaural

Step 7, deployment default voice, no voice in the request:

-d '{"model":"voxtral-tts-default-voice","input":"hello there"}'
200
HTTP/1.1 200 OK
x-litellm-model-id: 4974039b705ae04ada93d23459752825b588fa013d1b6b8be8707ec7bb8f889c
x-litellm-response-cost: 0.00015999999999999999
content-type: audio/mpeg
bytes written: 5014 (saved as $S/step7.mp3)
step7.mp3: Audio file with ID3 version 2.4.0, contains:
- MPEG ADTS, layer III, v2, 112 kbps, 22.05 kHz, Monaural

Step 8, no voice and no ref_audio (Mistral's own 400 now comes through as a 400):

-d '{"model":"voxtral-mini-tts-2603","input":"hello there"}'
400
HTTP/1.1 400 Bad Request
content-type: application/json
(no x-litellm-response-cost header)
bytes written: 358
{"error":{"message":"litellm.BadRequestError: MistralException - {\"object\":\"error\",\"message\":\"Either ref_audio or voice must be provided.\",\"type\":\"invalid_request_error\",\"param\":null,\"code\":null,\"raw_status_code\":400}. Received Model Group=voxtral-mini-tts-2603\nAvailable Model Group Fallbacks=None","type":null,"param":null,"code":"400"}}

Step 9, OpenAI control:

-d '{"model":"tts-1","input":"hello there","voice":"alloy"}'
200
HTTP/1.1 200 OK
x-litellm-model-id: c2cb74129a4207b4a83d0508501a7ece9d5b8f6c25aaa08dc6e573716f1bd5a4
x-litellm-response-cost: 0.00015000000000000001
content-type: audio/mpeg
bytes written: 10752 (saved as $S/step9.mp3)
step9.mp3: MPEG ADTS, layer III, v2, 128 kbps, 24 kHz, Monaural

Step 10, OpenAI with no voice (the OpenAI branch's own 400 instead of the Router TypeError):

-d '{"model":"tts-1","input":"hello there"}'
400
HTTP/1.1 400 Bad Request
content-type: application/json
(no x-litellm-response-cost header)
bytes written: 212
{"error":{"message":"litellm.BadRequestError: 'voice' is required to be passed as a string for OpenAI TTS. Received Model Group=tts-1\nAvailable Model Group Fallbacks=None","type":null,"param":null,"code":"400"}}

Step 11, transcription control, unchanged:

curl -sS --max-time 90 -D $S/step11.headers -o $S/step11.out -w '%{http_code}\n' -X POST http://localhost:25589/v1/audio/transcriptions -H "$H" -F model=voxtral-mini-2602 -F file=@$S/ref.wav
200
HTTP/1.1 200 OK
content-type: application/json
x-litellm-model-id: ebcad605643229e296e1f817b46f9bf4abdcf547a091afb9555aaee281b91009
x-litellm-response-cost: 2.8749999999999997e-05
bytes written: 66
{"text":"Hello there.","usage":null,"segments":[],"language":null}

Step 12, upstream error with a bad key:

-d '{"model":"voxtral-tts-badkey","input":"hello there","voice":"en_paul_neutral"}'
401
HTTP/1.1 401 Unauthorized
content-type: application/json
(no x-litellm-response-cost header)
bytes written: 244
{"error":{"message":"litellm.AuthenticationError: AuthenticationError: MistralException - {\"detail\":\"Invalid API Key\"}\n. Received Model Group=voxtral-tts-badkey\nAvailable Model Group Fallbacks=None","type":null,"param":null,"code":"401"}}

Step 13, upstream error with an unknown voice:

-d '{"model":"voxtral-mini-tts-2603","input":"hello there","voice":"totally_not_a_voice_id"}'
404
HTTP/1.1 404 Not Found
content-type: application/json
(no x-litellm-response-cost header)
bytes written: 365
{"error":{"message":"litellm.NotFoundError: NotFoundError: MistralException - {\"object\":\"error\",\"message\":\"Voice 'totally_not_a_voice_id' not found.\",\"type\":\"invalid_voice\",\"param\":null,\"code\":\"1902\",\"raw_status_code\":404}. Received Model Group=voxtral-mini-tts-2603\nAvailable Model Group Fallbacks=None","type":null,"param":null,"code":"404"}}

Spend attribution (step 14, both legs, 20 seconds after step 13)

curl -sS 'http://localhost:<port>/spend/logs' -H "$H" | jq -c '.[] | {model, call_type, spend, status}'

Before (4 rows: the transcription, the two OpenAI calls, and a single failure row for all eleven failed speech calls):

{"model":"mistral/voxtral-mini-2602","call_type":"atranscription","spend":0.0000325,"status":"success"}
{"model":"openai/tts-1","call_type":"aspeech","spend":0.00015,"status":"success"}
{"model":"openai/tts-1","call_type":"aspeech","spend":0.00015,"status":"success"}
{"model":"mistral/voxtral-mini-tts-2603","call_type":"","spend":0.0,"status":"failure"}

After (11 rows, newest first: steps 11, 9, 8, 7, 6b, 6a, 5, 4, 3, 2, 1; every successful Mistral speech call carries 0.00016 spend):

{"model":"mistral/voxtral-mini-2602","call_type":"atranscription","spend":0.00002875,"status":"success"}
{"model":"openai/tts-1","call_type":"aspeech","spend":0.00015,"status":"success"}
{"model":"mistral/voxtral-mini-tts-2603","call_type":"","spend":0.0,"status":"failure"}
{"model":"mistral/voxtral-mini-tts-2603","call_type":"aspeech","spend":0.00016,"status":"success"}
{"model":"mistral/voxtral-mini-tts-2603","call_type":"aspeech","spend":0.00016,"status":"success"}
{"model":"openai/tts-1","call_type":"aspeech","spend":0.00015,"status":"success"}
{"model":"mistral/voxtral-mini-tts-2603","call_type":"aspeech","spend":0.00016,"status":"success"}
{"model":"mistral/voxtral-mini-tts-2603","call_type":"aspeech","spend":0.00016,"status":"success"}
{"model":"mistral/voxtral-mini-tts-latest","call_type":"aspeech","spend":0.00016,"status":"success"}
{"model":"mistral/voxtral-mini-tts-2603","call_type":"aspeech","spend":0.00016,"status":"success"}
{"model":"mistral/voxtral-mini-tts-2603","call_type":"aspeech","spend":0.00016,"status":"success"}

Health check (step 15, both legs)

Present in the config from the first boot of each leg (so step 15 ran against the same 2 workers as every other step, no restart):

  - model_name: voxtral-tts-health
    litellm_params:
      model: mistral/voxtral-mini-tts-2603
    model_info:
      mode: audio_speech
curl -sS --max-time 90 -w '%{http_code}\n' 'http://localhost:<port>/health?model=voxtral-tts-health' -H "$H"

Before:

503
{"healthy_endpoints":[],"unhealthy_endpoints":[{"model":"mistral/voxtral-mini-tts-2603","voice":"alloy","error":"litellm.APIConnectionError: APIConnectionError: MistralException - Unable to map the custom llm provider=mistral to a known provider=[<LlmProviders.MISTRAL: 'openai'>, <LlmProviders.CHATGPT: 'chatgpt'[... trimmed, same mapping error as steps 1 to 5]"}],"healthy_count":0,"unhealthy_count":1}

After:

200
{"healthy_endpoints":[{"allow_client_keepalive_override":false,"use_in_pass_through":false,"use_litellm_proxy":false,"use_xai_oauth":false,"merge_reasoning_content_in_choices":false,"model":"mistral/voxtral-mini-tts-2603","voice":"alloy","cache":{"no-cache":true},"model_id":"13f626d19c94ec72641e86fd07cac56ada24a0e933532558288cf4bac795c8d5"}],"unhealthy_endpoints":[],"healthy_count":1,"unhealthy_count":0}

Model info (step 16, both legs)

curl -sS 'http://localhost:<port>/model/info' -H "$H" | jq -c '.data[] | select(.model_name=="voxtral-mini-tts-2603") | {model_name, litellm_model: .litellm_params.model, mode: .model_info.mode, input_cost_per_character: .model_info.input_cost_per_character, output_cost_per_character: .model_info.output_cost_per_character}'
before: {"model_name":"voxtral-mini-tts-2603","litellm_model":"mistral/voxtral-mini-tts-2603","mode":"audio_speech","input_cost_per_character":null,"output_cost_per_character":0.000016}
after:  {"model_name":"voxtral-mini-tts-2603","litellm_model":"mistral/voxtral-mini-tts-2603","mode":"audio_speech","input_cost_per_character":0.000016,"output_cost_per_character":null}

Blast radius (live-pr-risk at 93fa989)

Breaking: none observed. Every path that worked at the merge base (OpenAI speech, transcription, spend rows, health, model info) answers the same way at the tip

Backward incompatible: Router.aspeech / Router._aspeech take voice: str | None = None instead of a required str (a loosening; a request-level voice still wins, and when the request passes none the deployment's configured voice is forwarded instead of None, so a deployment default survives), and the two mistral/voxtral-mini-tts-* cost-map entries move their price from output_cost_per_character to input_cost_per_character (the speech cost path bills characters of input with custom_completion_cost=0, so the old key was never applied to a speech call; /model/info now reports it under the new key, and no dashboard code reads either key)

Dependency graph: proxy POST /v1/audio/speech -> Router.aspeech -> litellm.aspeech -> speech() mistral branch (tested by the PR's router and main tests, verified live in steps 1 to 8, 10); the health check helper's direct litellm.aspeech call in audio_speech mode (untested for mistral, verified live in step 15); the cost path cost_calculator -> _generic_cost_per_character (tested by test_cost_calculator, verified live through the cost header and /spend/logs); the get_model_info / /model/info wire contract (verified live in step 16); the other TTS branches in speech() (untouched, OpenAI verified live in steps 6a, 9, 10); ProviderConfigManager.get_provider_text_to_speech_config (single caller, tested); no subclass overrides Router.aspeech; the legacy tests/llm_translation and tests/local_testing suites pin nothing this PR changes, and CircleCI ran them at the tip

Not verified: none

Observations

  • Billing counts 10 of the 11 input characters; pre-existing, every TTS provider
  • No spend rows for the 4xx steps 10, 12, 13; pre-existing
  • Step 8 failure row has empty call_type; pre-existing shape
  • No cost or model-id header on any 4xx; pre-existing
  • Transcription cost differs between legs only by ref.wav length; unrelated
  • Health check probes with voice alloy; the alias makes it pass
  • Before-only: Router retried the mapping error twice per call
  • Before-only: error text renames OpenAI enum members to MISTRAL

Type

🆕 New Feature

Caveats (if any)

Low

  • speed and instructions are dropped silently instead of raising. Net negative to fix: every shipped TTS config (OpenAI-compatible, Azure, Vertex, ElevenLabs, MiniMax, Polly, Runway) maps or drops unsupported params the same way and none raises UnsupportedParamsError, speech() hardcodes drop_params=False for every provider, and raising here would make Mistral the one provider that errors on a default speed many OpenAI clients always send; honoring drop_params for TTS is a shared-layer change for a separate PR
  • Streaming (with_streaming_response) is not wired for Mistral: the response is fully buffered before it is returned. Mistral's endpoint returns one JSON document with base64 audio, so there is nothing to stream through yet
  • nova and shimmer both alias to gb_jane_sarcasm because Mistral ships two English female voices and both were taken by the closer matches; pass a Mistral voice_id directly for a specific voice
  • Only mp3 and wav went through the proxy legs above; the other three formats were verified directly against https://api.mistral.ai/v1/audio/speech with the same key and payload shape (flac -> FLAC 24 bit mono 24 kHz, pcm -> raw data, opus -> Ogg Opus mono 24 kHz, all 200, and aac -> 422 naming exactly pcm, wav, mp3, flac, opus as the accepted values)
  • Billing counts characters with whitespace stripped (10 of 11 for hello there); that is _count_characters behavior shared by every TTS provider, not this PR's
  • MISTRAL_API_BASE is not read by this path; api_base in litellm_params (or on the call) and MISTRAL_AZURE_API_BASE are, matching what MistralConfig reads for chat
  • Any string voice that is not one of the six OpenAI aliases is forwarded to Mistral as voice_id unchanged, the same way ElevenLabs forwards voice ids; Mistral answers 404 invalid_voice for an unknown one (step 13)
  • The transcription control returns usage: null and segments: [] on both legs; pre-existing and untouched here
  • No docs page yet for Mistral TTS on /v1/audio/speech: LIT-7001 tracks the docs follow-up in the docs repo

Final Attestation

  • I reviewed the code changes and the PR description one final time before submitting

Reviewed at 93fa989238 (the tip, litellm_internal_staging merged in at df3b8a699d). All 33 required checks on the base branch's ruleset are green at that commit, including proxy-infra / Run tests (Python 3.10), which went green once #39780 landed on staging (LIT-6947). One non-required job is red and it fails identically on litellm_internal_staging without this branch: the run-ci CircleCI pipeline 89157 at the tip (workflow ec1f947d, 43 jobs, 42 green) has only proxy_store_model_in_db_tests red on test_chat_completion_bad_model_with_spend_logs (assert '' == 'non-existent-model'), the same failure staging pipelines 89097 and 89104 show (LIT-6949); no CircleCI job is required and this branch touches neither that test nor failure spend logging. Greptile 5/5 and bugbot "no new issues" both at 93fa989238, every review thread resolved


Note

Low Risk
Additive provider path with tests; the only behavioral broadening is optional Router.aspeech voice and a cost-map key rename for two Mistral TTS models.

Overview
Adds Mistral Voxtral TTS so litellm.speech / proxy /v1/audio/speech can call Mistral’s POST /v1/audio/speech instead of failing with an unmapped provider error.

The new MistralTextToSpeechConfig builds the JSON request (voice_id, optional response_format and ref_audio), maps OpenAI-style voices (including aliases like alloy) to Mistral IDs, strips unsupported params such as speed/instructions, and turns Mistral’s JSON audio_data into binary audio with the right content-type.

Router aspeech now accepts an optional voice: when omitted, the deployment’s configured voice is used (needed for ref_audio cloning without a voice argument).

Pricing for mistral/voxtral-mini-tts-* moves from output_cost_per_character to input_cost_per_character so speech calls bill on input text length.

Reviewed by Cursor Bugbot for commit 5825cc7. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds Mistral Voxtral text-to-speech support through the shared speech transport.

  • Translates OpenAI speech parameters and voice aliases into Mistral’s request format.
  • Decodes Mistral’s base64 response into binary audio with the appropriate content type.
  • Supports reference-audio cloning and deployment-level default voices by making router voice input optional.
  • Corrects Voxtral pricing metadata so input characters are billed.
  • Adds focused adapter, router, dispatch, and cost-calculation tests.

Confidence Score: 5/5

The PR appears safe to merge; no new actionable issue remains in the Mistral speech path.

The adapter uses the shared HTTP handler, strictly validates encoded audio, preserves upstream error handling, supports optional and deployment-default voices, and has aligned input-character pricing and focused tests. All previous Greptile threads are resolved, including two findings Greptile explicitly withdrew.

Important Files Changed

Filename Overview
litellm/llms/mistral/audio_speech/transformation.py Implements Mistral TTS request, authentication, URL, voice alias, response decoding, header, and error transformations using the shared transport.
litellm/main.py Dispatches Mistral speech calls through the new provider adapter and shared text-to-speech handler.
litellm/router.py Allows speech calls without an explicit voice while preserving a deployment-configured default.
litellm/utils.py Registers the Mistral text-to-speech adapter with the provider configuration manager.
model_prices_and_context_window.json Moves Voxtral TTS pricing to input-character accounting.
tests/test_litellm/llms/mistral/audio_speech/test_mistral_audio_speech_transformation.py Covers parameter mapping, URL construction, credentials, request generation, binary decoding, voice aliases, and strict base64 validation.

Reviews (12): Last reviewed commit: "chore: merge litellm_internal_staging in..." | Re-trigger Greptile

Comment thread litellm/main.py Resolved
@codecov

codecov Bot commented Aug 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.31818% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...itellm/llms/mistral/audio_speech/transformation.py 94.59% 4 Missing ⚠️
litellm/main.py 88.88% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_mistral_voxtral_tts_speech (5825cc7) with litellm_internal_staging (02522a5)

Open in CodSpeed

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@mateo-berri
mateo-berri requested a review from tin-berri August 29, 2026 18:58
@mateo-berri
mateo-berri enabled auto-merge August 29, 2026 18:58
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 2, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: TTS URL omits required /v1
    • get_complete_url now normalizes the resolved base by appending /v1 when missing (matching the OCR/chat convention) so host-only api_base or MISTRAL_API_BASE values yield /v1/audio/speech.

Create PR

Or push these changes by commenting:

@cursor push 04f9904f69
Preview (04f9904f69)
diff --git a/litellm/llms/mistral/audio_speech/transformation.py b/litellm/llms/mistral/audio_speech/transformation.py
--- a/litellm/llms/mistral/audio_speech/transformation.py
+++ b/litellm/llms/mistral/audio_speech/transformation.py
@@ -115,8 +115,9 @@
         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"
+        base_url: Final = (api_base or get_secret_str("MISTRAL_API_BASE") or self.TTS_BASE_URL).rstrip("/")
+        normalized_base: Final = base_url if base_url.endswith("/v1") else f"{base_url}/v1"
+        return f"{normalized_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
--- 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
@@ -101,6 +101,24 @@
     assert url == "https://custom.api.example.com/v1/audio/speech"
 
 
+def test_get_complete_url_host_only_base_adds_v1(monkeypatch: pytest.MonkeyPatch):
+    monkeypatch.delenv("MISTRAL_API_BASE", raising=False)
+    config: Final = MistralTextToSpeechConfig()
+    url: Final = config.get_complete_url(
+        model="voxtral-mini-tts-2603",
+        api_base="https://custom.api.example.com",
+        litellm_params={},
+    )
+    assert url == "https://custom.api.example.com/v1/audio/speech"
+
+
+def test_get_complete_url_env_base_without_v1_adds_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(

You can send follow-ups to the cloud agent here.

A host-only api_base or MISTRAL_API_BASE (the documented form, https://api.mistral.ai) built
https://api.mistral.ai/audio/speech and 404ed. Match the chat and OCR configs by appending /v1
when the configured base does not already end with it.
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 2, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

…itellm_mistral_voxtral_tts_speech

Resolves the tests/test_litellm/test_main.py collision, where both sides appended a
new test at the end of the file, by keeping both.

Also carries the one-line fix from #39502: staging arrived with a duplicate
embedding_executor kwarg in the Bedrock KB fake handler, which ruff rejects as a
syntax error, so every commit here would otherwise fail lint. The change is byte
identical to #39502, so that PR merges cleanly once it lands.
@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@veria-ai

veria-ai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 3, 2026
@mateo-berri
mateo-berri requested a review from a team September 4, 2026 23:52
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 4, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 5, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 5, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 5825cc7. Configure here.

@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 6, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri
mateo-berri merged commit 1c7b13b into litellm_internal_staging Sep 7, 2026
130 of 133 checks passed
@mateo-berri
mateo-berri deleted the litellm_mistral_voxtral_tts_speech branch September 7, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants