Skip to content

feat(quota): show OpenCode Go remaining from official /zen/go/v1/usage - #491

Open
Adam-Dalloul wants to merge 10 commits into
xintaofei:mainfrom
Adam-Dalloul:feat/opencode-go-remaining-quota
Open

feat(quota): show OpenCode Go remaining from official /zen/go/v1/usage#491
Adam-Dalloul wants to merge 10 commits into
xintaofei:mainfrom
Adam-Dalloul:feat/opencode-go-remaining-quota

Conversation

@Adam-Dalloul

Copy link
Copy Markdown

Merge order

  1. #472 then #481 then #490
  2. Then this PR

This branch already contains those. Merge them first so this reviews as the OpenCode Go delta.


OpenCode stats is still just session history. The Go plan remaining API shipped 2026-08-11 (anomalyco/opencode#16513): GET https://opencode.ai/zen/go/v1/usage with the existing Go API key.

I hit it without a key from here: 401 Missing API key (and /zen/go/v1/models is 200, so the host is live). The official handler returns { usage.rolling|weekly|monthly: { percent, resetsAt } }. percent is used 0-100.

This reads the key from OpenCode auth.json (opencode-go, then opencode) or OPENCODE_GO_API_KEY. No Go plan / 401 / 403 stays unavailable and links the Go page. We do not invent a number and we do not scrape the dashboard.

Token Usage now lists isolatable families. Remaining plan quota is
emitted only from a recorded official remaining-subscription envelope.
ACP usage_update stays context occupancy. Families without a payload
link to the provider usage page instead of inventing a number.
Codex remaining comes from documented app-server account/rateLimits/read.
Claude remaining comes from the /usage HUD five_hour utilization payload.
Other families still link to the provider page instead of inventing a number.
subscription-quota now calls official `codex app-server --stdio`
`account/rateLimits/read` and parses the live envelope (primary
usedPercent, window, reset, extra limit ids).

Local CLI check: Claude `auth status` and `claude -p /usage` do not
publish remaining plan quota. Grok has no usage command. OpenCode
`stats` is historical cost, not remaining. Those rows stay links.
There is no `claude usage` CLI. Live `GET /api/oauth/usage` with the local
Claude Code OAuth token returns five_hour / seven_day utilization as 0-100
percents. That is the HUD payload community monitors already parse.

The panel fetches it next to Codex. Utilization is not treated as a 0-1
fraction. Weekly and extra-usage windows show as extras. Tokens are never
logged.
Live `GET /v1/billing?format=credits` on cli-chat-proxy.grok.com with the
Grok CLI OAuth token returns config.creditUsagePercent. The panel fetches
that next to Codex and Claude. Tokens and emails are never logged.

Gemini and OpenCode still have no remaining-quota command.
Cursor has no usage CLI. Parse planUsage from the same
GetCurrentPeriodUsage RPC the official client already ships.
Signed-in Ultra session returned planUsage remaining/limit 40000
and totalPercentUsed 0. Parse billingCycleEnd as reset time.
Shipped 2026-08-11 in anomalyco/opencode#16513. percent is used
0-100 across rolling/weekly/monthly. No invented numbers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant