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_fix_azure_ai_reclassify
mateo-berridf24dab7c918
diff --cc tests/test_litellm/test_main.pyindex 30975033b7d,7c2b9d0be05..bcb01864a3f--- a/tests/test_litellm/test_main.py+++ b/tests/test_litellm/test_main.py@@@ -3180,44 -3214,26 +3214,66 @@@ def test_stream_chunk_builder_keeps_pro)assert response is not None- assert response._hidden_params.get("response_cost") is None+ assert getattr(response.usage, "cost", None) == pytest.approx(0.5)+ assert response._hidden_params["response_cost"] == pytest.approx(0.5)+++ def test_stream_chunk_builder_prices_alias_from_openai_sdk_usage_chunk():+ from openai.types.completion_usage import CompletionUsage++ usage_chunk: Final = _stream_builder_text_chunk("mantle-claude", "")+ usage_chunk.usage = CompletionUsage(prompt_tokens=20, completion_tokens=60, total_tokens=80, cost=0.000704)+ assert type(usage_chunk.usage) is CompletionUsage+ chunks: Final = [+ _stream_builder_text_chunk("mantle-claude", "Hello "),+ _stream_builder_text_chunk("mantle-claude", "world.", finish_reason="stop"),+ usage_chunk,+ ]++ response: Final = litellm.stream_chunk_builder(chunks=chunks, messages=[{"role": "user", "content": "hi"}])++ assert response is not None+ assert response.usage.prompt_tokens == 20+ assert response.usage.completion_tokens == 60+ assert getattr(response.usage, "cost", None) == pytest.approx(0.000704)+ assert response._hidden_params["response_cost"] == pytest.approx(0.000704)+++FOUNDRY_HOST: Final = "https://my-project.services.ai.azure.com"+++def test_azure_ai_transcription_on_a_foundry_host_uses_the_azure_openai_deployment_route(+ respx_mock: respx.MockRouter,+):+ route: Final = respx_mock.post(+ url__regex=r"https://my-project\.services\.ai\.azure\.com/openai/deployments/whisper-1/audio/transcriptions\?api-version=.+"+ ).mock(return_value=httpx.Response(200, json={"text": "hello"}))++ response: Final = litellm.transcription(+ model="azure_ai/whisper-1",+ file=("tone.wav", b"RIFF\x00\x00\x00\x00WAVE", "audio/wav"),+ api_base=FOUNDRY_HOST,+ api_key="fake-key",+ )++ assert route.called+ assert response.text == "hello"+++def test_azure_ai_speech_on_a_foundry_host_uses_the_azure_openai_deployment_route(+ respx_mock: respx.MockRouter,+):+ route: Final = respx_mock.post(+ url__regex=r"https://my-project\.services\.ai\.azure\.com/openai/deployments/tts-1/audio/speech\?api-version=.+"+ ).mock(return_value=httpx.Response(200, content=b"mp3-bytes"))++ response: Final = litellm.speech(+ model="azure_ai/tts-1",+ input="hello",+ voice="alloy",+ api_base=FOUNDRY_HOST,+ api_key="fake-key",+ )++ assert route.called+ assert response.content == b"mp3-bytes"