Skip to content

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

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!

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