litellm/tests/integration/pricing
Kerry Lu b5e719392e
fix(cost): price forwarded-credential clones by their source deployment (#52313)
* fix(cost): price forwarded-credential clones by their source deployment

A request that forwards the client's own Authorization header goes through
`_clientside_deployment`, which builds a request-scoped deployment with a
new id derived from the credential and keeps the configured deployment's
id as `model_info.original_model_id`. Deployment prices are registered
under the configured id, so the clone's id has no cost-map entry and
`select_model_name_for_cost_calc` falls back to the public price map.

`get_router_model_id` exists only to find the deployment pricing entry.
Return a registered clone id when one exists, and otherwise fall back to
the registered `original_model_id`, so configured prices still apply to
forwarded-credential requests. Spend attribution still reads
`model_info.id`, so the per-credential model id is unchanged.

Fixes #52038

* fix(cost): type the forwarded-credential price lookup and cover it with an integration test

The original_model_id fallback added six basedpyright errors over the merge-base ceiling. The lookup now runs in a typed helper, and a proxy integration test sends /v1/messages with a forwarded client credential and checks the response cost header and spend row against the deployment's configured rates.

Co-authored-by: xDipzz <deepakmahajan.2004@gmail.com>

---------

Co-authored-by: xDipzz <deepakmahajan.2004@gmail.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-11-18 03:30:02 +08:00
..
test_bundled_cost_map_price_wire.py refactor(types): replace Any with proven types in 157 files (#44798) 2026-10-06 15:31:54 +00:00
test_configured_prices.py fix(cost): price forwarded-credential clones by their source deployment (#52313) 2026-11-18 03:30:02 +08:00
test_cost_margin_discount.py test(e2e): retire the quiet_stack lock and batch the claude_code model registration (#49984) 2026-11-04 09:55:53 -08:00
test_databricks_cache_pricing.py test(integration): regression tests for August cost tracking and budgeting bugs (#42622) 2026-09-23 04:13:03 +00:00
test_model_listing_token_limits.py fix(router): keep a deployment's token limits off the shared backend cost map key (#49952) 2026-11-03 16:14:44 -08:00
test_ocr_page_pricing.py test(integration): regression tests for August cost tracking and budgeting bugs (#42622) 2026-09-23 04:13:03 +00:00
test_off_peak_pricing.py test(integration): cover off-peak pricing on a live proxy 2026-09-19 00:10:22 +00:00
test_opencode_go_reported_cost_wire.py fix(opencode_go): forward chat reasoning effort (#52156) 2026-11-16 16:31:56 -08:00
test_per_second_pricing.py test(integration): stop GET /__observations from draining the upstream log (#47256) 2026-10-18 09:58:05 +00:00
test_price_data_reload_prices.py fix(cost-map): restore backward compatibility after the Rust loader move (#51545) 2026-11-14 08:12:17 +09:00
test_price_precedence.py Format database and accounting integration tests 2026-09-14 21:24:20 -07:00
test_realtime_cached_audio_pricing.py fix(cost): apply a deployment's pricing override to realtime sessions (#43114) 2026-09-24 21:03:59 -07:00
test_sail_service_tier_pricing.py test: move Sail, Weave and Presidio e2e tests to integration tests (#49533) 2026-10-31 18:31:01 -07:00
test_search_mode_pricing.py fix(search): price Tavily advanced and Linkup deep searches at their own cost map entries (#47411) 2026-10-19 23:32:31 -07:00
test_service_tier_pricing.py test(integration): stop GET /__observations from draining the upstream log (#47256) 2026-10-18 09:58:05 +00:00