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

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

@rcambrj

rcambrj commented May 27, 2026

Copy link
Copy Markdown

This pull request is now second most wanted, by measure of 👍 reactions

Screenshot 2026-05-27 at 08 50 58

Opencode continues to see improvements and bugfixes, which I'm eternally grateful for, but I do wonder what's holding this up. It seems like a quick QOL improvement for your paying subscribers. Is there something which needs to be fixed, opencode maintainers?

bibhubhatta pushed a commit to bibhubhatta/ClaudeBar that referenced this pull request Aug 25, 2026
The local-DB probe only sees this machine's messages and guesses at the
server's cost accounting, so its numbers diverged from the opencode.ai
dashboard. opencode now exposes GET /zen/go/v1/usage (anomalyco/opencode#16513),
which returns the same rolling/weekly/monthly percentages and reset times
the dashboard shows.

- Add OpenCodeCredentialLoader: reads OPENCODE_API_KEY or the
  `opencode-go` / `opencode` entry from $XDG_DATA_HOME/opencode/auth.json
- Add OpenCodeAPIUsageProbe: calls the endpoint with a bearer key, maps
  used% -> remaining%, 401 -> sessionExpired, 403 -> subscriptionRequired
- Keep OpenCodeUsageProbe (local DB) as a fallback when no key is present

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CdVhUZgY4SKaYkuxdqR3AY
1056674754 added a commit to 1056674754/opencode that referenced this pull request Aug 31, 2026
Upstream v1.18.16 (a3647eb) -> v1.18.17 (02546df), 32 commits.

Functional changes:
- fix(compaction): clearer instructions for smaller models like dsv4 flash (anomalyco#42045)
- fix(provider): add Merge Gateway reasoning variants (anomalyco#41867)
- fix(opencode): cap session retries with jitter (anomalyco#41939) - retry policy
  gains RETRY_MAX_RETRIES=5 global cap and 25% jitter
- fix(opencode): detect Copilot PDF input support (anomalyco#41522)
- fix(provider): scope DeepSeek V4 Flash sampling defaults (anomalyco#41620)
- fix(session): route all Muse family models to the Meta system prompt (anomalyco#41581)
- fix(app): use current default model (anomalyco#38603)
- feat(console): add go usage endpoint (anomalyco#16513) and r2 data catalog stats
- fix(ui): correct OC-2 weak icon color (anomalyco#41504)
- fix(i18n): use widely recognized developer terminology (anomalyco#41532)

Conflicts resolved: 30 package.json version bumps (rebranded 1.18.17-sscity),
bun.lock (took upstream, rebranded workspace entries via bun install), and
session/retry.ts (kept fork per-reason maxAttempts cap alongside upstream
RETRY_MAX_RETRIES global cap and jitter).
androidand pushed a commit to androidand/opencode-skein that referenced this pull request Sep 18, 2026
androidand pushed a commit to androidand/opencode-skein that referenced this pull request Sep 19, 2026
androidand pushed a commit to androidand/opencode-skein that referenced this pull request Sep 19, 2026
rldona pushed a commit to rldona/FlupCode that referenced this pull request Sep 24, 2026
Jovan1666 pushed a commit to Jovan1666/opencode that referenced this pull request Oct 4, 2026
arionrefat added a commit to arionrefat/open-usage that referenced this pull request Oct 6, 2026
GET /zen/go/v1/usage merged in anomalyco/opencode#16513 and now answers
in production, so the parser no longer has to guess. The route returns
`{ usage: { rolling, weekly, monthly } }`, each window holding a status,
a floored percent and an ISO reset, and nothing else; the aliases and
dollar fallbacks written against the proposal are gone. A window marked
`rate-limited` reads as spent, since its floored percent can say 99.

A valid key on a workspace without Go answers 403 with an
EntitlementError, which now reads as no subscription instead of a
rejected key, and a 404 is drift rather than an outage. The cookie
still ranks above the key because only the console publishes dollars.
Ichinose-Kazuki pushed a commit to Ichinose-Kazuki/opencode that referenced this pull request Oct 7, 2026
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)