opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Github Copilot: Tracking Premium Requests

Open FareedFarag opened this issue 5 months ago • 12 comments

When using Github copilot models, the cost tracker is irrelevant as it always stays at $0.00. Instead, is it possible to display the premium requests quota? See below image as an example from VS code copilot extension.

Image

FareedFarag avatar Jul 08 '25 16:07 FareedFarag

FYI - Don't recall where I found it, but the data is available through this endpoint:

curl https://api.github.com/copilot_internal/user -H "Authorization: Bearer $COPILOT_API_KEY" -H "Content-Type: application/json"

If anyone is interested in a quick alias to get the current quota/usage:

alias copilot-quota="curl -s https://api.github.com/copilot_internal/user -H 'Authorization: Bearer $COPILOT_API_KEY' -H 'Content-Type: application/json' | jq .quota_snapshots.premium_interactions"

martinhpedersen avatar Jul 08 '25 17:07 martinhpedersen

FYI - Don't recall where I found it, but the data is available through this endpoint:

curl https://api.github.com/copilot_internal/user -H "Authorization: Bearer $COPILOT_API_KEY" -H "Content-Type: application/json"

If anyone is interested in a quick alias to get the current quota/usage:

alias copilot-quota="curl -s https://api.github.com/copilot_internal/user -H 'Authorization: Bearer $COPILOT_API_KEY' -H 'Content-Type: application/json' | jq .quota_snapshots.premium_interactions"

How do you get COPILOT_API_KEY? Copilot doesn't issue API keys as far as I know.

FareedFarag avatar Jul 10 '25 00:07 FareedFarag

As a github copilot user, I think this would be a great addition to the software. Not having to open up the browser to look at remaining premium requests would be such a good quality-of-life improvement.

asadmoosvi avatar Jul 26 '25 07:07 asadmoosvi

Here's a curl that uses your GitHub Copilot Oauth token instead:

curl -s -H "Authorization: Bearer $(cat ~/.config/github-copilot/apps.json \
| jq '.[].oauth_token' \
| sed 's/^"\(.*\)"$/\1/')" https://api.github.com/copilot_internal/user

As a user of Copilot, having this info in the UI would be very useful. I'm happy to implement this if the authors also see its value. cc @thdxr

berenar avatar Oct 27 '25 08:10 berenar

@berenar how would you go about implementing it? There will probably be other providers that have special billing things like copilot too

This would be welcome but we would probably need to discuss how it would be shown in the ui

rekram1-node avatar Oct 27 '25 15:10 rekram1-node

Providers support

Well, so far I've only used Claude (subscription based), GitHub Copilot and Zen.

  • Anthropic has hourly and daily usage limits. → And an API to get that info
  • Copilot "has X premium requests per month" → And an (internal) API endpoint to get that info too

I think the rest of supported providers are not subscription based (yet...), therefore they would not need this feature

UI

On how to show it in the UI, that's yours to decide :)

I would leave the top right corner for info related to the current session

  • Context size
  • Context %
  • Cost so far Image

And instead use the bottom right corner to show the provider limits Image

The info to display would change based on the provider being used

Claude

  • "Approaching hourly limit" Same as how Claude Code shows it
  • "Approaching daily limit"
  • "Limit resets at 3pm"

Copilot

  • "80% used Premium Requests. Resets Nov. 1st"

wdyt @rekram1-node ?

berenar avatar Oct 28 '25 08:10 berenar

Sorry for delay @berenar I think we should wait for opentui to be wrapped up before a PR is attempted here. Another thing we need to surface that currently isn't being surfaced is retries.

I recently added some logic that will allow us to display the # of retries, if it is retrying, etc.

And that would also tie into this because some plan quotas are rate limited and we do exponential backoffs with awareness of the rate limit headers so there are a few moving pieces here.

That said I do like your proposal I just thing it will be best to revisit in a week once opentui has a little less stuff in motion

rekram1-node avatar Oct 29 '25 21:10 rekram1-node

Hey, would love this!!!

Any plans on this?

itse4elhaam avatar Nov 25 '25 21:11 itse4elhaam

No immediate plans but we should think about how we wanna show it

rekram1-node avatar Nov 26 '25 18:11 rekram1-node

This same issue applies to z.ai Coding Plans. Cost tracking shows $0.00, but users have no visibility into their prompt quota. Even worse, z.ai does not even have an api call to track this.

Not ideal however a possible approach:

  • Optional quotas config per provider, make it configurable per model: for example glm4.6: Lite: 120 prompts/5h , Pro: 600 prompts/5h, Max: 2400 prompts/5h
  • Track rolling window prompt count per configurable time window.
  • Display alongside cost/even hide cost for flat fee plan: "Cost: $0.00 | Usage: 87%" example based upon 104 requests of 120 limit)

flupkede avatar Dec 04 '25 09:12 flupkede

Would love to see this for Github and Anthropic, i use both and id love to see how much time i have left before i have to think for myself again :D

ojsef39 avatar Dec 11 '25 13:12 ojsef39