feat(pricing): price cached and cache-write input tokens

Cost now prices cache-read and cache-write prompt tokens at their own rates.
A model without a cache price keeps the input rate, so cost does not change.
The cache shares are clamped to the prompt, so odd usage cannot give a negative cost.
LiteLLM field names cache_read_input_token_cost and cache_creation_input_token_cost were confirmed in the fetched source.
The pricing-sync tool reads both fields. The table regeneration is a separate commit.
This commit is contained in:
2026-11-26 00:37:19 +00:00
parent 73ff7d92e0
commit 55ebe1fae1
6 changed files with 206 additions and 17 deletions
+6 -2
View File
@@ -627,9 +627,13 @@ type AdminStatsConfig struct {
}
// ModelPricing overrides the built-in per-model price table.
// CachedInputPerM and CacheWritePerM price cache-read and cache-write
// prompt tokens; nil falls back to InputPerM.
type ModelPricing struct {
InputPerM float64 `json:"inputPerM"`
OutputPerM float64 `json:"outputPerM"`
CachedInputPerM *float64 `json:"cachedInputPerM,omitempty"`
CacheWritePerM *float64 `json:"cacheWritePerM,omitempty"`
InputPerM float64 `json:"inputPerM"`
OutputPerM float64 `json:"outputPerM"`
}
// ModelMetaConfig overrides one model's context window and per-token