Repository navigation
fix(cost_calculator): price base_model deployments from the base mode… - #41801
Closed
pratikwayal01 wants to merge 2 commits into
Closed
pratikwayal01 wants to merge 2 commits into
pratikwayal01 wants to merge 2 commits into
Conversation
…l's own provider A hosted_vllm deployment with model_info.base_model set to a registered cost key from a different provider (e.g. openrouter/deepseek/...) recorded /usr/bin/bash spend: cost_per_token received the deployment's provider and _get_model_info_helper rejected the base model's entry on provider mismatch, so every candidate in completion_cost failed and cost fell back to 0.0. A bare base_model also broke: it was prefixed with the deployment provider into an unregistered key before pricing. When base_model is set, infer custom_llm_provider from the selected model itself so pricing follows the base model's own provider entry, and keep a bare base_model verbatim when the prefixed form is unregistered. Fixes BerriAI#41780
Contributor
Contributor
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…odel test Replace the assertion that pinned the built-in cost map's contents (hosted_vllm/gpt-3.5-turbo absent) with a synthetic registered entry, so the test fails only on behavior changes, not on future cost-map updates.
Contributor
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.
…l's own provider
A hosted_vllm deployment with model_info.base_model set to a registered cost key from a different provider (e.g. openrouter/deepseek/...) recorded /usr/bin/bash spend: cost_per_token received the deployment's provider and _get_model_info_helper rejected the base model's entry on provider mismatch, so every candidate in completion_cost failed and cost fell back to 0.0. A bare base_model also broke: it was prefixed with the deployment provider into an unregistered key before pricing.
When base_model is set, infer custom_llm_provider from the selected model itself so pricing follows the base model's own provider entry, and keep a bare base_model verbatim when the prefixed form is unregistered.
Fixes #41780
TLDR
Problem this solves:
How it solves it:
User Flow
Relevant issues
Affected release
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Type
🆕 New Feature
🐛 Bug Fix
🧹 Refactoring
📖 Documentation
🚄 Infrastructure
✅ Test
Caveats (if any)
QA runbook
Final Attestation