#3890·9router

[BUG] Usage counts mis-translated from OpenAI responses to Anthropic messages

Author: cfytrokCreated Sep 8, 2026Updated Sep 30, 2026

Usage numbers are incorrectly translated from upstream OpenAI-style "responses" into Anthropic-style "messages", causing wrong values to be shown in the dashboard UI.

What happened (examples)

Provider response (5_res_provider.txt): { "input_tokens":21729, "input_tokens_details":{"cache_write_tokens":0,"cached_tokens":20992}, "output_tokens":11, "output_tokens_details":{"reasoning_tokens":0}, "total_tokens":21740 }

Translated messages after translation (7_res_client.txt): {"input_tokens":2737,"output_tokens":11,"cache_read_input_tokens":20992}

Expected messages

{"input_tokens":737,"output_tokens":11,"cache_read_input_tokens":20992}

Why this is wrong

  • The provider "responses" input_tokens (21729) includes cached_tokens (20992). The non-cached input should therefore be 21729 - 20992 = 737.
  • After translation the message's input_tokens becomes 2737 instead of 737, so the UI displays incorrect usage numbers.

Suspected location

Likely bug in open-sse/utils/usageTracking.js (BUFFER_TOKENS): https://github.com/decolua/9router/blob/eb712ca821f0ba6bc41043fbd14494c5af5daba5/open-sse/utils/usageTracking.js#L33

Image