-
[issue-6969] [BE] fix: discount OpenAI Responses API cached tokens in cost (#6971)
发布于
2026-06-05 15:11:17 +00:00 SpanCostCalculator.textGenerationWithCacheCostOpenAI only looked for cached input tokens under original_usage.prompt_tokens_details.cached_tokens (the Chat Completions shape) and the OTel cache_read_input_tokens key. The OpenAI Responses API reports them under original_usage.input_tokens_details.cached_tokens, so cached tokens were billed at the full input rate instead of the discounted cache-read rate, over-reporting cost on cache-heavy Responses API calls.
Add that key as a fallback in the cached-read lookup, and cover it with a new case in SpanCostCalculatorTest.
Fixes #6969
Co-authored-by: Andres Cruz andresc@comet.com
下载附件