litellm/tests/test_litellm/proxy/spend_tracking
devin-ai-integration[bot] 0c515ed7a8
feat(proxy): record in spend logs whether a request used a client-forwarded Anthropic OAuth token (#43063)
* feat(proxy): record in spend logs whether a request used a client-forwarded Anthropic OAuth token

Stamp metadata.used_client_oauth_token where the proxy decides to forward a
client's Anthropic OAuth token, carry it through StandardLoggingMetadata into
the spend log row, add a used_client_oauth_token filter to /spend/logs/ui, and
surface it on the Logs page as a Credential filter and drawer field. The token
itself never reaches the log

* fix(proxy): carry used_client_oauth_token onto failure spend rows for litellm_metadata routes

* fix(proxy): resolve used_client_oauth_token against the provider the call was sent to

* fix(proxy): keep the proxy's used_client_oauth_token stamp on failure rows and move the resolver under llms/anthropic

* fix(logging): read used_client_oauth_token from the proxy-stamped metadata slot

On routes that carry proxy metadata in litellm_metadata, metadata is the
caller's own body field, and merge_litellm_metadata lets it win. Resolve the
flag from litellm_metadata when the proxy stamped it there so a caller cannot
set it in the standard logging payload

* fix(spend-logs): read used_client_oauth_token from the bucket the route stamped

A guardrail on the unified path adds litellm_metadata to a chat request after
the proxy stamped metadata, so both spend row writers read the new bucket and
stored null. The success row now resolves the flag the same way the callback
payload does, and the failure row picks the bucket from the request route.

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-09-30 19:17:01 -07:00
..
test_baseline_accounting.py fix(proxy): estimate auto-router baseline costs from durable cache history 2026-09-19 12:44:47 -07:00
test_budget_reservation.py test(rust_bridge): drop route dispatch assertions, test the bridge directly (#42536) 2026-09-22 19:21:32 +00:00
test_budget_reservation_redis_failure.py perf(proxy): hold one spend counter batch across admission and across post-call accounting (#43369) 2026-09-29 15:05:33 -07:00
test_carried_budget_state.py feat(team): team-level model_max_budget with key-level overrides 2026-09-16 00:40:58 +00:00
test_cloudzero_endpoints.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_compression_savings.py feat(spend): track prompt compression saved tokens in daily spend aggregates (#33810) 2026-07-18 17:47:54 -07:00
test_input_tokens.py test(rust_bridge): drop route dispatch assertions, test the bridge directly (#42536) 2026-09-22 19:21:32 +00:00
test_key_metadata_recovery.py fix(proxy): look up hashed key names with two spend log rows per key (#43656) 2026-09-29 20:21:55 -07:00
test_ptu_feature_flag.py feat(ptu): gate PTU flat-cost attribution behind an opt-in env var (#36138) 2026-08-10 12:23:20 -07:00
test_ptu_flat_cost_rollup.py test(ptu): drop the assertion on the flag removed upstream 2026-08-23 10:02:41 +00:00
test_savings.py chore(cost-map): remove models past their deprecation date (#42435) 2026-09-22 21:19:26 +00:00
test_spend_capture_rate.py feat(spend): capture-rate check of LiteLLM spend against the OpenAI bill (#43044) 2026-09-24 17:09:28 -07:00
test_spend_counter_batch.py perf(proxy): hold one spend counter batch across admission and across post-call accounting (#43369) 2026-09-29 15:05:33 -07:00
test_spend_event.py feat(proxy): offload spend tracking to a pod-local collector sidecar (#40545) 2026-09-10 17:14:13 -07:00
test_spend_event_producer.py feat(proxy): offload spend tracking to a pod-local collector sidecar (#40545) 2026-09-10 17:14:13 -07:00
test_spend_log_error_logger.py feat(spend-logs): opt-in suppression of stack traces in spend-tracking error logs 2026-05-02 00:44:34 +00:00
test_spend_management_endpoints.py feat(proxy): record in spend logs whether a request used a client-forwarded Anthropic OAuth token (#43063) 2026-09-30 19:17:01 -07:00
test_spend_query_optimization.py feat(agents): authenticate Entra identities and delegated requests (#43722) 2026-09-30 13:05:22 -07:00
test_spend_tracking_utils.py feat(proxy): record in spend logs whether a request used a client-forwarded Anthropic OAuth token (#43063) 2026-09-30 19:17:01 -07:00