pi-opencode-go-usage
Track OpenCode Go usage limits (rolling 5h / weekly / monthly) in Pi — status bar + /opencode-go report via the console API.
Package details
Install pi-opencode-go-usage from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:pi-opencode-go-usage- Package
pi-opencode-go-usage- Version
1.1.3- Published
- Nov 19, 2026
- Downloads
- 545/mo · 76/wk
- Author
- darkodev
- License
- MIT
- Types
- extension
- Size
- 38.1 KB
- Dependencies
- 0 dependencies · 1 peer
Pi manifest JSON
{
"image": "https://raw.githubusercontent.com/Dakai/pi-opencode-go-usage/main/assets/pi-opencode-go-usage.png",
"extensions": [
"./extensions/opencode-go-usage.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
pi-opencode-go-usage
简体中文 · English
Track OpenCode Go usage limits — rolling 5-hour, weekly, and monthly — in-session
with a live status bar and a /opencode-go report widget.

Status bar: Go 5h 62% · wk 31% · mo 44% (12d 0h / ~15d left)
Report widget:
OpenCode Go Usage
Workspace: wrk_xxxxxxxxxxxxxxxxxxxxxxxx
Rolling 5h ██████░░░░ 62% · 1h 12m
Weekly ███░░░░░░░ 31% · 3d 4h
Monthly ████░░░░░░ 44% · 12d 0h / ~15d left
Updated 2:32:05 PM (time format follows your locale)
Why this exists
OpenCode Go publishes a usage endpoint that accepts an API key:
GET https://opencode.ai/zen/go/v1/usage (Authorization: Bearer <api-key>)
-> { usage: {
rolling: { status, percent, resetsAt },
weekly: { status, percent, resetsAt },
monthly: { status, percent, resetsAt } } }
This extension calls that endpoint with your OpenCode API key and derives the three percentages plus reset countdowns. It reports percentages, countdowns, and (for the monthly meter) an estimate of days of quota left at your average pace so far — it does not spend screen space on dollar figures.
For the monthly meter the countdown is followed by / and the estimate, e.g.
12d 0h / ~15d left: at the current pace the quota lasts about 15 more days.
Hide it with /opencode-go --estimate off.
The older console-cookie mechanism (/console/api/go/status) is still supported
as a fallback for users without an API key.
Install
pi install npm:pi-opencode-go-usage # Pi (recommended)
# or
omp plugin install github:Dakai/pi-opencode-go-usage
# or, for local dev:
omp plugin link /path/to/pi-opencode-go-usage
Then restart the session (or /reload).
Connect
Preferred: an OpenCode API key. Resolve it from (first non-empty wins):
OPENCODE_GO_API_KEYOPENCODE_API_KEYOPENCODE_ZEN_API_KEY~/.local/share/opencode/auth.json→opencode-go.key/opencode.key
If you use the OpenCode CLI, the key is already there — nothing to configure.
Or save one explicitly:
/opencode-go --connect <api-key>
/opencode-go --api-key <api-key>
Legacy (console cookie) fallback, if you have no API key:
- Workspace ID — the
wrk_…segment in the address bar:opencode.ai/console/wrk_…/go - Session cookie — on that page press F12 → Application → Cookies →
https://opencode.ai→ the__Host-console_sessionrow → copy its Value.
Either set env vars:
export OPENCODE_GO_WORKSPACE_ID=wrk_…
export OPENCODE_GO_AUTH_COOKIE='…'
or use:
/opencode-go --connect wrk_… <session-cookie-value>
Bare cookie values are sent as __Host-console_session=<value>. To send a
different cookie name, or several at once, pass a full cookie pair:
name=value; name2=value2.
Env vars take precedence over the saved file: while they are set, --connect /
--cookie save but have no effect (the command warns when it detects this). Unset
them, or export the new value. OPENCODE_GO_CONFIG_PATH overrides where the file
lives (default ~/.omp/agent/opencode-go-usage.json).
Commands
| Command | Effect |
|---|---|
/opencode-go |
Fetch and show the report widget |
/opencode-go --connect <api-key> |
Save API key, fetch, show |
/opencode-go --api-key <api-key> |
Save API key only |
/opencode-go --connect <wrk> <cookie> |
Save workspace + cookie (legacy), fetch, show |
/opencode-go --workspace <id> |
Save workspace id only (legacy) |
/opencode-go --cookie <value> |
Save cookie only (legacy) |
/opencode-go --disconnect |
Forget all credentials |
/opencode-go --refresh |
Fetch again now |
/opencode-go --compact [on|off] |
Toggle compact status bar (Go: 5h 0% · wk 2% · mo 2%) |
/opencode-go --estimate [on|off] |
Show/hide the monthly days-left estimate |
/opencode-go --json |
Export report to ~/.omp/agent/opencode-go-usage-report.json |
Usage refreshes automatically every 5 minutes.
Failure modes
| Status text | Meaning | Fix |
|---|---|---|
Session expired |
The API key/console session lapsed | Reconnect with a fresh key/cookie |
No Go subscription on this workspace |
The console reports no Go plan | Check the workspace |
Console API response unrecognised |
The console API changed shape | Update the parser |
Network error / Request timed out |
Transient | Retry |
Security
This is an authenticated read of your own usage figures, using an API key or a
browser session cookie stored in a 0600-mode file (or in env vars). It reports
only what the endpoint already shows; an API change will break it, and it will
say so instead of showing a confident zero.
License
MIT
