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(cost): carry output_cost_per_second_720p through model info
mateo2881b8cd4553
diff --git a/litellm/types/router.py b/litellm/types/router.pyindex 5c9eab30f3d..6b707a544a2 100644--- a/litellm/types/router.py+++ b/litellm/types/router.py@@ -525,6 +525,7 @@ class LiteLLMParamsTypedDict(TypedDict, total=False):input_cost_per_second: float | Noneoutput_cost_per_second: float | Noneoutput_cost_per_second_480p: ReadOnly[float | None]+ output_cost_per_second_720p: ReadOnly[float | None]output_cost_per_second_1080p: float | Noneoutput_cost_per_second_4k: ReadOnly[float | None]num_retries: int | Nonediff --git a/litellm/types/utils.py b/litellm/types/utils.pyindex d62f00f3676..ab0cc5f959c 100644--- a/litellm/types/utils.py+++ b/litellm/types/utils.py@@ -318,6 +318,7 @@ class ModelInfoBase(ProviderSpecificModelInfo, total=False):float | None) # video_generation tier: key output_cost_per_second_<resolution> (e.g. 1080p, 720p)output_cost_per_second_480p: ReadOnly[float | None]+ output_cost_per_second_720p: ReadOnly[float | None]output_cost_per_second_4k: ReadOnly[float | None]ocr_cost_per_page: float | None # for OCR modelsocr_cost_per_credit: float | None # for OCR models priced by credit@@ -3522,6 +3523,7 @@ class CustomPricingLiteLLMParams(MirroredPricingParams):output_cost_per_second: float | None = Noneoutput_cost_per_second_1080p: float | None = Noneoutput_cost_per_second_480p: float | None = None+ output_cost_per_second_720p: float | None = Noneoutput_cost_per_second_4k: float | None = Noneinput_cost_per_pixel: float | None = Noneoutput_cost_per_pixel: float | None = Nonediff --git a/litellm/utils.py b/litellm/utils.pyindex 36b48d3b8d8..d0ff4917616 100644--- a/litellm/utils.py+++ b/litellm/utils.py@@ -5913,6 +5913,7 @@ def _get_model_info_helper(output_cost_per_second=_model_info.get("output_cost_per_second", None),output_cost_per_second_1080p=_model_info.get("output_cost_per_second_1080p", None),output_cost_per_second_480p=_model_info.get("output_cost_per_second_480p", None),+ output_cost_per_second_720p=_model_info.get("output_cost_per_second_720p", None),output_cost_per_second_4k=_model_info.get("output_cost_per_second_4k", None),output_cost_per_video_per_second=_model_info.get("output_cost_per_video_per_second", None),output_cost_per_image=_model_info.get("output_cost_per_image", None),diff --git a/tests/test_litellm/test_utils.py b/tests/test_litellm/test_utils.pyindex ec3a141a490..357c0d1c363 100644--- a/tests/test_litellm/test_utils.py+++ b/tests/test_litellm/test_utils.py@@ -814,6 +814,7 @@ def validate_model_cost_values(model_data, exceptions=None):"input_cost_per_second","output_cost_per_second","output_cost_per_second_480p",+ "output_cost_per_second_720p","output_cost_per_second_1080p","output_cost_per_second_4k","input_cost_per_query",@@ -1037,6 +1038,7 @@ def test_aaamodel_prices_and_context_window_json_is_valid():"output_cost_per_pixel": {"type": "number"},"output_cost_per_second": {"type": "number"},"output_cost_per_second_480p": {"type": "number"},+ "output_cost_per_second_720p": {"type": "number"},"output_cost_per_second_1080p": {"type": "number"},"output_cost_per_second_4k": {"type": "number"},"output_cost_per_token": {"type": "number"},diff --git a/tests/test_litellm/test_video_generation.py b/tests/test_litellm/test_video_generation.pyindex 2a60ff9c4b5..f3cd4618078 100644--- a/tests/test_litellm/test_video_generation.py+++ b/tests/test_litellm/test_video_generation.py@@ -532,6 +532,32 @@ class TestVideoGeneration:assert abs(cost_for("runwayml/seedance2_5", "480p", 8.0) - 1.6) < 0.001assert abs(cost_for("runwayml/gen4.5", None, 8.0) - 0.96) < 0.001+ def test_completion_cost_xai_imagine_video_720p_tier_from_cost_map(self, monkeypatch):+ """720p xAI Imagine Video requests bill the published 720p rate, not the 480p base rate."""+ from litellm.cost_calculator import completion_cost++ local_map_path = os.path.join(+ os.path.dirname(__file__), "..", "..", "model_prices_and_context_window.json"+ )+ with open(local_map_path, "r") as f:+ monkeypatch.setattr(litellm, "model_cost", json.load(f))++ def cost_for(model: str, resolution: str, duration: float) -> float:+ mock_response = MagicMock()+ mock_response.usage = {"duration_seconds": duration, "video_resolution": resolution}+ type(mock_response)._hidden_params = {}+ return completion_cost(+ completion_response=mock_response,+ model=model,+ call_type="create_video",+ custom_llm_provider="xai",+ )++ assert abs(cost_for("xai/grok-imagine-video", "720p", 10.0) - 0.7) < 0.001+ assert abs(cost_for("xai/grok-imagine-video-1.5", "720p", 10.0) - 1.4) < 0.001+ assert abs(cost_for("xai/grok-imagine-video-1.5", "480p", 10.0) - 0.8) < 0.001+ assert abs(cost_for("xai/grok-imagine-video-1.5", "1080p", 10.0) - 2.5) < 0.001+def test_completion_cost_veo_31_tiers_pin_published_rates(self, monkeypatch):"""The gemini and vertex_ai veo 3.1 entries bill Google's published per-second tier rates."""from litellm.cost_calculator import completion_costdiff --git a/ui/litellm-dashboard/src/lib/http/schema.d.ts b/ui/litellm-dashboard/src/lib/http/schema.d.tsindex 83b0d58f2b2..ce50978602f 100644--- a/ui/litellm-dashboard/src/lib/http/schema.d.ts+++ b/ui/litellm-dashboard/src/lib/http/schema.d.ts@@ -29629,6 +29629,8 @@ export interface components {output_cost_per_second_480p?: number | null;/** Output Cost Per Second 4K */output_cost_per_second_4k?: number | null;+ /** Output Cost Per Second 720P */+ output_cost_per_second_720p?: number | null;/** Output Cost Per Token */output_cost_per_token?: number | null;/** Output Cost Per Token Above 128K Tokens */@@ -39820,6 +39822,8 @@ export interface components {output_cost_per_second_480p?: number | null;/** Output Cost Per Second 4K */output_cost_per_second_4k?: number | null;+ /** Output Cost Per Second 720P */+ output_cost_per_second_720p?: number | null;/** Output Cost Per Token */output_cost_per_token?: number | null;/** Output Cost Per Token Above 128K Tokens */