oc-plugin-openai-usage
v0.1.0
Published
OpenCode TUI plugin that shows current ChatGPT OpenAI subscription usage in the sidebar
Readme
oc-plugin-openai-usage
OpenCode TUI plugin that shows current ChatGPT OpenAI usage in the session sidebar.
What it does
- Renders a compact
OpenAI Usagecard insidebar_content - Only appears when the selected model provider is
openai - Reuses the existing OpenCode OpenAI OAuth session by reading OpenCode auth storage
- Does not refresh or extend the OAuth session itself
- Fetches usage from
https://chatgpt.com/backend-api/wham/usage - Caches usage for 5 minutes to avoid refetching on TUI rerenders or terminal resize
Sidebar output
The card currently shows:
OpenAI UsagePlan5husage window7dusage window
Each window shows:
- used percent
- remaining percent
- exact local reset time
Example:
OpenAI Usage
Plan: prolite
5h ██░░░░░░░░░░░░░░░ 14%
86% left • resets 22:14
7d █░░░░░░░░░░░░░░░░░ 6%
94% left • resets 16.04 22:14Install
npm
Install it with:
opencode plugin oc-plugin-openai-usageOr add it directly to your TUI config:
{
"plugin": [
"oc-plugin-openai-usage"
]
}Repository:
https://github.com/nazriel/oc-plugin-openai-usage
Local development path
If you are developing locally from a GitHub checkout, you can point OpenCode at the local path:
{
"plugin": [
"/Users/you/path/to/oc-plugin-openai-usage"
]
}Requirements
- OpenCode build that includes
api.state.model.current()for TUI plugins - OpenAI connected through ChatGPT OAuth
- Selected model provider must be
openai
If OAuth is missing or expired, the card shows ChatGPT OAuth required.
Notes
- The plugin is TUI-only. There is no
server.ts. - The plugin reads OpenCode auth from the OpenCode data directory.
- The plugin intentionally does not mutate auth state or refresh tokens.
- Additional rate-limit buckets are hidden to keep the sidebar compact.
