Skip to content

fix(cost_calculator): price base_model deployments from the base mode… - #41801

Closed
pratikwayal01 wants to merge 2 commits into
BerriAI:mainfrom
pratikwayal01:fix-hosted-vllm-base-model-cost
Closed

pratikwayal01 wants to merge 2 commits into
BerriAI:mainfrom
pratikwayal01:fix-hosted-vllm-base-model-cost

Conversation

@pratikwayal01

Copy link
Copy Markdown

…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

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. 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
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to 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

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

…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
@pratikwayal01
pratikwayal01 requested a review from a team September 18, 2026 11:14
@codspeed

codspeed Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing pratikwayal01:fix-hosted-vllm-base-model-cost (e3a09a1) with main (8fc9c46)

Open in CodSpeed

@greptile-apps

greptile-apps Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The pricing fix appears behaviorally safe, but the repository’s test-stability requirement must be satisfied before merging

Findings

  1. P2 Test Pins Cost Map ▶

Summary

This PR corrects pricing for deployments configured with explicit base-model cost keys

  • Preserves registered bare base-model keys when deployment-prefixed keys are unavailable
  • Infers the pricing provider from the explicit base model
  • Adds regression coverage for cross-provider and bare-name base models

Reviews (1) · Last reviewed commit: "fix(cost_calculator): price base_model d..."

@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

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.
@CLAassistant

CLAassistant commented Sep 18, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@mateo-berri

Copy link
Copy Markdown
Contributor

Base model pricing across providers is handled on main by #46318 and #47037. Reopen if it still happens or something is missing

@mateo-berri mateo-berri closed this Nov 9, 2026
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.

[Bug]: base_model not used for cost tracking with hosted_vllm, resulting in $0 spend

3 participants