I wrote about ollama-usage back in April – a tiny Go CLI that scrapes Ollama Cloud usage so I don’t have to open their light-mode-only settings page. The reception was warm enough that I figured I’d do the same for another service I’m in daily: OpenCode Go.
OpenCode Go lets you pipe prompts to models like DeepSeek V4 Pro, GLM-5.1, Kimi K2.6, MiMo-V2.5-Pro, Qwen3.7 Max, MiniMax M3 – 14 models across the major Chinese and US labs – all from the CLI. It’s genuinely useful. But if you’re on a Go plan and want to check your usage, you have to open a browser, navigate to the workspace page, and squint at a web UI. No public API endpoint for usage data. Classic.
The full model lineup is a who’s-who of the current frontier: DeepSeek V4 Pro and Flash, GLM-5.1 and GLM-5, Kimi K2.5 and K2.6, MiMo-V2.5-Pro and V2.5, Qwen3.7 Max, Plus, and Qwen3.6 Plus, and MiniMax M2.5, M2.7, and M3. Fourteen models, one opencode CLI.
So I made opencode-go-usage – a Go CLI that does exactly one thing: fetch and display your OpenCode Go usage from the terminal.
The cookie problem
Getting a session cookie out of a browser on macOS is more annoying than it should be. Chromium-based browsers (Chrome, Arc, Brave, Edge) now store cookies in encrypted v10 format with keys in iCloud Keychain – inaccessible from a CLI without popping up system dialogs.
Firefox, bless its contrarian heart, stores cookies in plaintext SQLite. No encryption, no Keychain dance, just a cookies.sqlite file in your profile directory.
The tool auto-detects your Firefox profile, copies the cookie database (handling WAL lock conflicts from a running Firefox), extracts the auth cookie for opencode.ai, and uses it to fetch usage data. You never need to manually copy a cookie.
If you don’t use Firefox, you can pass a cookie directly with -cookie, read one from a file with -cookie-file, or point at a specific cookies.sqlite with -db.
Usage
Running it with no arguments gives a three-meter view with color-coded bars (green below 50%, yellow at 50–74%, red at 75%+):
opencode-go-usage
OpenCode Go Usage (Go plan)
Rolling: 1.0% used (resets in 1 hour 21 minutes)
Weekly: 1.0% used (resets in 1 day 11 hours)
Monthly: 0.0% used (resets in 26 days 6 hours)
Rolling █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1.0%
Weekly █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1.0%
Monthly ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 0.0%
The rolling window is the most useful day-to-day – it’s your burst limit over a shorter trailing period. Weekly and monthly give you the medium-term picture.
JSON output
For scripting, cron jobs, or piping into a dashboard:
opencode-go-usage -json
{
"rolling": {
"percent": 1,
"reset_in_sec": 4907,
"status": "ok"
},
"weekly": {
"percent": 1,
"reset_in_sec": 126983,
"status": "ok"
},
"monthly": {
"percent": 0,
"reset_in_sec": 2268694,
"status": "ok"
},
"plan": "Go",
"fetched_at": "2026-06-06T10:15:00Z"
}
Custom workspace
If you’re across multiple workspaces, pass the ID explicitly:
opencode-go-usage -workspace wrk_...
How it works
The tool fetches https://opencode.ai/workspace/:id/go with your session cookie, then parses usage meter data from the embedded initial state script in the page. No headless browser, no DOM parsing – just a regex over a <script> tag that contains the store state. It’s fast (one HTTP call, one regex pass), and there’s nothing to break if OpenCode tweaks their component tree.
The redirect checker catches expired sessions – if OpenCode redirects to a sign-in page, you get a clear error instead of a confusing parse failure.
Build and install
Assuming Go 1.26+:
git clone https://git.sr.ht/~hrbrmstr/opencode-go-usage
cd opencode-go-usage
go build -o opencode-go-usage .
There’s also a justfile if you prefer just build / just install.
The pattern
At this point I’ve got two of these – ollama-usage and opencode-go-usage – and I’ll keep making them as long as services keep not shipping usage endpoints. There’s something genuinely satisfying about a 150-line Go binary that retires a browser tab.
Repo at git.sr.ht/~hrbrmstr/opencode-go-usage. Kick the tyres, send a PR, and maybe nudge the OpenCode folks about a proper usage API while you’re at it.