Skip to content

🤖 fix: attribute GPT-5.6 prompt-cache write premium (1.25x) in cost reporting #3705

Description

@ammar-agent

Summary

GPT-5.6 (Sol/Terra/Luna) bills prompt-cache writes at 1.25x the uncached input rate. Mux's cost pipeline cannot attribute this premium yet: cache-written tokens are costed at the base input rate, so costs are slightly underreported on cache-miss/first-write requests. Found by Codex review on #3702.

Verified facts (July 9, 2026)

  • The Responses API reports cache writes: a live gpt-5.6-sol call with prompt_cache_key returned usage.input_tokens_details.cache_write_tokens: 3207 on first call and cached_tokens: 3207 on the second.
  • @ai-sdk/openai does not surface it: convertOpenAIResponsesUsage hardcodes cacheWrite: undefined and the usage Zod schema only parses cached_tokens, stripping cache_write_tokens. Verified on installed 3.0.62 and latest 3.0.83 — a version bump does not help.
  • Mux's createDisplayUsage() only sets cacheCreateTokens from providerMetadata.anthropic.cacheCreationInputTokens; there is no OpenAI-side source.

Impact

Bounded underreport: 0.25 × input rate on cache-written tokens, once per prefix (e.g. Sol at $5/M input → $1.25/M premium on first-write tokens). Subsequent cache hits are costed correctly via cached_tokens.

Options

  1. Wait for upstream: @ai-sdk/openai maps cache_write_tokensinputTokens.cacheWrite (the provider-usage shape already has the slot). Then read it generically in createDisplayUsage alongside the Anthropic path. Preferred; consider filing/watching an upstream issue.
  2. Mux-side workaround: extract usage from raw Responses bodies (JSON + SSE response.completed) in the OpenAI fetch wrapper and side-channel it into usage aggregation. Invasive/fragile; only if upstream stalls.

The cache_creation_input_token_cost metadata for GPT-5.6 in models-extra.ts is already correct, so pricing lights up automatically once cache-write tokens reach createDisplayUsage.


Generated with mux • Model: anthropic:claude-fable-5 • Thinking: high • Cost: $37.87

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions