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
fix(router): honor tiered_pricing set in a deployment's litellm_params
mateo-berric9685b2a6d4b
diff --git a/litellm/types/utils.py b/litellm/types/utils.pyindex 354857f8d72..34be2afbdd7 100644--- a/litellm/types/utils.py+++ b/litellm/types/utils.py@@ -3260,6 +3260,7 @@ class MirroredPricingParams(BaseModel):output_cost_per_character: float | None = Nonecache_read_input_token_cost: float | None = Nonecache_creation_input_token_cost: float | None = None+ tiered_pricing: list[dict[str, Any]] | None = Noneclass CustomPricingLiteLLMParams(MirroredPricingParams):@@ -3327,7 +3328,6 @@ class CustomPricingLiteLLMParams(MirroredPricingParams):output_cost_per_audio_per_second: float | None = Nonesearch_context_cost_per_query: dict[str, Any] | None = Nonecitation_cost_per_token: float | None = None- tiered_pricing: list[dict[str, Any]] | None = Nonecache_read_input_token_cost_above_272k_tokens: float | None = Nonecache_read_input_token_cost_above_512k_tokens: float | None = Noneinput_cost_per_image_token: float | None = Nonediff --git a/tests/test_litellm/types/test_router.py b/tests/test_litellm/types/test_router.pyindex 1b66863a82f..5ce5eca4954 100644--- a/tests/test_litellm/types/test_router.py+++ b/tests/test_litellm/types/test_router.py@@ -46,12 +46,30 @@ def test_custom_pricing_params_keeps_every_field_it_had():@pytest.mark.parametrize("field", SPECIAL_MODEL_INFO_PARAMS)def test_deployment_mirrors_pricing_from_litellm_params_onto_model_info(field):+ value = [{"range": [0, 128000], "input_cost_per_token": 3e-06}] if field == "tiered_pricing" else 3e-06deployment = Deployment(model_name="my-model",- litellm_params=LiteLLM_Params(model="gpt-4o", **{field: 3e-06}),+ litellm_params=LiteLLM_Params(model="gpt-4o", **{field: value}),)- assert getattr(deployment.model_info, field) == 3e-06- assert deployment.model_info.model_dump(exclude_none=True)[field] == 3e-06+ assert getattr(deployment.model_info, field) == value+ assert deployment.model_info.model_dump(exclude_none=True)[field] == value+++def test_deployment_mirrors_tiered_pricing_onto_model_info():+ """+ Regression: tiered_pricing set under a deployment's litellm_params was silently+ ignored at cost time because the Deployment mirror excluded it, so the logging+ path never flagged the deployment as custom-priced.+ """+ tiers = [+ {"range": [0, 3000], "input_cost_per_token": 3.25e-07, "output_cost_per_token": 1.95e-06},+ {"range": [3000, 128000], "input_cost_per_token": 6.5e-07, "output_cost_per_token": 3.9e-06},+ ]+ deployment = Deployment(+ model_name="my-model",+ litellm_params=LiteLLM_Params(model="anthropic/claude-haiku-4-5", tiered_pricing=tiers),+ )+ assert deployment.model_info.tiered_pricing == tiersdef test_unset_pricing_is_still_absent_from_dumps():diff --git a/ui/litellm-dashboard/src/lib/http/schema.d.ts b/ui/litellm-dashboard/src/lib/http/schema.d.tsindex 1e46ae9c577..443401eca5d 100644--- a/ui/litellm-dashboard/src/lib/http/schema.d.ts+++ b/ui/litellm-dashboard/src/lib/http/schema.d.ts@@ -35483,6 +35483,10 @@ export interface components {team_public_model_name?: string | null;/** Tier */tier?: ("free" | "paid") | null;+ /** Tiered Pricing */+ tiered_pricing?: {+ [key: string]: unknown;+ }[] | null;/** Updated At */updated_at?: string | null;/** Updated By */