You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature] Token Usage & Cost Indicator per Response #756
Display a small, subtle token count (and estimated cost, if applicable) at the bottom of every AI response.
Use Case
When using paid APIs (like OpenRouter or OpenAI), developers are highly sensitive to token usage. A small indicator helps them build an intuition for how much context they are sending and when they need to clear their session to save money.
Proposed Solution
Append a tiny, grayed-out string like (Tokens: 4.2k | ~$0.01) at the bottom of the AI's chat bubble (in the extension) or terminal output (in the CLI).
Alternatives Considered
Only showing it in a separate "Usage" tab, but placing it inline with the response is much more helpful for immediate feedback.
Additional Context
I have searched existing issues to ensure this is not a duplicate
This feature aligns with the project's goals (local-first AI assistance)
Implementation Notes (optional)
Most LLM API responses (via Vercel AI SDK) include a usage object in the response payload.
In the VS Code extension, this can be injected directly into the DOM below the messages-container.
Contribution Guidelines
If you would like to work on this issue, please comment below to ask for assignment first.
Before opening a Pull Request, please briefly share your implementation plan in this thread so we can align on the approach!
Before I assign this issue, could you briefly share your implementation plan? I'd like to understand how you're planning to tackle it and ensure we're aligned on the approach.
Also, please make sure to follow the repository's contributing guidelines. Looking forward to your plan!
In conversation-loop.tsx, result.usage (provider-reported tokens per API call) is already in scope where AssistantMessage is queued - pass it as a new optional prop.
Compute cost with the existing getModelPricing() helper (models.dev rates, cached); omit cost when pricing is unavailable (local models like Ollama).
In AssistantMessage, upgrade the existing gray ~N tokens footer to show real usage + cost, e.g. Tokens: 4.2k | ~$0.01; fall back to the current estimate when the provider reports no usage.
Add compact-number/cost formatters with unit tests, update component specs, add a minor changeset.
For Extension:
the extension's chat runs over ACP, and agent_message_chunk has no usage field - so the CLI side must send usage over the protocol (e.g. _meta on the final chunk or a dedicated update), and the webview renders the gray line under each message.
Questions:
Per API call or per turn? One user prompt can trigger several API calls in agentic tool loops. Should each rendered assistant message show its own call's usage, or should the whole turn's usage be aggregated into one indicator at the end?
Activity
lakshay-2411 commentedon Aug 3, 2026
Can I work on this? @akramcodez
akramcodez commentedon Aug 3, 2026
Thanks for your interest, @lakshay-2411!
Before I assign this issue, could you briefly share your implementation plan? I'd like to understand how you're planning to tackle it and ensure we're aligned on the approach.
Also, please make sure to follow the repository's contributing guidelines. Looking forward to your plan!
lakshay-2411 commentedon Aug 4, 2026
Brief approach
For CLI:
For Extension:
the extension's chat runs over ACP, and agent_message_chunk has no usage field - so the CLI side must send usage over the protocol (e.g. _meta on the final chunk or a dedicated update), and the webview renders the gray line under each message.
Questions:
Per API call or per turn? One user prompt can trigger several API calls in agentic tool loops. Should each rendered assistant message show its own call's usage, or should the whole turn's usage be aggregated into one indicator at the end?
akramcodez commentedon Aug 5, 2026
@lakshay-2411 Great, you're assigned to this issue. Let me know if you need any help.
lakshay-2411 commentedon Aug 5, 2026
#796