GeezerVison is showing github.com — [FEATURE]: Add Go plan usage/balance API endpoint (rolling/weekly/monthly windows) · Issue #16017 · anomalyco/opencode
[FEATURE]: Add Go plan usage/balance API endpoint (rolling/weekly/monthly windows) #16017DescriptionFeature hasn't been suggested before.
- I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
Summary
Expose the Go plan subscription usage data via a public API endpoint. The dashboard already shows this information — rolling, weekly, and monthly usage percentages with reset timers — but there is no way to query it programmatically.
Use Case
- Status bar widgets (waybar, polybar, macOS menu bar) showing current usage
- Alerts when approaching plan limits before getting throttled
- Monitoring dashboards aggregating usage across providers and plans
- CI/CD pipelines checking remaining quota before kicking off expensive runs
Current Behavior
The only way to see Go plan usage is the web dashboard, which displays:
- Rolling usage: x% (resets in N minutes)
- Weekly usage: y% (resets in N minutes)
- Monthly usage: z% (resets in N minutes)
No API endpoint exists to retrieve this data.
Proposed API
GET /api/v1/usage/plan
Authorization: Bearer <api-key>
Response:
{
"plan": "go",
"windows": {
"rolling": {
"usage_percent": 65,
"resets_in_seconds": 2520
},
"weekly": {
"usage_percent": 30,
"resets_in_seconds": 259200
},
"monthly": {
"usage_percent": 12,
"resets_in_seconds": 1728000
}
}
}
Related Issues
Additional Context
The Go plan's rolling/weekly/monthly usage windows are a distinct data model from the Zen credit balance (#10448) and provider-level quotas (#9281). The server already computes this data for the dashboard, so exposing it via API should be a relatively small addition. Reacted by Arif Rahman (Bolt), EremesNG, Ryan, Ata Yıkılmaz, Oleksandr, Jiyeol Lee, Josh Klar, Filipe, Almendio, Withee Poositasai and 128 more Activityadded coreAnything pertaining to core functionality of the application (opencode server stuff) on Mar 4, 2026github-actions commented on Mar 4, 2026
This issue doesn't fully meet our contributing guidelines.
What needs to be fixed:
- Feature request titles must start with
[FEATURE]: (current title: "Feature Request: Add Go plan usage/balance API endpoint...")
- The feature request template includes a verification checkbox confirming you've searched for existing issues — please ensure this is included
Please edit this issue to address the above within 2 hours, or it will be automatically closed.
This issue might be a duplicate of existing issues. Please check:
If you believe this was flagged incorrectly, please let a maintainer know. changed the title [-]Feature Request: Add Go plan usage/balance API endpoint (rolling/weekly/monthly windows)[/-] [+][FEATURE]: Add Go plan usage/balance API endpoint (rolling/weekly/monthly windows)[/+] on Mar 4, 2026github-actions commented on Mar 4, 2026 Thanks for updating the issue! It now meets our contributing guidelines — the title has been corrected to start with [FEATURE]: and the verification checkbox is checked. We appreciate you taking the time to fix it. github-actions commented on Mar 4, 2026 Thanks for updating the issue! It now meets our contributing guidelines — the title has been corrected, the verification checkbox is checked, and the description clearly explains the use case and need. Much appreciated! peculiarnewbie commented on Mar 7, 2026 submitted a pr #16513. but i don't think can test this locally, so it's not meeting compliance @thdxr StephanMeijer commented on Mar 8, 2026 alansong63 commented on Apr 28, 2026 +1. Would love to see this implemented. My use case: integrating Go plan usage tracking into an AI agent CLI as a quick command. Having rolling/weekly/monthly usage data accessible via API (e.g. GET /zen/go/v1/usage) would enable real-time monitoring without the web dashboard. Reacted by perzarys, dkellam44, Hicham el Allouchi, Luis Herrera, gui-bo and Taylor Rackley LuisHerreraG commented on May 2, 2026 +1, I would like it too to programmatically check it in a helper script or even inside of OpenCode itself! slkiser commented on May 2, 2026 If you need a workaround is possible with OpenCode Quota: for OpenCode Go you just have to provide a workspace ID and auth cookie. Reacted by jiziol, gui-bo and orzogc OCPdev25 commented on Jul 9, 2026 Adding one concrete downstream use case in support of this issue and PR #16513.
quota-axi is a small read-only quota reporter used by agents before they decide whether to start expensive work. For OpenCode Go, the useful integration point is exactly a machine-readable endpoint keyed by the existing Go API key, not a dashboard scrape or browser cookie flow.
The ideal response for agent routing would include the same three windows the dashboard already computes:
- rolling or 5 hour usage percent plus reset time
- weekly usage percent plus reset time
- monthly usage percent plus reset time
- optional spent and limit values in USD, if available from the same server-side counters
Two constraints matter for agent tooling:
- read-only: checking quota should not create model usage or mutate provider state
- cookie-free: API key auth lets CLIs, status bars, and automation avoid browser-cookie import
The proposed /zen/go/v1/usage shape in #16513 looks like the right direction because it reads LiteTable usage counters and uses the same Subscription.analyze*Usage logic as the workspace dashboard. Reacted by Zachary Cutlip, Arif Rahman (Bolt) and Dan Wright kevincojean commented on Jul 14, 2026 markbus-ai commented on Aug 1, 2026 +1 from the Omarchy side (a Linux desktop distro): our bar widget already renders Claude Code and Codex usage with rolling/weekly/monthly meters (usagePercent, reset countdown, alarm at 90%). OpenCode's local opencode.db gives us token totals, but not the plan windows — so the widget can't show what actually stops the next prompt.
A single REST endpoint like /go/usage returning { rollingUsage: { usagePercent, resetInSec, limit }, weeklyUsage: {...}, monthlyUsage: {...} } would unblock us (and dashboards/CLI tools) with zero browser login — same auth as /zen/v1/models.
@thdxr is this on the roadmap? Happy to help spec it or test an early version — 37signals' DHH pointed at this exact need when we upstreamed an OpenCode provider, so there's real consumer demand. Reacted by Lorenzo Strambi, Raul Abreu, Arif Rahman (Bolt), Sami Rautiainen and BZ candu commented on Aug 2, 2026 +1: I often keep the OpenCode Go page open and refresh every so often, but would much prefer to have e.g. a plugin in opencode that shows me usage against limits right where I'm working.
I'd imagine the visibility would also be interesting to orgs that track AI usage / spend internally. slkiser commented on Aug 2, 2026 PowerfulShell commented on Aug 4, 2026 been waiting too long since March... PowerfulShell commented on Aug 4, 2026 when will this be done? server side issue....
just make this endpoint.. bertrell commented on Aug 5, 2026 +1 — running opencode serve as a persistent backend for multiple clients (browser, phone, SSH) sharing one Go API key. Heavy parallel use burns the 5h cap fast with zero visibility from the TUI. Currently forced to keep a browser tab on the workspace page or switch to the free tier when limits hit. Would especially love a TUI slash command (e.g. /usage) that shows the three windows with reset timers. 0pilatos0 commented on Aug 5, 2026 +1 exactly what I need for monitoring my Go subscription usage PowerfulShell commented on Aug 6, 2026 why not now? been 5 months. artile commented on Aug 7, 2026 +1, with a gateway use case that the ones above do not cover.
We run a self-hosted multi-provider gateway (CLIProxyAPI) in front of several coding agents. A Go key is one credential in a pool the router picks from. The router reads per-request token counts from the usage object in the chat/completions response, but it has no way to know how much of the plan is left, so it cannot steer traffic away from Go before the cap is reached. It only finds out at the 429, mid-request, and the whole pool stalls.
There is no in-band signal to fall back on either. Checked from outside today: GET /zen/go/v1/usage, /zen/v1/usage and /zen/go/v1/balance all return the SPA 404 HTML, and normal responses carry no X-RateLimit-* headers.
Recomputing the meter on the client side is not a substitute. We can multiply token counts by the published per-model rates, but that number drifts from what the dashboard reports, as shown in #40280 ($12.42 tracked against $19.20 displayed). Only the server knows its own accounting.
What would be enough for us is the shape already proposed here: the three windows with usage_percent (or remaining USD) and a reset timestamp, authenticated with the plain API key. The workspace-ID plus session-cookie route that opencode-quota uses works for a desktop, but it is not something a headless server can hold. Rate-limit headers on ordinary responses would cover most of the need as well, and would be cheaper to ship. Reacted by victor, Arif Rahman (Bolt), MiningInMySleep, blablup and Jeroen van Meerendonk PowerfulShell commented on Aug 12, 2026 when will it be possible....
its so simple, why take 5 months.... when please when.. and7ey commented on Sep 15, 2026
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|