Skip to content

Copilot Business (token-based billing): surface GitHub AI credit usage — card is blank because every quota reports unlimited/zero-entitlement #2593

Description

@KSEGIT

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/user on a Business token-billing seat returns every quota as unlimited with zero entitlement (redacted, live, v0.46.0):

"quota_snapshots": {
  "premium_interactions": {
    "unlimited": true, "entitlement": 0, "remaining": 0,
    "percent_remaining": 100.0, "quota_remaining": 0.0,
    "credits_used": 31,            // <-- real usage, currently not decoded
    "token_based_billing": true, "overage_permitted": true
  },
  "chat":        { "unlimited": true, "entitlement": 0, "credits_used": 0 },
  "completions": { "unlimited": true, "entitlement": 0, "credits_used": 0 }
},
"copilot_plan": "business",
"access_type_sku": "copilot_for_business_seat_quota",
"token_based_billing": true,
"quota_reset_date": "2026-09-01"

That payload is dropped on purpose, in two places:

No 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/usage returns 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/usage and /orgs/{org}/copilot/billing too — 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 — no admin:org, no manage_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:user only, 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. Whether read:user alone 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/usage 404'd for me and asks for the user scope, so per-user attribution likely needs its own decision.

Proposal

Rough shape, smallest first:

  1. Decode credits_used from the snapshots CodexBar already fetches. No new endpoint, no new scope, no cookies — the field is sitting in the existing /copilot_internal/user response and CopilotUsageModels.swift simply doesn't have a CodingKey for 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.
  2. Optional org AI-credit source behind a setting, mirroring how "Budget extras" is already opt-in — call /orgs/{org}/settings/billing/ai_credit/usage, show credits consumed and net spend, optionally broken down per model.
  3. Optional user-entered entitlement (e.g. 6,000) to turn (2) into a real progress bar, since GitHub won't give the denominator.

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

  • CodexBar 0.46.0 (build 110, commit 7760f349)
  • macOS 26.5.2 (25F84)
  • Copilot Business seat, token_based_billing: true, org-owned

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low-risk cleanup, docs, polish, ergonomics, or speculative feature.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:needs-security-reviewClawSweeper 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:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:ux-frictionUser-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.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions