mirror of
https://gh-proxy.org/https://github.com/klinsmaya/sub2api.git
synced 2026-11-09 13:57:06 +08:00
Anthropic Messages reports input_tokens excluding cache_read/cache_creation, but OpenAI Responses input_tokens is the total including cached tokens. The reverse converter passed Anthropic's input_tokens straight through, so client-facing prompt_tokens/input_tokens were short by the cached count and cache_creation was dropped entirely. Fix the non-stream path and the streaming state machine to add cache_read + cache_creation back into input_tokens, and track CacheCreationInputTokens on the streaming state. Six downstream paths benefit (Anthropic->Responses, Anthropic->ChatCompletions, Gemini->ChatCompletions, each sync + stream). Co-Authored-By: Claude Opus 4.7 <[email protected]>