A standalone TrafficMonitor plugin
that shows your OpenCode Go subscription usage (rolling / weekly / monthly) and
your OpenRouter credit balance (total / used / remaining) right in the taskbar /
main window. It is driven by the public OpenCode Go usage API
(https://opencode.ai/zen/go/v1/usage) and the OpenRouter credits API
(https://openrouter.ai/api/v1/credits).
It is built against the official
PluginInterface.h
(supplied here in the repo) and the documented plugin contract
(Plugin Development Guide).
- Name: OpenCode Go & OpenRouter Usage
- Description: Displays OpenCode Go and OpenRouter usage via Official APIs.
- Author: P1N2O
- Copyright: © 2026 P1N2O
- Home: https://github.com/P1N2O/ocg-usage-plugin
- Item IDs:
ocg-rolling,ocg-weekly,ocg-monthly,ocg-reset,or-total,or-used,or-remaining - DLL:
OpenCodeGoUsage.dll
- Your own API keys — each user enters their own OpenCode Go and OpenRouter bearer tokens in the item settings (one field per provider); nothing is hard-coded in the plugin. The two providers are fully independent — either can be used alone, and the OpenRouter rows are never disturbed by an OpenCode Go error (or vice versa).
- Shows seven rows (like the CPU/GPU monitors). OpenCode Go:
OpenRouter (money):
AI (R): 2% (2h) AI (W): 7% (3d) AI (M): 12% (18d) AI RESET: 1h • 3d • 12dOpenRouter Total: $35.34 OpenRouter Used: $20.83 OpenRouter Remaining: $14.51AI (R)/AI (W)/AI (M)each show one window's percent plus a compact single-unit reset countdown (2h,3d,18d) when Inline reset time is on.AI RESETalways shows the next reset for all three windows together (1h • 3d • 12d), independent of the Inline-reset-time toggle.OpenRouter Total/Used/Remainingare computed fromtotal_credits,total_usageandtotal_credits - total_usage(clamped at $0), formatted as dollars ($35.34). Used also draws a small usage bar (spent / purchased credits). Rows are host-drawn text items aligned like TrafficMonitor's own items.
- All rows are always available — no per-row visibility toggles in the plugin. (You can still hide a row from TrafficMonitor's own display-item settings.)
- Configurable refresh interval — set how often it queries the APIs (default 60 s, min 5 s). The interval applies to both providers.
- Optional Inline reset time toggle (
12%→12% (18d), OpenCode Go rows only). - Background fetch thread (network never blocks the UI); each usage row also exposes a resource-usage graph value so the taskbar item can draw a small usage bar.
- Download the DLL for your architecture:
OpenCodeGoUsage-x64.dll— 64-bit Windows (most machines)OpenCodeGoUsage-x86.dll— 32-bit Windows
- Copy it into your TrafficMonitor
pluginsfolder (next toTrafficMonitor.exe) and rename it toOpenCodeGoUsage.dll. - Start/restart TrafficMonitor.
- Right-click any usage row → Item settings:
- paste your OpenCode Go API key (for the
AIrows), - paste your OpenRouter API key (for the
OpenRouterrows), - set the refresh interval (seconds),
- optionally toggle Inline reset time.
- paste your OpenCode Go API key (for the
The plugin appears as seven rows (AI (R), AI (W), AI (M), AI RESET,
OpenRouter Total, OpenRouter Used, OpenRouter Remaining).
The settings are stored in <TrafficMonitor>\plugins\OpenCodeGoUsage.ini.
You only need one plugin DLL; you do not need to build TrafficMonitor itself.
Requirements:
- Visual Studio 2022 (Community is fine) with the Desktop development with C++ workload
(MSVC
v143+ Windows 10/11 SDK). The plugin is pure Win32 and has no MFC dependency, so no extra MFC component is required.
Steps:
- Open
OpenCodeGoUsage.slnin Visual Studio. - Set Release | x64 (or x86) and Build.
- The output is written to
bin\Release\x64\OpenCodeGoUsage.dll.
Or from the command line:
msbuild OpenCodeGoUsage.sln -p:configuration=Release -p:platform=x64 -p:platformToolset=v143
Output lands in bin\Release\x64\OpenCodeGoUsage.dll (x86 → bin\Release\Win32\).
Drop that DLL into TrafficMonitor's plugins\ folder to test.
The included GitHub Action (.github/workflows/build.yml) builds the DLL for x64 and
x86 on windows-latest. On a v* tag it publishes them as a public GitHub Release.
GET https://opencode.ai/zen/go/v1/usage with header Authorization: Bearer <your key>:
{
"usage": {
"rolling": { "status": "ok", "percent": 1, "resetsAt": "2026-08-15T12:34:47.397Z" },
"weekly": { "status": "ok", "percent": 18, "resetsAt": "2026-08-17T00:00:00.397Z" },
"monthly": { "status": "ok", "percent": 11, "resetsAt": "2026-09-01T01:15:47.397Z" }
}
}Each window's percent (clamped 0–100) and resetsAt are parsed, cached, and rendered
through the standard IPluginItem::GetItemLableText / GetItemValueText contract — four
items (Rolling / Weekly / Monthly / Reset). The resetsAt timestamp is shown as a compact
countdown (2h, 3d, 18d).
GET https://openrouter.ai/api/v1/credits with header Authorization: Bearer <your key>:
{
"data": {
"total_credits": 35.34,
"total_usage": 20.834910545
}
}Three items are derived from the two numbers, formatted as dollars:
- Total =
total_credits→$35.34 - Used =
total_usage→$20.83 - Remaining =
total_credits - total_usage(clamped at$0.00) →$14.51
The OpenRouter request only runs when an OpenRouter API key is configured; it is fetched on the same background thread and refresh interval as the OpenCode Go data, but stored and displayed entirely separately.
| Key | Meaning |
|---|---|
api_key |
Your OpenCode Go bearer token |
openrouter_api_key |
Your OpenRouter bearer token (separate provider) |
show_reset_time |
1 to append the reset countdown to each usage row (e.g. 12% (18d)) |
refresh_seconds |
Seconds between API fetches, both providers (default 60, min 5) |
The API keys are stored in plain text in plugins\OpenCodeGoUsage.ini on the user's
own machine and sent only to opencode.ai and openrouter.ai.
Do not use a privileged key for public testing.
| File | Purpose |
|---|---|
OpenCodeGoUsage.vcxproj / OpenCodeGoUsage.sln |
Standalone build project |
PluginInterface.h |
Vendored official TrafficMonitor plugin interface (v8) |
OpenCodeGoService.* |
WinHTTP client + JSON parser for the usage/credits APIs |
DataManager.* |
Settings persistence + thread-safe usage/credits cache |
OpenCodeGoItem.* |
IPluginItem rows — one per OpenCode Go window (AI R / W / M / RESET) |
OpenRouterItem.* |
IPluginItem rows — OpenRouter Total / Used / Remaining |
OpenCodeGoUsage.* |
ITMPlugin entry point + background fetch thread |
OptionsDlg.*, OpenCodeGoUsage.rc |
Item settings dialog + resources |