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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_mistral_voxtral_tts_speech
mateo-berri75e7f4c4a50a
diff --cc tests/test_litellm/test_main.pyindex cb7f117f937,3c8bf142835..9b5122c3f75--- a/tests/test_litellm/test_main.py+++ b/tests/test_litellm/test_main.py@@@ -3239,29 -3240,22 +3240,50 @@@ def test_stream_chunk_builder_prices_alassert response._hidden_params["response_cost"] == pytest.approx(0.000704)+ def test_stream_chunk_builder_leaves_xai_reported_cost_to_the_calculator(monkeypatch: pytest.MonkeyPatch):+ monkeypatch.setattr(litellm, "cost_margin_config", {"xai": 0.5})+ usage_chunk: Final = _stream_builder_text_chunk("grok-4", "")+ usage_chunk.usage = Usage(prompt_tokens=5, completion_tokens=2, total_tokens=7, cost=0.42)+ chunks: Final = [+ _stream_builder_text_chunk("grok-4", "Hello "),+ _stream_builder_text_chunk("grok-4", "world.", finish_reason="stop"),+ usage_chunk,+ ]+ logging_obj: Final = _stream_builder_logging_obj(model="grok-4", custom_llm_provider="xai")++ response: Final = litellm.stream_chunk_builder(+ chunks=chunks, messages=[{"role": "user", "content": "hi"}], logging_obj=logging_obj+ )++ assert response is not None+ assert getattr(response.usage, "cost", None) == pytest.approx(0.42)+ assert response._hidden_params.get("response_cost") is None+ assert logging_obj._response_cost_calculator(result=response) == pytest.approx(0.63)+++++def test_speech_mistral_dispatches_and_decodes_audio(respx_mock: respx.MockRouter, monkeypatch: pytest.MonkeyPatch):+ monkeypatch.setenv("MISTRAL_API_KEY", "sk-mistral-test")+ audio_bytes: Final = b"ID3-fake-mp3-bytes"+ mock_route: Final = respx_mock.post("https://api.mistral.ai/v1/audio/speech").mock(+ return_value=httpx.Response(200, json={"audio_data": base64.b64encode(audio_bytes).decode()})+ )++ response: Final = litellm.speech(+ model="mistral/voxtral-mini-tts-2603",+ input="hello from litellm",+ voice="en_paul_neutral",+ response_format="wav",+ speed=2,+ instructions="sound cheerful",+ )++ assert mock_route.called+ request_body: Final = json.loads(mock_route.calls.last.request.content)+ assert request_body == {+ "model": "voxtral-mini-tts-2603",+ "input": "hello from litellm",+ "voice_id": "en_paul_neutral",+ "response_format": "wav",+ }+ assert mock_route.calls.last.request.headers["authorization"] == "Bearer sk-mistral-test"+ assert response.content == audio_bytes