-
Notifications
You must be signed in to change notification settings - Fork 2k
Copilot Business (token-based billing): surface GitHub AI credit usage — card is blank because every quota reports unlimited/zero-entitlement #2593
Copy link
Copy link
Closed
Labels
P3Low-risk cleanup, docs, polish, ergonomics, or speculative feature.Low-risk cleanup, docs, polish, ergonomics, or speculative feature.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.ClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:ux-frictionUser-facing flow adds avoidable confusion or support burden without fully blocking progress.User-facing flow adds avoidable confusion or support burden without fully blocking progress.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Description
Activity
Metadata
Metadata
Assignees
Labels
P3Low-risk cleanup, docs, polish, ergonomics, or speculative feature.Low-risk cleanup, docs, polish, ergonomics, or speculative feature.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper marked this issue as needing security-sensitive review.ClawSweeper marked this issue as needing security-sensitive review.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:ux-frictionUser-facing flow adds avoidable confusion or support burden without fully blocking progress.User-facing flow adds avoidable confusion or support burden without fully blocking progress.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.
Summary
On a Copilot Business seat with token-based billing, the Copilot card renders no usage at all — just the plan label. This is currently correct behaviour (it's the guard added for #1258 to avoid a fake "0% used"), but it leaves the card empty even though GitHub does expose real consumption for these accounts — just on a different endpoint than the one CodexBar reads.
Request: add GitHub AI credit usage as a Copilot data source, so token-based-billing accounts get a real metric instead of a blank card.
Why the card is blank today
GET /copilot_internal/useron a Business token-billing seat returns every quota as unlimited with zero entitlement (redacted, live, v0.46.0):That payload is dropped on purpose, in two places:
CopilotUsageFetcher.swift:149—guard !snapshot.unlimited else { return nil }CopilotUsageFetcher.swift:86—usage.tokenBasedBilling || hasUnlimitedQuota→primary = nil, secondary = nilNo complaint about those guards — a percent bar genuinely is meaningless here. The gap is that there's no alternative metric for this account class.
What GitHub actually exposes
GET /orgs/{org}/settings/billing/ai_credit/usagereturns per-model AI credit consumption (redacted, live):{ "timePeriod": { "year": 2026, "month": 8 }, "organization": "<ORG>", "usageItems": [ { "product": "Copilot", "sku": "Copilot AI Credits", "model": "Code Review model", "unitType": "ai-credits", "pricePerUnit": 0.01, "grossQuantity": 31.13, "netAmount": 0.0 }, { "product": "Copilot", "sku": "Copilot Cloud Agent", "model": "Coding Agent model", "unitType": "ai-credits", "pricePerUnit": 0.01, "grossQuantity": 49.97, "netAmount": 0.0 } ] }31.13 + 49.97 = 81.10, which matches the "81 / 6,000 AI credits" shown on the org's Billing → AI usage page exactly. So the numerator is available over the REST API, with a per-model breakdown that's arguably nicer than a single bar.
Caveat worth stating up front: the 6,000 denominator is not in that response. I probed
/orgs/{org}/settings/billing/usageand/orgs/{org}/copilot/billingtoo — neither carries the included-credit entitlement. So either the bar needs a user-supplied entitlement, or this ships as a credits-consumed + spend figure without a denominator.Auth / scope — the blocker from #1276
#1276 was closed with budget windows (#1273), and the reason AI credits were deferred was that the auth and account-scope model needed maintainer sign-off. One data point that may make this cheaper than expected:
The org call above succeeded with a classic token carrying only
gist, read:org, repo, workflow— noadmin:org, nomanage_billing:*. (The authenticating account is an owner of the org, so org-ownership may be doing the work rather than the scopes; I haven't isolated which.)CodexBar's device flow currently requests
read:useronly, so this would still mean widening the requested scope — that's the real cost, and it's a genuine UX tradeoff, not a free win. Whetherread:useralone suffices for an org owner is the open question I couldn't answer without minting a separate token.For reference, the user-scope sibling
GET /users/{username}/settings/billing/ai_credit/usage404'd for me and asks for theuserscope, so per-user attribution likely needs its own decision.Proposal
Rough shape, smallest first:
credits_usedfrom the snapshots CodexBar already fetches. No new endpoint, no new scope, no cookies — the field is sitting in the existing/copilot_internal/userresponse andCopilotUsageModels.swiftsimply doesn't have aCodingKeyfor it. On this account that alone would turn a blank card into "31 credits used · resets 1 Sep". Happy to split this into its own issue if you'd prefer it decoupled from the org work./orgs/{org}/settings/billing/ai_credit/usage, show credits consumed and net spend, optionally broken down per model.I'd be glad to take a swing at (1) as a PR with fixtures if it's a shape you'd accept — it's contained to the model decoder plus the fetcher's token-billing branch.
Environment
7760f349)token_based_billing: true, org-ownedRelated