Skip to content

feat(gemini): Veo Lite pricing, video resolution usage and tiered cost - #25348

Merged
ishaan-berri merged 4 commits into
mainfrom
litellm_gemini-veo-video-resolution-pricing2
Apr 14, 2026
Merged

feat(gemini): Veo Lite pricing, video resolution usage and tiered cost#25348
ishaan-berri merged 4 commits into
mainfrom
litellm_gemini-veo-video-resolution-pricing2

Conversation

@Sameerlite

Copy link
Copy Markdown
Contributor

Summary

  • Add gemini/veo-3.1-lite-generate-preview to the model cost map with output_cost_per_second (720p) and output_cost_per_second_1080p.
  • Map OpenAI size (WxH) to Gemini resolution (720p/1080p) alongside aspectRatio, using a single preset map.
  • Populate usage.video_resolution on Gemini and Vertex Veo create responses for spend tracking.
  • Resolve per-second video cost via dynamic output_cost_per_second_<resolution> keys, falling back to output_cost_per_second.
  • Wire video_resolution through completion_cost / default_video_cost_calculator; extend types, router TypedDict, and get_model_info for output_cost_per_second_1080p.

Tests

  • tests/test_litellm/llms/gemini/videos/test_gemini_video_transformation.py
  • tests/test_litellm/test_video_generation.py (video cost / 1080p tier / completion_cost)

Notes

  • Pyright: cast(BaseModel, ...) for usage/hidden-params narrowing in cost_calculator.py; Mapping[str, Any] for _video_output_cost_per_second.

@vercel

vercel Bot commented Apr 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Apr 8, 2026 5:02pm

Request Review

@codspeed-hq

codspeed-hq Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 16 untouched benchmarks


Comparing litellm_gemini-veo-video-resolution-pricing2 (2834659) with main (62757ff)

Open in CodSpeed

@greptile-apps

greptile-apps Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds support for gemini/veo-3.1-lite-generate-preview with resolution-aware tiered pricing for Google's Veo video generation API. The core changes wire a size → resolution inference path (720p/1080p) through the Gemini transformation layer, propagate video_resolution into the usage dict on VideoObject, and resolve the correct per-second cost via a new output_cost_per_second_<resolution> lookup with fallback to output_cost_per_second. Supporting changes include:

  • Pricing entries in both model_prices_and_context_window.json and the backup file for the new model (0.05 $/s default, 0.08 $/s at 1080p).
  • New output_cost_per_second_1080p field in ModelInfo, CustomPricingLiteLLMParams, LiteLLMParamsTypedDict, and get_model_info().
  • _video_output_cost_per_second and _video_resolution_to_cost_field_suffix helpers in openai/cost_calculation.py; video_resolution parameter threaded through video_generation_cost, default_video_cost_calculator, and the completion_cost video branch.
  • Vertex AI transform_video_create_response now also captures video_resolution from parameters.
  • Comprehensive unit tests covering resolution mapping, the infer-vs-explicit-resolution precedence rule, and the 1080p pricing tier through both calculators.

The previous review comments have been addressed: _video_output_cost_per_second is now a module-level import, and ModelInfo exposes output_cost_per_second_1080p.

Confidence Score: 5/5

Safe 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.

Vulnerabilities

No security concerns identified. Changes are limited to pricing/cost calculation logic and video request/response transformation; no auth, secrets handling, or input validation paths are modified.

Important Files Changed

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
Loading

Reviews (3): Last reviewed commit: "fix tests and mypy" | Re-trigger Greptile

Comment thread litellm/cost_calculator.py Outdated
Comment thread litellm/llms/openai/cost_calculation.py
Comment thread litellm/llms/gemini/videos/transformation.py
Comment thread litellm/cost_calculator.py Dismissed
Comment thread litellm/cost_calculator.py Dismissed
@krrish-berri-2

Copy link
Copy Markdown
Contributor

@Sameerlite can you include screenshots of this working as expected

@Sameerlite

Copy link
Copy Markdown
Contributor Author
image Cost(8 s at 720p (e.g. size: 1280x720))= 8 × 0.05 = 0.40

@ishaan-berri
ishaan-berri merged commit 4a71583 into main Apr 14, 2026
103 of 107 checks passed
@ishaan-berri
ishaan-berri deleted the litellm_gemini-veo-video-resolution-pricing2 branch April 14, 2026 17:23
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…o-resolution-pricing2

feat(gemini): Veo Lite pricing, video resolution usage and tiered cost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants