Skip to content

feat(console): add go usage endpoint - #16513

Merged
vimtor merged 3 commits into
anomalyco:devfrom
peculiarnewbie:go-usage-api
Aug 11, 2026
Merged

feat(console): add go usage endpoint#16513
vimtor merged 3 commits into
anomalyco:devfrom
peculiarnewbie:go-usage-api

Conversation

@peculiarnewbie

@peculiarnewbie peculiarnewbie commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #16017

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

this PR adds an API endpoint at /zen/go/v1/usage that will provide the same opencode go usage data as in the zen workspace dashboard.

If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!

How did you verify your code works?

unfortunately i don't think this is a change i can verify as an outside contributor. i did try running bun dev:remote but met with cloudflare api key error.
I did copy the pattern in /zen/v1/models and copied the logic from /workspace/[id]/billing/lite-section.tsx

Screenshots / recordings

not a ui change

Checklist

  • I have tested my changes locally
    i guess running dev server and building counts as testing? but yea i don't think i can test this feature locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 7, 2026
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 7, 2026
@github-actions

github-actions Bot commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@hendrixfreire

Copy link
Copy Markdown

Hey, any news on merging this?

@peculiarnewbie

Copy link
Copy Markdown
Contributor Author

no clue

@n-osennij

Copy link
Copy Markdown

+++

@patrezp

patrezp commented May 4, 2026

Copy link
Copy Markdown

I would like to see this implemented

@donrami

donrami commented May 9, 2026

Copy link
Copy Markdown

+1 for implementing this. In the meantime I'm using this hacky solution https://pi.dev/packages/pi-go-bars

@OmSoft-tech

Copy link
Copy Markdown

I would like to see this implemented

@slkiser

slkiser commented May 14, 2026

Copy link
Copy Markdown

Official support would be nice.

If you need usage and quota tracking in opencode, https://github.com/slkiser/opencode-quota

@n-osennij

Copy link
Copy Markdown

up

@m-saghir

Copy link
Copy Markdown

I'd employ this feature.

@matiasict

Copy link
Copy Markdown

+1

@Ksld154

Ksld154 commented May 19, 2026

Copy link
Copy Markdown

+1
really need this to check cross-device quota in OpenUsage

@hendrixfreire

hendrixfreire commented May 19, 2026

Copy link
Copy Markdown

Did they truly forget about this?

@robinebers

Copy link
Copy Markdown

Would really love this for OpenUsage. A lot of users keep asking, and the local SQL is unreliable.

@edsonboldrini

Copy link
Copy Markdown

+1

@igcodinap

Copy link
Copy Markdown

+1 pls merge this

@stevenup7

Copy link
Copy Markdown
  • 1 for this one, adding my name to the list of people wanting this, using @timm-u pi plugin but screen scraping feels pretty yuck

ltmoerdani pushed a commit to ltmoerdani/opencode-copilot-chat that referenced this pull request Aug 12, 2026
Pure, unit-testable module for the official OpenCode Go usage endpoint
(upstream anomalyco/opencode#16513, verified live in production):

- fetchGoUsage(): GET /zen/go/v1/usage with the existing opencode-go key as
  a Bearer token; classifies failures (unauthorized / no-subscription /
  not-found / network / invalid) so callers can fall back to local
  estimates. The key is never logged or persisted.
- mergeServerUsage(): overlays the server-accurate rolling/weekly/monthly
  percent + resetsAt onto a locally-computed UsageSummary. The endpoint
  does not return raw spend, so spent is derived as limit x percent / 100
  to keep the status bar and tooltip consistent; today/yesterday and
  per-session spend stay local.
- GO_LIMITS stays the source of the display limits (they match the
  server's ZEN_LIMITS).
duh17 added a commit to duh17/oppi that referenced this pull request Aug 15, 2026
OpenCode shipped a usage API (GET /zen/go/v1/usage, PR anomalyco/opencode#16513)
that reports percent-of-limit for the Go plan's rolling 5h, weekly, and monthly
windows. Wire it into GET /server/provider-quotas so Model Providers on Apple
clients shows OpenCode Go usage alongside Codex and xAI.

The adapter maps rolling/weekly/monthly to the shared five_hour/weekly/monthly
window DTOs (percent-only payload; dollar limits live server-side), reads the
stored opencode-go API key directly, and surfaces structured errors for missing
keys, inactive subscriptions (upstream 401), and invalid payloads. Shared the
ISO-to-epoch helper with xai via shared.ts.

Apple UI needs no changes: the client joins quotas by providerId and renders
windows generically; the opencode-go icon/color/name mappings already exist for
the model picker.

Agent-Model: opencode-go/glm-5.3
Agent-Reasoning: high
thinh0704hcm added a commit to thinh0704hcm/OmniRoute that referenced this pull request Aug 16, 2026
…ndpoint

The upstream OpenCode Go usage endpoint shipped in anomalyco/opencode#16513
(merged 2026-08-11): GET /zen/go/v1/usage returns { useBalance, rollingUsage,
weeklyUsage, monthlyUsage }, each { status, resetInSec, usagePercent } (0-100,
resets in seconds). Replace the placeholder /quota URL and parser with the real
shape (legacy shape kept as a defensive fallback). opencode-go finally gets
working 5h/weekly/monthly quota data for reset-window routing.
Adam-Dalloul added a commit to Adam-Dalloul/codeg that referenced this pull request Aug 22, 2026
Shipped 2026-08-11 in anomalyco/opencode#16513. percent is used
0-100 across rolling/weekly/monthly. No invented numbers.
JaminYe pushed a commit to JaminYe/pane that referenced this pull request Aug 24, 2026
anomalyco/opencode#16513 shipped GET /zen/go/v1/usage (2026-08-11) —
the endpoint the code comment said to swap to when it existed. The
card now shows Session/Weekly/Monthly percentages and resets counted
on OpenCode servers (same numbers as the Zen dashboard, other devices
and shared-subscription participants included), authenticated with the
Go key Pane already reads from auth.json.

The live wire shape differs from the merged PR draft — verified
against the deployed endpoint with a real key and pinned in a test:
usage.{rolling,weekly,monthly}.{status,percent,resetsAt}. The old
local-window computation stays as the fallback when the API is
unreachable; dollar spend remains local. README + providers.md drop
the "no public usage API yet" story.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

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