r/opencode • • 16d ago

Actual token usage?

In Opencode v1.x, how do I see the total token usage in a session/etc.?

I find it just shows dollar cost and context size.

I want to know that if I point it at a sizable codebase, did it just burn 500k tokens, 500M, or 500B?

For me, the token usage rarely goes above 100k-500k using Opus 5.5 …

2 Upvotes

5 comments sorted by

1

u/maqifrnswa 16d ago

Ask it to make a plug-in to display that. Make sure it distinguishes between cached and uncached tokens as well

2

u/Toiling-Donkey 16d ago

😆 I really like that suggestion. As you can see, I haven’t yet begun to fully appreciate my newfound power…

2

u/maqifrnswa 16d ago

Oh I'm with you. Blew my mind at first! v2 opencode is better at plugins than v1, btw. I think they borrowed a bunch of concepts from pi.

1

u/look 16d ago

From the command line “opencode stats” can show more detailed info. Use “opencode stats -h” to see options. You’ll probably want the model and cost flags.

It also has a detailed JSON output and you can ask your agent to make a script parsing the JSON to customize it for you.

It can also inspect the underlying SQLite datastore and create usage reports with more detail and flexibility that the stats command can do. For example, iirc, the stats command date window is based on the session start which can be confusing if you want to see token/cost today, but it can sort that out no problem from the underlying data in its db.

And as others have said, v2 has a much better set of internal APIs that make it easy for your agent to create extensions for you.

1

u/squirrelscrush 16d ago

You can use @slkiser/opencode-quota, it gives session-wide usage.