bug: @langfuse/openai emits unpriced input_cache_write_tokens for GPT-5.6
Describe the bug
When the OpenAI Responses API reports GPT-5.6 cache-write usage, the official @langfuse/openai wrapper persists it as input_cache_write_tokens, but the Langfuse GPT-5.6 pricing definitions do not contain a price for that usage key. As a result, the tokens are present in usageDetails while their cost is silently omitted from costDetails and totalCost.
The mismatch is internal to Langfuse:
- OpenAI returns
usage.input_tokens_details.cache_write_tokens. parseUsageDetailsprefixes Responses API input detail keys withinput_, producinginput_cache_write_tokens.- The current
gpt-5.6-solpricing definition pricesinput_cache_creationandcache_write_tokens, but notinput_cache_write_tokens. - Usage-to-price matching therefore leaves this positive usage bucket unpriced.
Expected behavior: input_cache_write_tokens should be recognized as an alias of input_cache_creation and priced at the GPT-5.6 cache-write rate. OpenAI documents cache writes at 1.25x the uncached input rate. For GPT-5.6 Sol requests above 272K input tokens, this is $12.50 per million tokens.
Steps to reproduce
- Wrap the OpenAI Node SDK with
observeOpenAIfrom@langfuse/[email protected]. - Send a Responses API request using
gpt-5.6-solthat produces non-zeroinput_tokens_details.cache_write_tokens. - Retrieve the generation through
GET /api/public/v2/observationswith theusagefield group. - Observe that
usageDetails.input_cache_write_tokensis positive, butcostDetails.input_cache_write_tokensis absent.
A sanitized production observation:
{
"usagePricingTierName": "Large Context (>272K)",
"usageDetails": {
"input": 3,
"input_cached_tokens": 0,
"input_cache_write_tokens": 537807,
"output": 71,
"output_reasoning_tokens": 23,
"total": 537904
},
"costDetails": {
"input": 0.00003,
"input_cached_tokens": 0,
"output": 0.003195,
"output_reasoning_tokens": 0.001035,
"total": 0.00426
}
}The missing cache-write cost for this observation is:
537,807 * $12.50 / 1,000,000 = $6.7225875The buckets are otherwise mutually exclusive and sum to total, so this is not a double-counting issue.
Langfuse Cloud or self-hosted?
Langfuse Cloud
If self-hosted, what version are you running?
Not applicable.
SDK and integration versions
@langfuse/openai: 5.10.0@langfuse/client: 5.10.0@langfuse/otel: 5.10.0@langfuse/tracing: 5.10.0openai: 7.4.0- OpenAI Responses API
- Model:
gpt-5.6-sol
All listed npm packages are on their current latest versions as of August 16, 2026. The same mismatch is also present on the current main branches of langfuse-js and langfuse.
Additional information
This is closely related to langfuse/langfuse#15139 and its fix langfuse/langfuse#15712, but that fix added input_cache_creation and cache_write_tokens without adding the key emitted by the official JS wrapper: input_cache_write_tokens.
The open alias-resolution PR #15471 would be the natural place to handle this centrally, but its current alias map includes input_cache_write and cache_write_tokens, not input_cache_write_tokens.
Suggested fix:
input_cache_write_tokens -> input_cache_creationPlease add a regression test that starts from an OpenAI Responses API usage object containing input_tokens_details.cache_write_tokens, passes it through the official JS wrapper normalization, and verifies that the resulting cache-write bucket receives the configured GPT-5.6 price.
In one sanitized daily aggregate, 12,892,178 large-context cache-write tokens received zero cost in Langfuse, omitting $161.152225 from totalCost.
Are you interested in contributing a fix for this bug?
No.
Source: langfuse/langfuse