fix: apply custom video pricing from deployment model_info - #21923
Merged
12 commits merged intoFeb 24, 2026
Merged
Conversation
…ported-model-name-encoding fix(bedrock): encode model arns for OpenAI compatible bedrock imported models
…point-for-auth_with_role_name feat(bedrock): support optional regional STS endpoint in role assumption
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryThis PR fixes custom video pricing not being applied for
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| litellm/cost_calculator.py | Added model_info parameter to default_video_cost_calculator() and extraction logic in completion_cost() video branch; clean structural refactoring with no behavioral regressions. |
| litellm/llms/openai/cost_calculation.py | Added optional model_info parameter to video_generation_cost() to skip global get_model_info() lookup when deployment-specific pricing is provided; minimal and focused change. |
| tests/test_litellm/test_video_generation.py | Added 3 new mock-only tests covering custom pricing through default_video_cost_calculator and the full completion_cost flow; no real network calls made. |
Sequence Diagram
sequenceDiagram
participant CC as completion_cost()
participant LO as litellm_logging_obj
participant VGC as video_generation_cost()
participant DVCC as default_video_cost_calculator()
participant GMI as get_model_info() / model_cost
CC->>CC: Check call_type in _VIDEO_CALL_TYPES
alt custom_pricing=True & litellm_logging_obj present
CC->>LO: Extract litellm_params.metadata.model_info
LO-->>CC: _video_model_info (deployment pricing)
end
alt duration_seconds available in usage
CC->>VGC: model, duration_seconds, model_info
alt model_info provided
VGC->>VGC: Use provided model_info directly
else model_info is None
VGC->>GMI: get_model_info(model)
GMI-->>VGC: global model_info
end
VGC-->>CC: cost (float)
else no duration_seconds
CC->>DVCC: model, duration=0.0, model_info
alt model_info provided
DVCC->>DVCC: Use provided model_info directly
else model_info is None
DVCC->>GMI: Lookup litellm.model_cost
GMI-->>DVCC: cost_info
end
DVCC-->>CC: cost (float)
end
Last reviewed commit: 9506d2f
Use Optional[ModelInfo] instead of Optional[dict] and restructure cost_info narrowing so mypy can properly track non-None state.
ghost
merged commit Feb 24, 2026
289e603
into
BerriAI:litellm_oss_staging_02_23_2026
30 checks passed
Sameerlite
added a commit
that referenced
this pull request
Mar 3, 2026
* auth_with_role_name add region_name arg for cross-account sts * update tests to include case with aws_region_name for _auth_with_aws_role * Only pass region_name to STS client when aws_region_name is set * Add optional aws_sts_endpoint to _auth_with_aws_role * Parametrize ambient-credentials test for no opts, region_name, and aws_sts_endpoint * consistently passing region and endpoint args into explicit credentials irsa * fix env var leakage * fix: bedrock openai-compatible imported-model should also have model arn encoded * fix: custom pricing not applied for /v1/videos endpoint (#21907) * fix: resolve mypy type errors for video pricing model_info parameter Use Optional[ModelInfo] instead of Optional[dict] and restructure cost_info narrowing so mypy can properly track non-None state. --------- Co-authored-by: An Tang <ta@stripe.com> Co-authored-by: Sameer Kankute <sameer@berri.ai>
fzowl
pushed a commit
to fzowl/litellm
that referenced
this pull request
Jun 24, 2026
…1923) * auth_with_role_name add region_name arg for cross-account sts * update tests to include case with aws_region_name for _auth_with_aws_role * Only pass region_name to STS client when aws_region_name is set * Add optional aws_sts_endpoint to _auth_with_aws_role * Parametrize ambient-credentials test for no opts, region_name, and aws_sts_endpoint * consistently passing region and endpoint args into explicit credentials irsa * fix env var leakage * fix: bedrock openai-compatible imported-model should also have model arn encoded * fix: custom pricing not applied for /v1/videos endpoint (BerriAI#21907) * fix: resolve mypy type errors for video pricing model_info parameter Use Optional[ModelInfo] instead of Optional[dict] and restructure cost_info narrowing so mypy can properly track non-None state. --------- Co-authored-by: An Tang <ta@stripe.com> Co-authored-by: Sameer Kankute <sameer@berri.ai>
This pull request was closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
model_infowas not applied for video generation cost calculation (/v1/videosendpoint)video_generation_cost()anddefault_video_cost_calculator()only looked up the globallitellm.model_costmap, ignoring deployment-specific pricingmodel_infoparameter to both functions, following the existingbatch_cost_calculator()patterncompletion_cost(), extractmodel_infofromlitellm_logging_obj.litellm_params.metadatawhencustom_pricing=Trueand pass it throughFixes #21907
Changes
litellm/llms/openai/cost_calculation.py- Accept optionalmodel_infoinvideo_generation_cost(), skipget_model_info()lookup when providedlitellm/cost_calculator.py- Accept optionalmodel_infoindefault_video_cost_calculator(), use it before global lookup. Extract model_info from litellm_logging_obj in video branch ofcompletion_cost()tests/test_litellm/test_video_generation.py- 3 new tests covering custom pricing through all code pathsTest plan
test_video_generation_cost_with_custom_model_info- custom per-second pricing via model_infotest_video_generation_cost_custom_model_info_fallback_to_per_second- fallback key in model_infotest_video_generation_cost_custom_pricing_through_completion_cost- full flow through completion_cost with mock litellm_logging_obj