6 views
-/https://github.com/berriai/litellm/issues/27191
GitHub · issue

#27191 [Feature]: Cache Token Cost & Tracking for Custom Pricing and OpenAI-Compatible Providers

  • State: open
  • Author: @escon1004
  • Labels: enhancement, proxy, llm translation

### Check for existing issues

- [x] I have searched the existing issues and checked that my issue is not a duplicate.

### The Feature

## Summary

Two related but independent bugs prevented LiteLLM from correctly handling prompt-cache tokens when using:

1. **Custom pricing** (`custom_cost_per_token` with `cache_read_input_token_cost` / `cache_creation_input_token_cost`) — cache tokens were billed at the full `input_cost_per_token` rate instead of the configured cache rate. 2. **OpenAI-compatible providers** (moonshotai, openai, deepseek, kimi-k2, etc.) that report cache info via `usage.prompt_tokens_details` — daily spend aggregation always recorded `Cache Read Tokens = 0` and `Cache Write Tokens = 0` in the dashboard.

This patch fixes both, while preserving existing behavior when no custom cache pricing is configured (cache tokens fall back to `input_cost_per_token`).

References: - https://github.com/BerriAI/litellm/issues/26807 - https://docs.litellm.ai/docs/proxy/custom_pricing - https://docs.litellm.ai/docs/completion/prompt_caching

---

## Bug 1: `custom_cost_per_token` Ignores Cache Token Pricing

### Symptom

When a user configures custom pricing with ca…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (1 events)
#0 of 0 · 31d18h12m25s ago — entered · #import:https:::github.com:berriai:litellm post #2859
The left issue requires coordinated changes across pricing, token accounting, provider normalization, aggregation, and regression coverage, with backward-compatibility risk. The right issue is primarily a repository workflow and merge-configuration change with limited runtime scope.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search