bug: token cost seems inaccurate #1348

Closed
opened 2026-02-16 17:30:32 -05:00 by yindo · 8 comments
Owner

Originally created by @nikhilmaddirala on GitHub (Aug 17, 2025).

Originally assigned to: @thdxr on GitHub.

I have some questions about this example conversation: https://opencode.ai/s/XPu4Slcg

  1. It says Cost$0.25 Input Tokens 54541 Output Tokens 431 Reasoning Tokens — but according to openrouter the cost of z-ai/glm-4.5 is $0.20/M input tokens $0.80/M output tokens, which is much lower. Is this discrepancy due to a bug in opencode?
  2. Where are the 50k+ input tokens coming from for my query and how can I inspect them?

Thanks in advance!

Originally created by @nikhilmaddirala on GitHub (Aug 17, 2025). Originally assigned to: @thdxr on GitHub. I have some questions about this example conversation: https://opencode.ai/s/XPu4Slcg 1. It says `Cost$0.25 Input Tokens 54541 Output Tokens 431 Reasoning Tokens —` but according to openrouter the cost of [z-ai](https://openrouter.ai/z-ai)/glm-4.5 is `$0.20/M input tokens $0.80/M output tokens`, which is much lower. Is this discrepancy due to a bug in opencode? 2. Where are the 50k+ input tokens coming from for my query and how can I inspect them? Thanks in advance!
yindo closed this issue 2026-02-16 17:30:32 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Aug 17, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #534: OpenRouter price calculations likely does not consider cache read - specifically addresses discrepancies in OpenRouter cost calculations
  • #1349: Shows tokens per file - requests ability to inspect where input tokens are coming from (your question 2)
  • #1634: Track overall token usage - related to understanding token consumption across sessions

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Aug 17, 2025): This issue might be a duplicate of existing issues. Please check: - #534: OpenRouter price calculations likely does not consider cache read - specifically addresses discrepancies in OpenRouter cost calculations - #1349: Shows tokens per file - requests ability to inspect where input tokens are coming from (your question 2) - #1634: Track overall token usage - related to understanding token consumption across sessions Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Aug 17, 2025):

Looking at openrouter I see:
Input: $0.6/M
Output: $2.20/M

see here

@rekram1-node commented on GitHub (Aug 17, 2025): Looking at openrouter I see: Input: $0.6/M Output: $2.20/M see [here](https://openrouter.ai/z-ai/glm-4.5)
Author
Owner

@nikhilmaddirala commented on GitHub (Aug 17, 2025):

Looking at openrouter I see:
Input: $0.6/M
Output: $2.20/M

see here

But even w/ those numbers the cost seems incorrect...

When I click your link I see the same numbers I cited in my OP.

@nikhilmaddirala commented on GitHub (Aug 17, 2025): > Looking at openrouter I see: > Input: $0.6/M > Output: $2.20/M > > see [here](https://openrouter.ai/z-ai/glm-4.5) > > But even w/ those numbers the cost seems incorrect... When I click your link I see the same numbers I cited in my OP.
Author
Owner

@rekram1-node commented on GitHub (Aug 17, 2025):

@nikhilmaddirala I was looking at:

Image

But yes you are correct and this appears to be a bug, thank you for reporting

@rekram1-node commented on GitHub (Aug 17, 2025): @nikhilmaddirala I was looking at: <img width="1052" height="183" alt="Image" src="https://github.com/user-attachments/assets/d1d8c11c-f3f1-46ab-ab2e-8ebe91f9a494" /> But yes you are correct and this appears to be a bug, thank you for reporting
Author
Owner

@nikhilmaddirala commented on GitHub (Aug 17, 2025):

image

@nikhilmaddirala commented on GitHub (Aug 17, 2025): ![image](https://github.com/user-attachments/assets/63f604c2-ee4d-499b-94b9-ff45dc949592)
Author
Owner

@spoons-and-mirrors commented on GitHub (Aug 19, 2025):

somewhat related to https://github.com/sst/opencode/issues/1937 I believe

@spoons-and-mirrors commented on GitHub (Aug 19, 2025): somewhat related to https://github.com/sst/opencode/issues/1937 I believe
Author
Owner

@rekram1-node commented on GitHub (Aug 22, 2025):

just to provide insight into where the tokens are coming from, looks like vast majority are from the web fetch results, they can be rather expensive depending on website & content

@rekram1-node commented on GitHub (Aug 22, 2025): just to provide insight into where the tokens are coming from, looks like vast majority are from the web fetch results, they can be rather expensive depending on website & content
Author
Owner

@rekram1-node commented on GitHub (Dec 27, 2025):

[automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!

@rekram1-node commented on GitHub (Dec 27, 2025): [automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1348