Commit 12770e8
fix: preserve cache_creation fields in responses API usage transform
The _transform_chat_completion_usage_to_responses_usage method drops
Anthropic cache creation fields (cache_creation_input_tokens,
cache_read_input_tokens, cache_creation.ephemeral_5m/1h_input_tokens)
when converting chat-completion Usage to ResponseAPIUsage. This causes
the inference proxy to see zero cache creation tokens, resulting in
unbilled cache creation on /v1/responses.
Fix: use setattr to add these fields as extras on ResponseAPIUsage
(which supports extra fields via BaseLiteLLMOpenAIResponseObject's
extra="allow" config), so they survive serialization and can be
extracted downstream.
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent f5fe620 commit 12770e8
1 file changed
Lines changed: 20 additions & 0 deletions
Lines changed: 20 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2147 | 2147 | | |
2148 | 2148 | | |
2149 | 2149 | | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
2150 | 2170 | | |
2151 | 2171 | | |
2152 | 2172 | | |
| |||
0 commit comments