feat(gemini): Veo Lite pricing, video resolution usage and tiered cost - #25348
Conversation
…on for cost tiers Made-with: Cursor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR adds support for
The previous review comments have been addressed: Confidence Score: 5/5Safe to merge — no P0/P1 issues; all previous review concerns have been addressed. The implementation is correct end-to-end: size→resolution inference, usage propagation, and tiered cost lookup all work as intended. The fallback chain (output_cost_per_second_1080p → output_cost_per_second) correctly handles 720p (which uses the default rate) without needing an extra key in the JSON. Previous thread issues (inline import, ModelInfo typing) are resolved. Tests cover the new paths without weakening existing coverage. No files require special attention.
|
| Filename | Overview |
|---|---|
| litellm/llms/gemini/videos/transformation.py | Adds _OPENAI_VIDEO_SIZE_TO_ASPECT_RATIO class-level map, _convert_size_to_resolution, and _usage_video_resolution_from_parameters; wires size→resolution inference into map_openai_params with correct explicit-resolution-wins precedence; populates usage.video_resolution in transform_video_create_response. |
| litellm/llms/openai/cost_calculation.py | Adds _video_resolution_to_cost_field_suffix, _video_output_cost_per_second, and video_generation_cost with video_resolution support; fallback chain (tier key → output_cost_per_second) is correct for current pricing model. |
| litellm/cost_calculator.py | Extracts video_resolution from both dict and Pydantic usage objects; passes it through video_generation_cost and default_video_cost_calculator; also moves _video_output_cost_per_second to a module-level import and adds cast for Pyright narrowing. |
| litellm/llms/vertex_ai/videos/transformation.py | Captures video_resolution from parameters.resolution into usage_data in transform_video_create_response; consistent with Gemini handler but does not add size→resolution inference (intentional per PR scope). |
| litellm/types/utils.py | Adds output_cost_per_second_1080p to ModelInfoBase TypedDict and CustomPricingLiteLLMParams Pydantic model; comment correctly notes other resolution tiers aren't yet exposed via typed lookup. |
| model_prices_and_context_window.json | Adds gemini/veo-3.1-lite-generate-preview with output_cost_per_second: 0.05 (default/720p rate) and output_cost_per_second_1080p: 0.08; both backup and primary files updated consistently. |
| tests/test_litellm/llms/gemini/videos/test_gemini_video_transformation.py | Adds tests for _convert_size_to_resolution, explicit-resolution-wins precedence, 1080p landscape mapping, and usage.video_resolution capture; remaining changes are Black formatting only (no logic weakened). |
| tests/test_litellm/test_video_generation.py | Adds test_video_generation_cost_1080p_tier_via_default_calculator and test_completion_cost_video_generation_1080p_tier covering the full tiered pricing path through both calculators. |
Sequence Diagram
sequenceDiagram
participant User
participant GeminiVideoConfig
participant CostCalculator
participant OpenAICostCalc
User->>GeminiVideoConfig: video_generation(size="1920x1080", seconds=8)
GeminiVideoConfig->>GeminiVideoConfig: map_openai_params()<br/>size → aspectRatio="16:9"<br/>size → resolution="1080p" (inferred)
GeminiVideoConfig->>GeminiVideoConfig: transform_video_create_request()<br/>builds {instances, parameters:{aspectRatio, durationSeconds, resolution}}
Note over GeminiVideoConfig: Sends request to Veo API
GeminiVideoConfig->>GeminiVideoConfig: transform_video_create_response()<br/>usage_data = {duration_seconds: 8.0, video_resolution: "1080p"}
GeminiVideoConfig-->>User: VideoObject(usage={duration_seconds:8, video_resolution:"1080p"})
User->>CostCalculator: completion_cost(response, call_type="create_video")
CostCalculator->>CostCalculator: extract video_resolution="1080p" from usage
CostCalculator->>OpenAICostCalc: video_generation_cost(model, duration=8.0, video_resolution="1080p")
OpenAICostCalc->>OpenAICostCalc: get_model_info() → ModelInfo<br/>{output_cost_per_second:0.05, output_cost_per_second_1080p:0.08}
OpenAICostCalc->>OpenAICostCalc: _video_output_cost_per_second(model_info, "1080p")<br/>→ looks up output_cost_per_second_1080p = 0.08
OpenAICostCalc-->>CostCalculator: 0.08 * 8.0 = $0.64
CostCalculator-->>User: $0.64
Reviews (3): Last reviewed commit: "fix tests and mypy" | Re-trigger Greptile
|
@Sameerlite can you include screenshots of this working as expected |
…o-resolution-pricing2 feat(gemini): Veo Lite pricing, video resolution usage and tiered cost

Summary
gemini/veo-3.1-lite-generate-previewto the model cost map withoutput_cost_per_second(720p) andoutput_cost_per_second_1080p.size(WxH) to Geminiresolution(720p/1080p) alongsideaspectRatio, using a single preset map.usage.video_resolutionon Gemini and Vertex Veo create responses for spend tracking.output_cost_per_second_<resolution>keys, falling back tooutput_cost_per_second.video_resolutionthroughcompletion_cost/default_video_cost_calculator; extend types, router TypedDict, andget_model_infoforoutput_cost_per_second_1080p.Tests
tests/test_litellm/llms/gemini/videos/test_gemini_video_transformation.pytests/test_litellm/test_video_generation.py(video cost / 1080p tier / completion_cost)Notes
cast(BaseModel, ...)for usage/hidden-params narrowing incost_calculator.py;Mapping[str, Any]for_video_output_cost_per_second.