Repository navigation
[FEATURE] Add unified usage tracking via /usage (#9545) #9281
Description
Activity
github-actions commented
on Jan 18, 2026 on Jan 18, 2026 – with GitHub ActionsContributorMore actionsThis issue might be a duplicate of existing issues. Please check:
- Github Copilot: Tracking Premium Requests #768: Github Copilot: Tracking Premium Requests - requests tracking for Copilot provider usage quota
Feel free to ignore if none of these address your specific case.
CasualDeveloper commented
on Jan 18, 2026 ContributorAuthorMore actionsThanks for the pointer. Related to #768 for Copilot quota visibility, but this issue is broader: adds a unified /usage API + TUI surfaces for codex/copilot/claude (including 5h/7d/Opus 7d windows) and is not limited to Copilot premium requests. I'll keep #768 referenced here.
AI Assistance: OpenCode + openai/gpt-5.2-codex; human reviewed.
Reacted by Dmitry Gordienko, Salloxy and Wiktor GoliczHey made an pr about this with images check it out :)
so copilot we need a separate authentication flow since uage data is is not accessible through the one in auth.json and also added antigravity for the plugin Antigravity + Gemini CLI OAuth Plugin for Opencode due to large popularityReacted by Stephen Collings, Dekai Li and Benoit de Chezelles- marked [FEATURE]:add the copilot remaining request #9509 as a duplicate of this issue
on Jan 19, 2026 41 remaining items
Workaround: my plugin solves this for most providers: https://github.com/slkiser/opencode-quota
Reacted by Dmitry Gordienko and mariusdillReacted by Ivan UhalinCasualDeveloper commented
on Apr 18, 2026 ContributorAuthorMore actionsRebased
#9545onto the latestdevagain.Still applies on current
server/routes/instance/server layout andtui.json-backed TUI config architecture. Verified locally withbun run typecheck,bun turbo typecheck, andbun --cwd packages/opencode test --timeout 600000 test/plugin/copilot-auth.test.ts test/server/usage.test.ts test/server/usage-copilot.test.ts test/cli/tui/usage-command.test.ts test/cli/tui/usage-format.test.ts test/cli/tui/usage-toast.test.ts(48 tests pass).If maintainers want a different direction, happy to rework it.
Workaround: my plugin solves this for most providers: slkiser/opencode-quota
also, whoa @slkiser - good work, that provider coverage is wide! lol
IMO our approaches are complementary - users can pick either: the broader coverage your plugin offers (13+ providers), or mine which covers a narrower set (OpenAI/Anthropic/GitHub) as a built-in with first-party OAuth flows only (no PATs / CLI shell-outs / scraping), so those three work out-of-box with no separate install step :P
Structure's provider-based too (one file per provider under
src/usage/providers/+ a central registry), so the core set can grow, or maybe expose a plugin hook later that lets plugins like yours register their own providers into the same sidebar //usage/ toast pipeline. :)CasualDeveloper commented
on Apr 26, 2026 ContributorAuthorMore actionsFork updated to sync with
dev(as of5a5a2e5fa) and pushed at3db7c0eb8.Recent behavior cleanup:
/usagenow always fetches all authenticated usage providers and opens the detail dialog./usage --used//usage --remainingonly select display mode./usage --refreshrefreshes all provider caches and updates the sidebar without opening the dialog.tui.show_usage_provider_scopeis sidebar-only now; the dialog is the detailed all-provider view.- The sidebar no longer relies on
usage.updatedevent/SSE refresh./usageand end-of-turn refresh explicitly refetch the shared sidebar resource to avoid the previous feedback-loop risk.
Scope clarification: this PR adds shared backend/API + SDK support and terminal TUI surfaces. Web/app UI is intentionally left for a follow-up, likely as a Usage tab in the existing top-right status popover rather than a custom side panel.
Verified with
./script/generate.ts,bun turbo typecheck, and the targeted usage suite (48 tests pass).the /usage endpoint being the single source of truth is the right call. the trap people fall into is parsing rate-limit headers or counting local tokens, then their numbers drift from what claude.ai actually shows. ccusage reads jsonl logs, claude-code-usage-monitor estimates, neither sees the server quota anthropic actually enforces. only the internal endpoint that powers claude.ai/settings/usage gives you the real 5h and weekly windows. one note on the 401 question, claude's session cookie expires silently and you wont know until the next fetch returns nothing useful, surfacing a reauth hint inline beats a refresh loop because the cookie path is browser-bound anyway.
Quick update: the fork branch has been refreshed and synced to origin/dev at 4519a1d.
CasualDeveloper commented
on Jul 27, 2026 ContributorAuthorMore actionsRefreshed #9545 to
805bc10ce4.The latest follow-up removes persistent usage cache files in favor of a process-local active-credential cache. Cache writes recheck current auth before replacing a superseded identity, so late requests cannot displace current data. Copilot now reports GitHub's independent
credits_usedAI-credit meter separately from entitlement-based quota percentages.Verification: workspace typecheck 30/30, focused server/API tests 100/100, TUI 223 passed with 1 skip, and HttpApi coverage/auth/effect modes 209/209 each. The PR body has the current scope and commands.
github-actions commented
on Sep 26, 2026 on Sep 26, 2026 – with GitHub ActionsContributorMore actionsTo stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.
Reacted by Benoit de ChezellesStill reproducible in OpenCode v2.0.18 on macOS 26.6 (arm64), using Ghostty and zsh.
With OpenAI ChatGPT OAuth, OpenCode’s
/statusdoes not show the subscription usage windows available in Codex. Codex’s/statusreports the consumed allowance and reset times for the rolling and weekly limits, while OpenCode provides no equivalent information.opencode stats --costis not a workaround: it reports locally recorded token and cost statistics, not the remaining provider-side subscription allowance or its reset times.It would be useful to expose these provider-reported limits through
/statusor/usage, clearly separated from session context usage and local cost estimates. This would let users anticipate rate limits without leaving the TUI.Environment:
- OpenCode: v2.0.18, latest release
- OS: Darwin 25.6.0, arm64
- Terminal: Ghostty, xterm-256color, truecolor
- Shell: zsh
- Active local plugin:
herdr-agent-state.js(unrelated)
Describe the enhancement you want to request
When you sign in to opencode with an OAuth provider, there's no built-in way to see how much of your plan or rate limit you've used. You have to open each provider's dashboard. I'd like usage to be visible inside opencode for the providers it already authenticates.
The feature now covers:
GET /usageendpoint that returns a normalized snapshot per provider (rate-limit windows, reset times, credits or quota, and plan type), each with a status such asok,stale, orunauthenticated./usageTUI dialog and a sidebar Usage section, with config for provider scope and whether to show used or remaining. End-of-turn refresh is throttled and only warns at 80/90/95%.