litellm/tests/integration/spend
devin-ai-integration[bot] 68db39a651
fix(cost): price rule-only model names at the deployment's rate (#44144)
* fix(cost): price streamed aliases that only match a capability rule from the deployment model

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor(cost): satisfy basedpyright delta after the cost-candidate sort

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* perf(cost): skip the capability-rule check for exact cost-map keys

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(spend): price streamed alias rows from the deployment's own rates

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(spend): isolate streamed alias deployments with per-run model names

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(streaming): keep the unpriceable-stamp case on a truly unmapped model

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(cost): treat capability-rule matches as unmapped in every cost lookup

Route every model-info lookup on cost paths through get_priced_model_info
and _cached_get_priced_model_info_helper, which raise ModelNotMappedError
when the only match is a pricing-free fallback-generalizations rule. An
alias that matches a capability rule now falls through to the deployment's
real model instead of billing 0, and the earlier candidate-sorting fix is
reverted since the priced helper is the single choke point.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(spend): assert the rule alias bills the same as the plain alias

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(cost): treat router-registered rule-only model_cost entries as unmapped

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(cost): count string rates and check pricing before the capability-rule match

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(cost): repoint cost-path patches at get_priced_model_info

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* style(cost): give the model_cost row cast a cast-ok reason

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* fix(cost): type the lazy get_priced_model_info export

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* refactor(cost): narrow the fix to ordering rule-only cost candidates last

Drops get_priced_model_info and its call-site swaps, the lazy-import entry,
and the cost-path code check. Only the candidate sort in completion_cost and
pricing_entry_for_cost_calc stays, with its tests

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(spend): cover rule-only base_model billing on every endpoint, client and failure mode

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

---------

Co-authored-by: kerry <kerry@berri.ai>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Backport: dropped the pricing_entry_for_cost_calc hunk and its test; that function is not on stable/1.103.x (it comes from #42345)

(cherry picked from commit f9a32ffcb5)
2026-10-02 22:28:19 -07:00
..
test_cache_and_quota.py test: add extension and browser integration contracts 2026-09-16 13:15:53 -07:00
test_daily_activity_key_alias_probes.py test(integration): register the daily activity key metadata contracts on stable/1.103.x 2026-09-30 12:35:46 -07:00
test_daily_activity_key_owner.py test(integration): register the daily activity key metadata contracts on stable/1.103.x 2026-09-30 12:35:46 -07:00
test_daily_activity_key_owner_faults.py test(integration): register the daily activity key metadata contracts on stable/1.103.x 2026-09-30 12:35:46 -07:00
test_daily_activity_key_owner_traffic.py test(integration): register the daily activity key metadata contracts on stable/1.103.x 2026-09-30 12:35:46 -07:00
test_filtered_ledger.py test: add extension and browser integration contracts 2026-09-16 13:15:53 -07:00
test_stream_alias_billing.py fix(cost): price rule-only model names at the deployment's rate (#44144) 2026-10-02 22:28:19 -07:00
test_team_member_spend_flush.py test(integration): make rc/1.103.0 integration groups collect and pass again (#43382) 2026-09-26 17:00:41 -07:00