#Missing cache write count for anthropic models

4 messages · Page 1 of 1 (latest)

coarse glenBOT
#

@sick sentinel

Description:
I'm trying to get the amount of tokens written in cache for Claude models for internal tracking

What I've Tried:
looking at the stream chunk that contains .usage i see cached_tokens but nothing about cache writes

You have the numbers in the backend (https://openrouter.ai/api/v1/generation?id=gen-1765829075-2y2cODsm0CXODYJfuCwg) because i can see you calculate cache_discount but it does not appear that you pass them downstream

Error Messages:

-

API/Model: anthropic/claude-4.5-sonnet-20250929

#

I'm an AI assistant - my answers may be incorrect and I cannot see screenshots. Please verify information with the OpenRouter docs.

Thank you for providing detailed context. To clarify your issue:

  • You're calling the API with anthropic/claude-4.5-sonnet-20250929
  • You're looking at the .usage stream chunk in the response and see cached_tokens but not a specific count for cache writes
  • You notice cache_discount is calculated in the backend, but do not see cache write details in the API response

Here’s what is currently documented:

"The cache_discount field in the response body will tell you how much the response saved on cache usage. Some providers, like Anthropic, will have a negative discount on cache writes, but a positive discount (which reduces total cost) on cache reads."

OpenRouter provides details about cache usage via:

  1. The Activity page
  2. The /api/v1/generation API (see docs)
  3. The usage: {include: true} request option for extra usage detail (Usage Accounting Guide)

The documentation does not mention a cache "write count" or field exposing the tokens written to cache separately for Anthropic models in the response. It only mentions cache_discount (for price calculation) and cached_tokens (Prompt Caching Guide).

Based on this, OpenRouter does not currently surface a specific cache write token count in the response for Anthropic models. Only cache_discount and cached_tokens are included, as described in the docs.

I don't have specific documentation ...

#

...showing how to retrieve the number of tokens written to cache via the API. Please verify this limitation with the mods or check the OpenRouter docs directly for the most current information. If this feature is critical, consider requesting it as a feature or clarification from the OpenRouter team.

References:

-# This is an automated response powered by Answer HQ. Use !mute to stop the bot from responding, or !close when your question is resolved.

sick sentinel
#

can i open a feature request to OpenRouter devs?