Skip to content

Latest commit

 

History

33 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

opencode-provider-usage

Minimal OpenCode TUI plugin that shows provider-aware usage in the prompt area.

The plugin reads existing local OpenCode auth state and displays compact usage badges for the active provider/model. It is designed to stay quiet for unsupported providers.

Features

  • OpenAI ChatGPT/Codex usage: compact 5h and 7d windows with reset timers, keeping unavailable windows visible as -- without a reset timer.
  • OpenAI Codex multi-auth aggregate: average 5h/7d usage across all enabled accounts when multiple accounts are configured.
  • GitHub Copilot usage: monthly premium interaction usage with reset timer.
  • Anthropic API headroom: remaining requests, input tokens, output tokens, and request reset countdown when available.
  • OpenCode Zen model pricing: input/output price per million tokens plus best-effort current-session cost.
  • Provider-aware visibility: hidden when the current provider is unsupported.
  • Pastel Jet usage colors: blue/green at low usage, yellow/red near the limit.

Examples

OpenAI single account:

[Plus] 5h: -- | 7d: 13% (-3d)

OpenAI with Codex multi-auth:

[Plus 1/2] 5h: -- | 7d: 13% (-3d)
[All 2/2] 5h: -- | 7d: 7% (-2d4h)

Other providers:

[Pro] mo: 22% (-19d)
[API] 49 req | 50k in | 10k out (-12s)
[Zen] $5/$30 per M | sess: $1.19/161k t

OpenAI Multi-Account Aggregate

The aggregate line appears only when Codex multi-auth has more than one enabled OpenAI account.

For each usage window:

  • percentage is the average used_percent across accounts that responded successfully
  • reset timer is the shortest reset_after_seconds among those accounts
  • label uses [All available/total], for example [All 2/3] if one account failed its usage fetch

The aggregate fetch is cached for 60 seconds and uses limited concurrency, so it works for any account count without assuming exactly two accounts. If Codex multi-auth is missing, disabled, or has only one enabled account, the plugin keeps the original single-account behavior.

Install

  1. Clone the repository somewhere stable.
git clone https://github.com/5TuX/opencode-provider-usage.git ~/opencode-provider-usage
  1. Install dependencies.
cd ~/opencode-provider-usage
npm install
  1. Point OpenCode TUI config at the plugin file.
{
  "$schema": "https://opencode.ai/tui.json",
  "plugin": [
    "/absolute/path/to/opencode-provider-usage/plugins/provider-usage.tsx"
  ]
}
  1. Quit and restart OpenCode.

Runtime Inputs

The plugin reads local runtime state only:

  • ~/.local/share/opencode/auth.json
  • ~/.local/state/opencode/model.json
  • ~/.opencode/oc-codex-multi-auth-accounts.json
  • ~/.local/state/opencode/oc-codex-multi-auth-tui-quota.json
  • ~/.config/opencode/secrets.env

It does not store credentials or write account state.

Synced Device Workflow

For the shared multi-device setup, edit the synced repository copy:

~/Documents/gdrive-shared/projets-ia/opencode-plugins/opencode-provider-usage/plugins/provider-usage.tsx

OpenCode should load a local runtime file, typically:

~/.config/opencode/plugins/provider-usage.tsx

After editing the repository copy, refresh the local runtime file or link, then restart OpenCode.

Linux symlink example:

ln -sfn ~/Documents/gdrive-shared/projets-ia/opencode-plugins/opencode-provider-usage/plugins/provider-usage.tsx ~/.config/opencode/plugins/provider-usage.tsx

Verification

Bundle-check the plugin without publishing:

npx esbuild plugins/provider-usage.tsx --bundle --platform=node --format=esm --external:@opencode-ai/plugin/tui --external:@opentui/solid --external:solid-js --outfile=/tmp/provider-usage-check.js

Then restart OpenCode and confirm the prompt badge updates for the active provider.

About

Minimal opencode TUI plugin for live Codex usage.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages