[proxy] split prompt-cache cost out of the metered total

Pricing now returns the cache portion of the request cost next to the
total (cache read + creation for Anthropic-shape providers, the
discounted cached subset for OpenAI). cost_meter emits it as
cost.usd_cache, and the usage-only access-log strip keeps the cache
token counts and cache cost so management can persist them.
This commit is contained in:
Maycon Santos
2026-07-25 19:19:56 +00:00
parent 99ad5642b9
commit d9bf667275
5 changed files with 48 additions and 17 deletions
+11 -8
View File
@@ -221,14 +221,17 @@ func (l *Logger) allowDenyLog(serviceID types.ServiceID, reason string) bool {
// proxy/internal/middleware/keys.go — only the dimensions management needs to
// record a usage row (provider / model / tokens / cost / groups).
var usageMetadataKeys = map[string]struct{}{
"llm.provider": {},
"llm.model": {},
"llm.resolved_provider_id": {},
"llm.input_tokens": {},
"llm.output_tokens": {},
"llm.total_tokens": {},
"cost.usd_total": {},
"llm.authorising_groups": {},
"llm.provider": {},
"llm.model": {},
"llm.resolved_provider_id": {},
"llm.input_tokens": {},
"llm.output_tokens": {},
"llm.total_tokens": {},
"llm.cached_input_tokens": {},
"llm.cache_creation_tokens": {},
"cost.usd_total": {},
"cost.usd_cache": {},
"llm.authorising_groups": {},
}
// stripAgentNetworkEntryForUsage returns the entry reduced to what's needed to