feat: add anthropic cached token values for local backends that support it
All checks were successful
PR Tests / test (pull_request) Successful in 1m19s
NYX Security Scan / nyx-scan (pull_request) Successful in 5m37s

This commit is contained in:
Alpha Nerd 2026-07-06 11:05:59 +02:00
parent 1d012a92ef
commit 04bc69993d
Signed by: alpha-nerd
SSH key fingerprint: SHA256:QkkAgVoYi9TQ0UKPkiKSfnerZy2h4qhi3SVPXJmBN+M
3 changed files with 93 additions and 16 deletions

View file

@ -90,7 +90,8 @@ def _serve_cache_hit(cached: bytes, message_id: str, stream: bool):
obj = orjson.loads(cached)
obj["id"] = message_id
u = obj.get("usage") or {}
read = u.get("input_tokens", 0) or 0
# Whole prompt served from cache: fold the stored uncached + read tokens into read.
read = (u.get("input_tokens", 0) or 0) + (u.get("cache_read_input_tokens", 0) or 0)
obj["usage"] = {
**u,
"input_tokens": 0,