Skip to content

[FEATURE]: Add Go plan usage/balance API endpoint (rolling/weekly/monthly windows) #16017

Closed

Description

@StephanMeijer

Feature 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.

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 4, 2026
  2. github-actions commented on Mar 4, 2026

    @github-actions
    Contributor

    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.

  3. 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, 2026
  4. github-actions commented on Mar 4, 2026

    @github-actions
    Contributor

    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.

  5. github-actions commented on Mar 4, 2026

    @github-actions
    Contributor

    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!

  6. peculiarnewbie commented on Mar 7, 2026

    @peculiarnewbie
    Contributor

    submitted a pr #16513. but i don't think can test this locally, so it's not meeting compliance @thdxr

  7. StephanMeijer commented on Mar 8, 2026

    @StephanMeijer
    Author

    Thanks!

  8. assigned and unassigned on Apr 26, 2026
  9. alansong63 commented on Apr 28, 2026

    @alansong63

    +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.

  10. LuisHerreraG commented on May 2, 2026

    @LuisHerreraG

    +1, I would like it too to programmatically check it in a helper script or even inside of OpenCode itself!

  11. slkiser commented on May 2, 2026

    @slkiser

    If you need a workaround is possible with OpenCode Quota: for OpenCode Go you just have to provide a workspace ID and auth cookie.

  12. 26 remaining items

  13. PowerfulShell commented on Aug 4, 2026

    @PowerfulShell

    been waiting too long since March...

  14. PowerfulShell commented on Aug 4, 2026

    @PowerfulShell

    when will this be done? server side issue....
    just make this endpoint..

  15. bertrell commented on Aug 5, 2026

    @bertrell

    +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.

  16. 0pilatos0 commented on Aug 5, 2026

    @0pilatos0

    +1 exactly what I need for monitoring my Go subscription usage

  17. PowerfulShell commented on Aug 6, 2026

    @PowerfulShell

    why not now? been 5 months.

  18. artile commented on Aug 7, 2026

    @artile

    +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.

  19. PowerfulShell commented on Aug 12, 2026

    @PowerfulShell

    when will it be possible....
    its so simple, why take 5 months.... when please when..

  20. and7ey commented on Sep 15, 2026

    @and7ey

    I've made small TUI plugin to display the stats - https://github.com/and7ey/opencode-go-usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions