Skip to content

[FEATURE]: Public API for Go plan usage/limits #31084

Closed
steipete/CodexBar
#2879

Description

@TiceWise
  • I have checked that this feature hasn't been suggested before

Problem

OpenCode Go plan users can only check their usage limits (rolling 5h, weekly, monthly) via the interactive web console at https://opencode.ai. There's no programmatic way to monitor usage from the CLI.

Use case

  • CLI tools/dashboards that show Go usage alongside other metrics
  • Automated alerts when approaching limits
  • Local dashboard integration (like the opencode-sessions project)

Current alternatives

  • opencode stats shows session-level costs from the local DB, but can't match server-side sliding windows (especially the 5h rolling window which is tied to the server's timeUpdated, not "last 5 hours")
  • Browser automation to scrape the workspace page (brittle, requires session cookies)

Suggested API

A simple endpoint accessible with the existing Go API key:

GET https://opencode.ai/zen/go/v1/usage
Authorization: Bearer sk-...

{
  "rolling5h": { "usageDollars": 2.34, "limitDollars": 12, "usagePercent": 19.5, "resetInSec": 7200 },
  "weekly":    { "usageDollars": 8.91, "limitDollars": 30, "usagePercent": 29.7, "resetInSec": 345600 },
  "monthly":   { "usageDollars": 15.00, "limitDollars": 60, "usagePercent": 25.0, "resetInSec": 1414800 },
  "subscribedAt": "2026-05-22T14:30:00Z"
}

The server already computes this via Subscription.analyzeRollingUsage / analyzeWeeklyUsage / analyzeMonthlyUsage — it's just not exposed outside the console SPA.

Would be a small but high-value addition. Thanks!

Activity

  1. github-actions commented on Jun 6, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • Feature requests must use the [FEATURE]: prefix in the title (e.g., [FEATURE]: Public API for Go plan usage/limits)
    • The feature request template requires checking the verification checkbox confirming the feature hasn't been suggested before

    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.

  2. changed the title [-]Feature request: Public API for Go plan usage/limits[/-] [+][FEATURE]: Public API for Go plan usage/limits[/+] on Jun 6, 2026
  3. github-actions commented on Jun 6, 2026

    @github-actions
    Contributor

    Thanks for updating the issue! It now meets our contributing guidelines. We appreciate the clear description and well-structured feature request.

  4. TiceWise commented on Jun 6, 2026

    @TiceWise
    Author

    Duplicate of #16017 — adding my support there.

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