Skip to content

docs(upstream): the vendor's own client never calls the usage endpoint - #102

Merged
viztor merged 1 commit into
mainfrom
docs/usage-endpoint
Oct 22, 2026
Merged

viztor merged 1 commit into
mainfrom
docs/usage-endpoint

Conversation

@viztor

@viztor viztor commented Oct 22, 2026

Copy link
Copy Markdown
Owner

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:

packages/console/app/src/routes/zen/go/v1/usage.ts:18   "GET /zen/go/v1/usage": "/go/v1/usage"

The console's dashboard does not go through the gateway for this number either — it reads its own tables (LiteTable.rollingUsage / weeklyUsage / monthlyUsage plus BillingTable) with a session cookie, in packages/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.ts is 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 answers 403 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.

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.
@viztor
viztor merged commit e093dd5 into main Oct 22, 2026
3 checks passed
@viztor
viztor deleted the docs/usage-endpoint branch October 22, 2026 18:51
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