I Built an OpenCode Plugin to Show GitHub Copilot Usage in TUI

Murtuzaali Surti
Murtuzaali Surti

• 4 min read

Updated

TL;DR

Table of Contents

If you use GitHub Copilot as your provider in OpenCode, there's no way to see how much of your usage you've burned through without leaving the terminal. You either open VS Code and hover over the Copilot icon in the status bar, or you go to GitHub and dig through your Copilot settings.

That's fine if you live in VS Code. If you've moved your day-to-day work to OpenCode, it's an annoying detour just to see one number.

So I built opencode-github-copilot-usage, an OpenCode plugin that shows your Copilot usage right in the TUI. I built it for OpenCode, using OpenCode, and it took around 15 minutes from start to being published on npm.

What the Plugin Shows

Once installed, a line like this appears below the prompt footer:

Copilot 2,000/15,000 cr · 13.3%

The cr stands for AI credits, and if your account is still on the older premium request billing, the plugin shows req instead.

How the line behaves:

  • The line only shows up while a GitHub Copilot model is selected, so it stays out of the way when you switch to another provider.
  • The colour changes as you get closer to your limit. It's muted below 75%, turns to a warning colour from 75%, and switches to the error colour from 90%.
  • It refreshes every 15 seconds, and again shortly after each turn finishes.

Here's what it looks like at 83.2%, past the 75% mark, so the line has switched to the warning colour.

OpenCode prompt with a GitHub Copilot model selected, showing Copilot 12,480/15,000 cr · 83.2% in the footer

For more detail, run the /copilot slash command (it's also in the command palette). It opens a dialog with your account, plan, billing type, used and remaining credits, overage, and the date your quota resets.

The /copilot dialog in OpenCode showing account, billing, used, remaining, overage, reset date, and last updated time

The plugin reuses the GitHub Copilot login that OpenCode already stores, so you don't need to create or paste a separate token. GitHub Enterprise logins work too, which matters if your company's Copilot seat is tied to an Enterprise account.

Installing the Plugin

You need GitHub Copilot connected in OpenCode, and either OpenCode V2 or OpenCode V1 1.18.29 or newer. I tested it with V2 2.0.28.

OpenCode V2

opencode plugin add opencode-github-copilot-usage

Or add it to ~/.config/opencode/opencode.jsonc yourself:

{
  "$schema": "https://opencode.ai/config.json",
  "plugins": ["opencode-github-copilot-usage"],
}

OpenCode V1

opencode plugin opencode-github-copilot-usage --global

Or add it to ~/.config/opencode/tui.json:

{
  "plugin": ["opencode-github-copilot-usage"]
}

On V1, the plugin runs only in the TUI. The usage line appears at the bottom of a session when that session's latest message used a Copilot model.

Changing the Refresh Interval

If 15 seconds is too often for you, set the interval option in seconds. The minimum is 5. On V2, it goes in opencode.jsonc:

{
  "plugins": [
    {
      "package": "opencode-github-copilot-usage",
      "options": {
        "interval": 30,
      },
    },
  ],
}

On V1, pass it as a tuple in tui.json:

{
  "plugin": [["opencode-github-copilot-usage", { "interval": 30 }]]
}

Where the Numbers Come From

GitHub has no documented API for your Copilot usage, but it does have an undocumented endpoint, GET https://api.github.com/copilot_internal/user, which returns your plan, quota snapshots, and reset date.

The plugin calls that same endpoint with the GitHub token OpenCode already holds for your Copilot login. On V2, a small server plugin makes the request and exposes the result through an RPC, and the TUI part of the plugin polls that RPC to draw the footer line and the /copilot dialog. On V1, there's no server side to lean on, so the TUI part reads the token from OpenCode's auth.json and calls the endpoint itself.

The endpoint doesn't update in real time. After a turn, it takes a little while to catch up with what you've actually used, but in my experience the difference isn't big enough to matter.

CAUTION

copilot_internal/user is undocumented, so GitHub can change or remove it without notice. If that happens, the plugin will show an error until it's updated. Treat the figures as a close estimate rather than an exact count.

As far as I can tell, there aren't any other OpenCode plugins that do this.

Built With OpenCode, for OpenCode, in 15 Minutes

The plugin itself is only half of why I wrote this post. I built it inside OpenCode, using Claude Opus 5.5 on medium effort, and the whole thing took around 15 minutes. That covers building it, testing it, and publishing it.

A tool this small used to sit on the "someday i will build this" list. You'd have to read the plugin docs, figure out how the TUI renders things, find the right endpoint, and wire it all together, and for a status line, that's rarely worth an evening. Now the cost of trying is low enough that you can go from "this annoys me" to "this is fixed" in one sitting, and keep using the result from then on.

In this case, it didn't stop at a personal script either. I published it to npm, so anyone else on Copilot can install it with one command. With AI, a small tool is cheap enough to build for yourself, and also cheap enough to share.

If there's a small gap in your own OpenCode setup, it's worth asking your agent to close it. The plugin is open source on GitHub.


The AI Slowdown Pact, Nvidia's $13B Hugging Face Deal & the RubyGems Attack - The Weekly Diff #10

Previous