跳到主要内容
    ↑↓ 选择↵ 打开esc 关闭
    中文English
    a-r-m-i-n

    Openai Usage

    v0.1.5工具与命令
    @a-r-m-i-n/opencode-openai-usage

    OpenCode plugin that shows ChatGPT/OpenAI usage in the sidebar and command palette.

    GitHub 星标

    0

    月装机量

    105

    近 7 天 21

    综合评分SCORE

    30.3

    生态多维模型

    最近提交

    1 个月前

    2026-07-05

    快速安装与配置

    opencode.json

    写入当前项目的 opencode.json,只对这个仓库生效。

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["@a-r-m-i-n/opencode-openai-usage@0.1.5"]
    }

    opencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。

    OpenCode plugin that reads your ChatGPT account usage and shows it in the TUI sidebar and command palette.

    The sidebar panel starts expanded and can be collapsed.

    OpenAI Usage sidebar showing active usage windows

    What It Does

    • fetches usage data from OpenAI Backend API
    • reads the OpenCode OpenAI OAuth token from OpenCode's local state
    • shows usage windows in the collapsible sidebar
    • adds OpenAI Usage, OpenAI Usage: Toggle Sidebar Display, and OpenAI Usage: Show/Hide Sidebar Section commands to the TUI command list

    Screenshots

    Command Palette

    Shows the OpenAI-specific commands added by the plugin.

    • OpenAI Usage: opens the detailed usage dialog
    • OpenAI Usage: Toggle Sidebar Display: switches the sidebar between used quota and remaining quota
    • OpenAI Usage: Show Sidebar Section / OpenAI Usage: Hide Sidebar Section: toggles the sidebar section and persists the setting across restarts
    Command palette with OpenAI Usage commands

    Usage Dialog

    Shows the detailed usage summary, including the current usage windows and account details returned by the upstream endpoint.

    OpenAI Usage dialog

    Sidebar Display Modes

    The sidebar can show either used quota or remaining quota.

    Used mode:

    Sidebar showing used quota

    Left mode:

    Sidebar showing remaining quota

    Requirements

    • OpenCode with an OpenAI account connected via OAuth
    • Node.js and npm available for installation/build steps

    Install From npm

    npm install @a-r-m-i-n/opencode-openai-usage
    

    Add the runtime plugin in opencode.json:

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["@a-r-m-i-n/opencode-openai-usage"]
    }
    

    Add the TUI plugin in tui.json:

    {
      "$schema": "https://opencode.ai/tui.json",
      "plugin": [["@a-r-m-i-n/opencode-openai-usage/tui", { "invert": false }]]
    }
    

    After changing config, quit and restart OpenCode.

    TUI Options

    The TUI plugin accepts options in tui.json:

    {
      "$schema": "https://opencode.ai/tui.json",
      "plugin": [["@a-r-m-i-n/opencode-openai-usage/tui", { "invert": true }]]
    }
    
    Option Default Description
    invert false Default sidebar mode. false shows used quota like 60% used; true shows remaining quota like 40% left. After the OpenAI Usage: Toggle Sidebar Display command is used, the last selected mode is persisted across restarts.

    Project Structure

    src/
      index.ts
      tui.tsx
      lib/openai-usage.ts
    .opencode/
      plugins/openai-usage.ts
      tui/openai-usage.tsx
      tui.json
    

    Notes And Limitations

    • The plugin depends on OpenCode's locally stored auth.json format.
    • The usage endpoint is an internal ChatGPT web endpoint and may change without notice.
    • The plugin caches usage data locally in OpenCode's state directory.
    • The plugin hides its sidebar panel when OpenCode has no OpenAI OAuth account configured.
    • Usage-specific commands are hidden when OpenCode has no OpenAI OAuth account configured, but the sidebar visibility toggle remains available.
    • The command summary currently includes the account email returned by the upstream endpoint.

    License

    MIT