Repository navigation
docs(upstream): the vendor's own client never calls the usage endpoint - #102
Merged
Merged
Conversation
Answering "which endpoint does OpenCode use for usage" by reading the source turns up something worth recording, because it changes what the endpoint IS. A full-text sweep of the 1.19.4 tree finds exactly ONE reference to `/zen/go/v1/usage`, and it is the server side: the console's inference-proxy path table. The dashboard does not go through the gateway for this number either — it reads its own `LiteTable` / `BillingTable` with a SESSION COOKIE. The CLI and TUI have no usage fetch at all; `acp/usage.ts` is a session's token count, not the plan's quota. So the route is a KEY-FACING endpoint: it authenticates with `authorization: Bearer <key>`, looks the key up in the key table, and answers `403 EntitlementError` when that workspace has no Go subscription. That is exactly the shape this plugin uses, and it is why the endpoint is so sparse. The two versions differ in where the number comes from and the shape does not change: 1.19.4 tries the inference proxy and falls back to its own database when it is unavailable; 2.0.32 forwards the request outright. In one line: `GET https://opencode.ai/zen/go/v1/usage`, the only such endpoint on the gateway — the Zen plane has no counterpart, because the Zen plan's credits are a console concept the dashboard reads with a cookie.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Answering "which endpoint does OpenCode use for usage" from the source turned up something worth recording, because it changes what the endpoint is.
Nothing in the vendor's client fetches it
A full-text sweep of the 1.19.4 tree finds exactly one reference to
/zen/go/v1/usage, and it is the server side:The console's dashboard does not go through the gateway for this number either — it reads its own tables (
LiteTable.rollingUsage/weeklyUsage/monthlyUsageplusBillingTable) with a session cookie, inpackages/console/app/src/routes/workspace/[id]/go/lite-section.tsx. The CLI and TUI have no usage fetch at all;packages/opencode/src/acp/usage.tsis about a session's token count, not the plan's quota.So it is a key-facing endpoint
The route authenticates with
authorization: Bearer <key>, looks the key up in the key table, and answers403 EntitlementError("OpenCode Go subscription required.") when that workspace has no Go subscription. That is exactly the shape this plugin uses — a key in hand, the windows in hand — and it is why the endpoint is so sparse: it exists for key holders, not for the dashboard.The two versions differ in where the number comes from, and the shape does not change: 1.19.4 tries the inference proxy and falls back to its own database when the proxy is unavailable (
.catch(inferenceUnavailable)), while 2.0.32 forwards the request outright (return proxyInference(input.request)).The answer, in one line
GET https://opencode.ai/zen/go/v1/usage— and it is the only such endpoint on the gateway. The Zen plane has no counterpart, because the Zen plan's credits are a console concept the dashboard reads with a cookie.This is a documentation-only change: the plugin already used this endpoint, and
docs/upstream-findings.md§3.7 already recorded that it is the only quota route in either major version.