Article

Track Copilot tokens without misreading historical zeros

Copilot admins and finance teams can collect model-level usage, identify gaps in token history and keep consumption separate from billed charges.

Editorial illustration for Track Copilot tokens without misreading historical zeros: code brackets represent developer tools. Not documentary evidence.

GitHub’s December 2, 2026 update lets Copilot administrators and finance teams collect model-level token counts directly from its billing API. Use the endpoint for the account that pays, keep consumption separate from charges, and treat zeros before token capture began as unavailable history—not proof of no use.

Tokens are units of model input and output, including cached context. The new fields bring detail already available in downloaded AI usage reports into direct JSON responses. This is a reporting capability, not a price reduction or a mandatory endpoint migration.

Choose the account that pays

An employee’s personal billing endpoint excludes Copilot usage paid through an organization or enterprise. An empty personal report therefore does not establish that the employee used nothing. Select the payer’s route in the billing API reference:

GET /enterprises/{enterprise}/settings/billing/ai_credit/usage
GET /organizations/{org}/settings/billing/ai_credit/usage
GET /users/{username}/settings/billing/ai_credit/usage

These are the AI-credit routes, not the generic usage summary or premium-request endpoints. GitHub says existing authorized callers receive the fields without permission changes; availability covers Business and Enterprise administrators and Copilot for individuals. The announcement does not grant anyone new access to another account’s billing.

For a new collector, check the exact endpoint’s access requirements. The organization reference lists App tokens and fine-grained personal tokens with organization Administration read permission; the personal route lists user Plan read permission. The enterprise reference documents an enterprise-installed App with billing read access. Account-role requirements still apply.

There is a documentation discrepancy: the general reporting tutorial says fine-grained personal tokens are unsupported, while the organization and personal endpoint references list them. Follow the scope-specific reference for setup and retain working authorized credentials rather than broadening access.

Payer changes also affect what a report contains. If you manage reviews, the separate Copilot code review billing-choice guide explains that decision; collecting usage does not change who pays.

Collect one explicit reporting period

Specify year and month, adding day for a daily slice. Otherwise the AI-credit endpoints default to the current year and month. This documentation-derived organization request selects December 1 usage; it is an illustrative request, not a tested billing integration. Replace ORG and supply an authorized credential through GITHUB_TOKEN. Keep it out of shared scripts and logs. Request parameters and headers are documented by GitHub.

curl --fail-with-body --get \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer $GITHUB_TOKEN" \
  -H "X-GitHub-Api-Version: 2026-03-10" \
  --data-urlencode "year=2026" \
  --data-urlencode "month=12" \
  --data-urlencode "day=1" \
  --data-urlencode "product=Copilot" \
  "https://api.github.com/organizations/ORG/settings/billing/ai_credit/usage"

Save the full response, requested filters and collection time. Keep timePeriod and the billed account alongside each usageItems row, retaining product, sku, model and unitType. The response schema separates this reporting context from the individual rows.

For repeated collection, replace the matching period-and-filter snapshot in your reporting view instead of adding each refresh to the previous total. Retain raw snapshots separately. Do not add an enterprise total to organization totals already inside it, or add a user-filtered subset to the full account total.

Preserve all six token fields

Store the counters individually. GitHub defines six raw measurements, without pricing or discount adjustments:

  • tokenInput and tokenOutput: input sent to the model and output it generates.

  • tokenImageInput and tokenImageOutput: image input and image output tokens.

  • tokenCacheRead and tokenCacheWrite: cached tokens read and tokens written to cache. The write count excludes extended cache creation.

Do not replace an absent field with zero. The schema defines nonnegative 64-bit integers but does not mark the token fields as required. Use storage that preserves those values accurately. Keep the categories separate rather than inventing a total-token sum or cache-hit ratio whose denominator is not established by these definitions.

Mark missing history before drawing a trend

GitHub says token capture generally begins with December 1, 2026 usage. Early-access customers may have partial earlier records; periods before capture return zero-valued token fields. That is different from a measured period with no consumption.

Add a coverage status in your own reporting system, without changing the saved API values:

  • Before capture: display unavailable, not zero consumption. Do not use these zeros as a November baseline for December growth.

  • Early-access history: retain genuine values and label their partial coverage. Do not treat a partial month as comparable to a complete one.

  • Capture expected: retain returned values, but label an unfinished period provisional. A missing field or failed request should produce an unavailable/error state, not a zero-filled refresh.

These are recommended dashboard labels, not GitHub response fields. The announcement gives no exact cutover hour or freshness guarantee. The API’s 24-month access window is not a promise of 24 months of token measurements.

Keep token counts separate from billed amounts

Keep token counts, AI-credit quantities and billed amounts in separate columns. GitHub’s pricing reference distinguishes models and token categories, with context tiers for some models. A single price multiplied by an undifferentiated token total cannot reproduce those rules.

Retain gross, discount and net quantities and amounts with their units. pricePerUnit belongs to the returned unitType, not automatically to each raw token. For billed usage, GitHub’s reporting tutorial points to netAmount; discountAmount includes usage covered by allowances or discounts.

A zero charge can coexist with substantial token consumption. Copilot Business and Enterprise draw on pooled included credits first. That is a different kind of zero from missing historical capture. The same billing guidance says inline completions and next-edit suggestions are not billed in AI credits, so this report is not a complete measure of Copilot activity—or employee productivity.

Use downloads for earlier detail and check the match

For earlier token detail, GitHub directs users to the AI usage report in billing settings. Follow the download steps: open AI usage, choose Get usage report, specify the period, then select Email me the report. Save the downloaded file; the emailed link expires after 24 hours.

The billing reports reference limits each AI report to a period of at most 31 days and records usage dates in UTC. This is a report-window limit, not a guarantee of historical retention. It lists input, output, cache-read and cache-write fields; do not assume a separate export column for each image counter.

Keep downloaded history labelled with its source and period, avoiding overlap with the API series. If an importer reads the CSV files, use the GitHub AI usage import checks rather than assuming its column positions remain unchanged.

Before relying on the dashboard, compare an authorized API response and download for the same payer, dates and filters. Check the shared token categories and billed amounts separately. Investigate mismatches without forcing the figures to agree. The useful result is a report that distinguishes measured consumption, included usage and missing evidence—not just a chart with fewer blanks.