Github Copilot: Tracking Premium Requests
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.
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"
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.
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.
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 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
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
And instead use the bottom right corner to show the provider limits
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 ?
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
Hey, would love this!!!
Any plans on this?
No immediate plans but we should think about how we wanna show it
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
quotasconfig 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)
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