AI 使用 REST API 中按模型划分的令牌明细
Per-model token breakdown in the AI usage REST API
导读
GitHub 的 AI 用量 REST API 现在可以按模型返回 AI 额度所对应的 token 明细。企业、组织和个人三类用量端点均会返回六项原始 token 计数,涵盖输入、输出、图像输入输出及缓存读写,不含定价或折扣调整;这些计数沿用 AI 用量报告的定义,并遵循端点已有的时间、用户和模型筛选条件。已使用这些端点的用户无需改动权限即可在响应中看到新字段,计数一般从 2026 年 12 月 1 日的用量开始提供,此前时段的 token 字段返回 0。
正在把原文翻译成中文,长文需要一两分钟;先显示原文。
Improvement
December 2, 20261 minute read
You can now get a per-model breakdown of the tokens behind your AI credits from the GitHub REST API. The following AI credit usage endpoints return token counts:
- Enterprise:
GET /enterprises/{enterprise}/settings/billing/ai_credit/usage - Organization:
GET /organizations/{org}/settings/billing/ai_credit/usage - User:
GET /users/{username}/settings/billing/ai_credit/usage
Each usage item includes six raw token counts, without pricing or discount adjustments:
tokenInput: Input tokens sent to the modeltokenOutput: Output tokens generated by the modeltokenImageInput: Image input tokens sent to the modeltokenImageOutput: Image output tokens generated by the modeltokenCacheRead: Cached tokens read by the modeltokenCacheWrite: Tokens written to the cache, excluding extended cache creation
The counts use the same definitions as the AI usage report, so you can pull token detail into your own dashboards and tools without downloading a report. They also respect the endpoints' existing filters, such as time period, user, and model.
If you already use the enterprise, organization, or user endpoints, the new fields appear in your responses with no changes to permissions. Token counts are available to admins on Copilot Business and Copilot Enterprise, and to anyone on Copilot for individuals.
Token counts generally start with usage on December 1, 2026. Customers with early access may have partial data from before that date. For periods before capture starts, token fields return 0. To see token detail for earlier usage, download the AI usage report from the AI usage page in your billing settings.
For more information, see the billing usage REST API documentation for enterprises and the billing usage REST API documentation for organizations and personal accounts.
出处
- S 官方GitHub Changelog · RSS阅读原文 ↗
Per-model token breakdown in the AI usage REST API