Token count is way off #3746

Open
opened 2026-02-16 17:41:19 -05:00 by yindo · 6 comments
Owner

Originally created by @abdurahmanshiine on GitHub (Dec 22, 2025).

Originally assigned to: @rekram1-node on GitHub.

Description

Hey there,

I started using OpenCode today and I got an out-of-credit error very quickly, that surprised me because the token count in OpenCode said: ~85k tokens, but when I went to the billing page of my API provider (Fireworks AI) it said I had used close to 3.55m tokens, which is a crazy gap. And so I'm wondering where is that difference coming from

OpenCode version

1.0.185

Steps to reproduce

No response

Screenshot and/or share link

Image Image

Operating System

WSL

Terminal

Windows Terminal

Originally created by @abdurahmanshiine on GitHub (Dec 22, 2025). Originally assigned to: @rekram1-node on GitHub. ### Description Hey there, I started using OpenCode today and I got an out-of-credit error very quickly, that surprised me because the token count in OpenCode said: ~85k tokens, but when I went to the billing page of my API provider (Fireworks AI) it said I had used close to 3.55m tokens, which is a crazy gap. And so I'm wondering where is that difference coming from ### OpenCode version 1.0.185 ### Steps to reproduce _No response_ ### Screenshot and/or share link <img width="466" height="331" alt="Image" src="https://github.com/user-attachments/assets/e249cfb2-4a39-4bbe-b6bc-b594d3528f7f" /> <img width="1312" height="639" alt="Image" src="https://github.com/user-attachments/assets/4dc5f02b-ee05-43e3-a230-449b715fc02f" /> ### Operating System WSL ### Terminal Windows Terminal
yindo added the bug label 2026-02-16 17:41:19 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 22, 2025):

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

  • #5440: Incorrect token usage - reported discrepancy between token count display and actual API usage
  • #2020: bug: token cost seems inaccurate - reported incorrect cost calculations and large discrepancies in token counts
  • #3322: web and tui reports token usage differently - reported discrepancies in how token usage is calculated/reported between different interfaces
  • #254: Ridiculously big usage of input tokens for simple tasks - reported unexpectedly high token usage for simple operations

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

@github-actions[bot] commented on GitHub (Dec 22, 2025): This issue might be a duplicate of existing issues. Please check: - #5440: Incorrect token usage - reported discrepancy between token count display and actual API usage - #2020: bug: token cost seems inaccurate - reported incorrect cost calculations and large discrepancies in token counts - #3322: web and tui reports token usage differently - reported discrepancies in how token usage is calculated/reported between different interfaces - #254: Ridiculously big usage of input tokens for simple tasks - reported unexpectedly high token usage for simple operations Feel free to ignore if none of these address your specific case.
Author
Owner

@abdurahmanshiine commented on GitHub (Dec 22, 2025):

Taking a look at the stats I got this, which is really weird because I have only sent 12 messages (and not 75)

Image
@abdurahmanshiine commented on GitHub (Dec 22, 2025): Taking a look at the stats I got this, which is really weird because I have only sent 12 messages (and not 75) <img width="701" height="730" alt="Image" src="https://github.com/user-attachments/assets/dec7e2bd-45b7-4ce8-a259-dc5e8d78ba9c" />
Author
Owner

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

and u only used fireworks in opencode? that usage couldn’t be from elsewhere?

That big of a gap just doesnt make sense UNLESS the session that this happened in had a bunch of subagent calls?

Rn it only shows the parent totals instead of including subagent costs and token usage

@rekram1-node commented on GitHub (Dec 22, 2025): and u only used fireworks in opencode? that usage couldn’t be from elsewhere? That big of a gap just doesnt make sense UNLESS the session that this happened in had a bunch of subagent calls? Rn it only shows the parent totals instead of including subagent costs and token usage
Author
Owner

@abdurahmanshiine commented on GitHub (Dec 23, 2025):

and u only used fireworks in opencode? that usage couldn’t be from elsewhere?

Yes, I actually created one Fireworks account specifically to use it with OpenCode, and I didn't use any subagents (I didn't even know how to invoke them until I checked now 😅 )

Not sure if it changes anything, but most of the messages in the convo (~10 of them) were using the planning mode, and only 2-3 used building mode

@abdurahmanshiine commented on GitHub (Dec 23, 2025): > and u only used fireworks in opencode? that usage couldn’t be from elsewhere? Yes, I actually created one Fireworks account specifically to use it with OpenCode, and I didn't use any subagents (I didn't even know how to invoke them until I checked now 😅 ) Not sure if it changes anything, but most of the messages in the convo (~10 of them) were using the planning mode, and only 2-3 used building mode
Author
Owner

@coreyward commented on GitHub (Jan 9, 2026):

Rn it only shows the parent totals instead of including subagent costs and token usage

@rekram1-node Yikes. That caught me off guard as well. I set up a brand new key to use OpenCode with Claude Opus 4.5 via API. I sent a single prompt/request in plan mode and it used a bunch of subagents to gather context. The TUI reported this as $0.16 of usage. The Anthropic billing dashboard, however, reported as $2.14. That's 13× the reported price.

Image Image
@coreyward commented on GitHub (Jan 9, 2026): > Rn it only shows the parent totals instead of including subagent costs and token usage @rekram1-node Yikes. That caught me off guard as well. I set up a brand new key to use OpenCode with Claude Opus 4.5 via API. I sent a single prompt/request in plan mode and it used a bunch of subagents to gather context. The TUI reported this as $0.16 of usage. The Anthropic billing dashboard, however, reported as $2.14. That's 13× the reported price. <img width="142" height="90" alt="Image" src="https://github.com/user-attachments/assets/e878a00e-e478-4542-a173-84ced0aabb01" /> <img width="425" height="189" alt="Image" src="https://github.com/user-attachments/assets/090a643b-66c8-4014-b578-7e5e75ae7f53" />
Author
Owner

@yassine-safraoui commented on GitHub (Jan 27, 2026):

I ran into a similar bug, but it's a little more specific. I was in a thread and decided to fork it from a certain message, then I started using a different model in the new fork. As I kept using the fork thread, I noticed the total price actually started decreasing. It looks like the math is flipped—instead of adding the cost of the new messages to the total, the system is performing a minus operation, so the more I talk, the "cheaper" the thread gets. Definitely seems like there's a bug in how the cost is being calculated, not sure what the root cause of. this is.

@yassine-safraoui commented on GitHub (Jan 27, 2026): I ran into a similar bug, but it's a little more specific. I was in a thread and decided to fork it from a certain message, then I started using a different model in the new fork. As I kept using the fork thread, I noticed the total price actually started decreasing. It looks like the math is flipped—instead of adding the cost of the new messages to the total, the system is performing a minus operation, so the more I talk, the "cheaper" the thread gets. Definitely seems like there's a bug in how the cost is being calculated, not sure what the root cause of. this is.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3746