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_anthropic_fast_mode_cache_and_response_speed
mateo-berriece187ea2478
diff --cc tests/test_litellm/test_cost_calculator.pyindex 29709af37c8,55e3406cb3a..304ce16b0ed--- a/tests/test_litellm/test_cost_calculator.py+++ b/tests/test_litellm/test_cost_calculator.py@@@ -2834,28 -2849,40 +2843,62 @@@ def test_anthropic_geo_and_fast_multiplassert completion_cost == pytest.approx(500 * 25e-6 * 2.0 * 1.1)+ "model,expected_fast",+ [+ ("claude-opus-5", 2.0),+ ("claude-opus-4-8", 2.0),+ ("claude-opus-4-6", None),+ ("claude-opus-4-6-20260205", None),+ ("claude-opus-4-7", None),+ ("claude-opus-4-7-20260416", None),+ ],+)+def test_anthropic_fast_multiplier_only_on_models_with_fast_mode(_local_model_cost_map, model, expected_fast):+ """+ Anthropic serves fast mode on Opus 5 and Opus 4.8 only, at 2x. Opus 4.6 and+ 4.7 accept the ``speed`` request param but are always served standard, so a+ ``fast`` multiplier on their map entries overbills every request that asked+ for fast and was served standard.+ """+ entry = litellm.model_cost[model]+ assert entry["provider_specific_entry"].get("fast") == expected_fast+++ @pytest.mark.parametrize(+ "model",+ ["claude-sonnet-4-6", "claude-mythos-5", "claude-mythos-preview"],+ )+ def test_anthropic_us_data_residency_uplift_on_claude_4_6_and_later_models(+ _local_model_cost_map, monkeypatch, model+ ):+ """+ Anthropic bills every Claude 4.6+ model served with ``inference_geo="us"`` at+ 1.1x, and echoes that geo back in the response usage, so each of these real+ cost-map entries has to carry the ``us`` multiplier or US-pinned traffic is+ under-reported by 10%.+ """+ from litellm.llms.anthropic.cost_calculation import (+ cost_per_token as anthropic_cost_per_token,+ )+ from litellm.types.utils import Usage++ monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True")++ def make_usage() -> "Usage":+ return Usage(prompt_tokens=1_000, completion_tokens=100, total_tokens=1_100)++ base_prompt_cost, base_completion_cost = anthropic_cost_per_token(model=model, usage=make_usage())++ geo_usage = make_usage()+ geo_usage.inference_geo = "us"+ geo_prompt_cost, geo_completion_cost = anthropic_cost_per_token(model=model, usage=geo_usage)++ assert base_prompt_cost > 0+ assert geo_prompt_cost == pytest.approx(base_prompt_cost * 1.1)+ assert geo_completion_cost == pytest.approx(base_completion_cost * 1.1)++def test_gemini_cache_tokens_details_no_negative_values():"""Test for Issue #18750: Negative text_tokens with Gemini caching