litellm/tests/unit/proxy/spend_tracking
Claude 9fae6ea6e4
feat(cost): price Claude token calls, budget holds and auth price checks in Rust
completion_cost prices a Claude token call on Anthropic, Bedrock, Vertex AI
and Azure AI through NativeModelCostMap.price and stores the receipt's
breakdown, rates and adjustments on the logging object as before. Any call
Rust leaves to Python (another provider or call kind, built-in tools other than
a reported web search, a provider-stated cost, custom per-call prices or a
deferred candidate list) keeps the Python candidate loop for that call.

The Anthropic speed and geo uplifts and the Bedrock geo uplift now come from
the Rust core, and the Python bodies are gone. Discount and margin resolve in
Rust for every kind through NativeModelCostMap.adjust, replacing
_apply_cost_discount, _apply_cost_margin and resolve_cost_discount. The legacy
budget hold calls bound, and the auth checks read token rate keys and positive
token rates from rates.

Tests that patched deleted internals now drive the public functions, and new
cases pin the adapter to main's totals and breakdowns for the captured Claude
fixtures.
2026-11-19 06:44:47 +00:00
..
native_budgets_golden feat(budgets): replace the python budget hold and settle engine with a rust engine admitted at auth (#51535) 2026-11-15 16:03:51 -08:00
__init__.py
native_budgets_replica.py feat(budgets): replace the python budget hold and settle engine with a rust engine admitted at auth (#51535) 2026-11-15 16:03:51 -08:00
test_background_interaction_settlement.py fix(interactions): keep background interaction bills through crashes, late restarts, and deployment keys (#45743) 2026-10-16 12:00:08 +00:00
test_baseline_accounting.py
test_budget_reservation.py feat(proxy): add a surcharge on customer requests (#52406) 2026-11-19 00:45:10 +08:00
test_budget_reservation_redis_failure.py feat(budgets): replace the python budget hold and settle engine with a rust engine admitted at auth (#51535) 2026-11-15 16:03:51 -08:00
test_budget_reservation_rust.py feat(budgets): replace the python budget hold and settle engine with a rust engine admitted at auth (#51535) 2026-11-15 16:03:51 -08:00
test_carried_budget_state.py fix(proxy): show committed spend in the remaining budget gauges (#49199) 2026-11-09 20:05:37 +00:00
test_cloudzero_endpoints.py
test_committed_spend.py fix(proxy): show committed spend in the remaining budget gauges (#49199) 2026-11-09 20:05:37 +00:00
test_compression_savings.py
test_cost_finalization.py feat(proxy): add a surcharge on customer requests (#52406) 2026-11-19 00:45:10 +08:00
test_customer_budget_alerts.py fix: restore customer budget alerts after hierarchy schema changes (#51645) 2026-11-13 18:06:53 +00:00
test_customer_cost_margin.py feat(cost): price Claude token calls, budget holds and auth price checks in Rust 2026-11-19 06:44:47 +00:00
test_customer_window_accounting.py feat(budgets): replace the python budget hold and settle engine with a rust engine admitted at auth (#51535) 2026-11-15 16:03:51 -08:00
test_customer_window_accounting_rust.py feat(budgets): replace the python budget hold and settle engine with a rust engine admitted at auth (#51535) 2026-11-15 16:03:51 -08:00
test_input_tokens.py fix(token_counter): price PDF pages for OpenAI and Azure models the way they bill (#47554) 2026-10-29 18:24:04 -07:00
test_key_metadata_recovery.py
test_native_budget_checks.py feat(budgets): replace the python budget hold and settle engine with a rust engine admitted at auth (#51535) 2026-11-15 16:03:51 -08:00
test_native_budgets.py feat(budgets): replace the python budget hold and settle engine with a rust engine admitted at auth (#51535) 2026-11-15 16:03:51 -08:00
test_native_budgets_proxy_path.py feat(customer portal): set budgets per customer and gateway app (#52477) 2026-11-18 17:31:03 +00:00
test_performance_alerts.py feat(alerts): detect daily changes in recorded usage (#50666) 2026-11-11 18:23:02 -08:00
test_ptu_feature_flag.py feat(proxy): split Azure PTU deployments across teams with per-team PTU ceilings and PTU-hour reporting (#43043) 2026-10-15 18:44:30 +00:00
test_ptu_flat_cost_rollup.py refactor(router): move router callers onto the entry points and invert the proxy imports (#48847) 2026-10-29 17:26:33 +00:00
test_savings.py fix(spend): keep a NaN or infinite cost from wedging daily spend writes (#48829) 2026-10-30 08:27:35 -07:00
test_search_api_logging.py
test_session_page.py fix(spend): read only the newest rows when paging sessions (LIT-8513) (#48886) 2026-11-03 10:51:09 -08:00
test_session_spend_total.py feat(auto_router): report a session's whole spend and name why savings stay unestimated (#51066) 2026-11-10 17:07:11 -08:00
test_spend_capture_rate.py
test_spend_counter_batch.py feat(budgets): replace the python budget hold and settle engine with a rust engine admitted at auth (#51535) 2026-11-15 16:03:51 -08:00
test_spend_event.py fix(spend): write a background response's settling read in-process when the spend collector is on (#50957) 2026-11-10 18:19:17 -08:00
test_spend_event_producer.py test(unit): keep unix socket paths in unit tests under the macOS AF_UNIX limit (#45040) 2026-10-28 20:23:22 -07:00
test_spend_log_error_logger.py
test_spend_management_endpoints.py feat(proxy)!: let every key read its own spend logs and return 403 for filters outside the caller's scope (#52449) 2026-11-19 03:14:35 +00:00
test_spend_query_optimization.py fix(proxy): cancel the Admin UI's raw spend-log reads in Postgres after 30s (#49965) 2026-11-03 16:07:00 -08:00
test_spend_tracking_utils.py fix(proxy): count generateContent spend under its own endpoint (#52701) 2026-11-18 16:50:56 -08:00
test_subscription_billing_periods.py feat(usage): show subscription-covered providers and account fees separately (#44772) 2026-10-30 03:58:36 -07:00