[Feature Request]: add flag to see usage when using opencode run #2191

Open
opened 2026-02-16 17:34:35 -05:00 by yindo · 14 comments
Owner

Originally created by @FarrukhCyber on GitHub (Oct 20, 2025).

Originally assigned to: @FarrukhCyber on GitHub.

Question

In the opnecode's interactive mode, the token usage and cost is shown on top right corner. Is there a way to get the same when running it in non-interactive mode such that at the end of execution it gives total cost and token usage?

Originally created by @FarrukhCyber on GitHub (Oct 20, 2025). Originally assigned to: @FarrukhCyber on GitHub. ### Question In the opnecode's interactive mode, the token usage and cost is shown on top right corner. Is there a way to get the same when running it in non-interactive mode such that at the end of execution it gives total cost and token usage?
yindo added the discussion label 2026-02-16 17:34:35 -05:00
Author
Owner

@rekram1-node commented on GitHub (Oct 20, 2025):

@FarrukhCyber are you trying to see it in ci? Or what's the environment you are running it in, there may already be a way for you to do this using opencode export but that's prolly not ideal

@rekram1-node commented on GitHub (Oct 20, 2025): @FarrukhCyber are you trying to see it in ci? Or what's the environment you are running it in, there may already be a way for you to do this using `opencode export` but that's prolly not ideal
Author
Owner

@FarrukhCyber commented on GitHub (Oct 20, 2025):

I run opencode run <prompt> inside a python script

@FarrukhCyber commented on GitHub (Oct 20, 2025): I run `opencode run <prompt>` inside a python script
Author
Owner

@rekram1-node commented on GitHub (Oct 20, 2025):

@FarrukhCyber would you like some flag on opencode run that would print usage to stdout or a file or something

@rekram1-node commented on GitHub (Oct 20, 2025): @FarrukhCyber would you like some flag on opencode run that would print usage to stdout or a file or something
Author
Owner

@FarrukhCyber commented on GitHub (Oct 20, 2025):

yes ideally. Is this feature available?

@FarrukhCyber commented on GitHub (Oct 20, 2025): yes ideally. Is this feature available?
Author
Owner

@rekram1-node commented on GitHub (Oct 20, 2025):

Not yet :)

just wanted to confirm what you wanted

@rekram1-node commented on GitHub (Oct 20, 2025): Not yet :) just wanted to confirm what you wanted
Author
Owner

@FarrukhCyber commented on GitHub (Oct 21, 2025):

@rekram1-node I would be happy to implement this feature and open a PR. I'm not sure if this comes under core feature because contribution policy states that core feature requires a design review with the core team before implementation.

@FarrukhCyber commented on GitHub (Oct 21, 2025): @rekram1-node I would be happy to implement this feature and open a PR. I'm not sure if this comes under core feature because contribution policy states that core feature requires a design review with the core team before implementation.
Author
Owner

@rekram1-node commented on GitHub (Oct 21, 2025):

i think a pr would be good, I should reword that to not sound so strict.

Edit: ill just assign to u so ppl know u wanted to work on it

@rekram1-node commented on GitHub (Oct 21, 2025): i think a pr would be good, I should reword that to not sound so strict. Edit: ill just assign to u so ppl know u wanted to work on it
Author
Owner

@rekram1-node commented on GitHub (Oct 21, 2025):

I also reworded the contributing guidelines to sound a little less "strict": https://github.com/sst/opencode/blob/dev/CONTRIBUTING.md#contributing-to-opencode

@rekram1-node commented on GitHub (Oct 21, 2025): I also reworded the contributing guidelines to sound a little less "strict": https://github.com/sst/opencode/blob/dev/CONTRIBUTING.md#contributing-to-opencode
Author
Owner

@FarrukhCyber commented on GitHub (Oct 22, 2025):

@rekram1-node Do you think this feature can be implemented using just a plugin?

@FarrukhCyber commented on GitHub (Oct 22, 2025): @rekram1-node Do you think this feature can be implemented using just a plugin?
Author
Owner

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

We don't have a great way to indicate if the run is headless or not so Idk how the plugin would be able to surface it unless you just wanted to write it to a file

@rekram1-node commented on GitHub (Oct 22, 2025): We don't have a great way to indicate if the run is headless or not so Idk how the plugin would be able to surface it unless you just wanted to write it to a file
Author
Owner

@sheldonhull commented on GitHub (Dec 10, 2025):

To confirm even if I provide the approx cost in a custom provider and model setup in my config, when running headless, there is no current method to have it output total tokens/cost at the end correct?

And is this possible if I explore the typescript SDK, or something that just isn't exposed currently without feature work on it?

@sheldonhull commented on GitHub (Dec 10, 2025): To confirm even if I provide the approx cost in a custom provider and model setup in my config, when running headless, there is no current method to have it output total tokens/cost at the end correct? And is this possible if I explore the typescript SDK, or something that just isn't exposed currently without feature work on it?
Author
Owner

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

when running headless, there is no current method to have it output total tokens/cost at the end correct?

You can do --format json

And is this possible if I explore the typescript SDK, or something that just isn't exposed currently without feature work on it?

If you are using an sdk you should have everything you need to get cost info

@rekram1-node commented on GitHub (Dec 10, 2025): > when running headless, there is no current method to have it output total tokens/cost at the end correct? You can do `--format json` > And is this possible if I explore the typescript SDK, or something that just isn't exposed currently without feature work on it? If you are using an sdk you should have everything you need to get cost info
Author
Owner

@FarrukhCyber commented on GitHub (Jan 28, 2026):

To confirm even if I provide the approx cost in a custom provider and model setup in my config, when running headless, there is no current method to have it output total tokens/cost at the end correct?

And is this possible if I explore the typescript SDK, or something that just isn't exposed currently without feature work on it?

@sheldonhull were you able to get the cost and token consumption through headless or sdk method?

@FarrukhCyber commented on GitHub (Jan 28, 2026): > To confirm even if I provide the approx cost in a custom provider and model setup in my config, when running headless, there is no current method to have it output total tokens/cost at the end correct? > > And is this possible if I explore the typescript SDK, or something that just isn't exposed currently without feature work on it? @sheldonhull were you able to get the cost and token consumption through headless or sdk method?
Author
Owner

@FarrukhCyber commented on GitHub (Jan 28, 2026):

when running headless, there is no current method to have it output total tokens/cost at the end correct?

You can do --format json

And is this possible if I explore the typescript SDK, or something that just isn't exposed currently without feature work on it?

If you are using an sdk you should have everything you need to get cost info

@rekram1-node There is no opencode python SDK right?

@FarrukhCyber commented on GitHub (Jan 28, 2026): > > when running headless, there is no current method to have it output total tokens/cost at the end correct? > > You can do `--format json` > > > And is this possible if I explore the typescript SDK, or something that just isn't exposed currently without feature work on it? > > If you are using an sdk you should have everything you need to get cost info @rekram1-node There is no opencode python SDK right?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2191