[FEATURE]: Discount cache write tokens from input. Handle Venice cache write #7667

Closed
opened 2026-02-16 18:07:52 -05:00 by yindo · 1 comment
Owner

Originally created by @dpuyosa on GitHub (Jan 26, 2026).

Originally assigned to: @thdxr on GitHub.

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

In getUsage, Opencode doesnt discount the cache_write tokens from the input tokens resulting on incorrect cost.
Right now, only anthropic and bedrock cache_write cost is being calculated. Venice also outputs this data for Claude models.

Extract Venice cacheWriteInputTokens to properly calculate the cost for Claude models. The cache.write tokens should be discounted from the input, since they have different cost.

Originally created by @dpuyosa on GitHub (Jan 26, 2026). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request In `getUsage`, Opencode doesnt discount the cache_write tokens from the input tokens resulting on incorrect cost. Right now, only `anthropic` and `bedrock` cache_write cost is being calculated. Venice also outputs this data for Claude models. Extract Venice `cacheWriteInputTokens` to properly calculate the cost for Claude models. The `cache.write` tokens should be discounted from the input, since they have different cost.
yindo added the discussion label 2026-02-16 18:07:52 -05:00
yindo closed this issue 2026-02-16 18:07:52 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 26, 2026):

This issue might be related to existing discussions about cache token handling:

  • #10581: stats: include cache tokens in averages

While #10581 focuses on reporting cache tokens in statistics, this issue addresses the critical aspect of correctly discounting cache_write tokens from input tokens in cost calculations. These features should likely be coordinated to ensure consistent token handling across the codebase.

Also note #9914 which addressed adding promptCacheKey support to Venice provider.

@github-actions[bot] commented on GitHub (Jan 26, 2026): This issue might be related to existing discussions about cache token handling: - #10581: stats: include cache tokens in averages While #10581 focuses on reporting cache tokens in statistics, this issue addresses the critical aspect of correctly discounting cache_write tokens from input tokens in cost calculations. These features should likely be coordinated to ensure consistent token handling across the codebase. Also note #9914 which addressed adding promptCacheKey support to Venice provider.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7667