Copilot 用量指标 API 新增对 OpenCode 等工具的使用量统计
英文标题:Usage metrics API adds usage from tools like OpenCode
GitHub Copilot 用量指标 API 现已支持追踪 IDE 之外更多第三方工具的模型使用情况,包括此前未被纳入报告的 OpenCode、Claude Code、Zed 等客户端。在企业和组织维度的 1 天与 28 天报告中,新增的 `totals_by_client` 数组能够清晰提供各工具的请求数、会话数及 Token 消耗。这一更新弥补了因缺乏编辑器遥测而导致的统计盲区,为企业团队评估各 AI 工具真实流量、制定工具支持和治理策略提供了可靠依据。
178.0 KB
中文
Copilot 用量指标(Usage metrics)API 现已开始统计开发者配合 Copilot 使用的更多工具的模型用量,其中包括此前未被纳入报告的 OpenCode 等工具。在企业(enterprise)、组织(organization)、企业用户(enterprise-user)和组织用户(organization-user)的 1 天和 28 天报告中,现已提供全新的 totals_by_client 数组。
每个 totals_by_client 条目代表一个客户端,包含以下内容:
client:发送请求的工具,例如opencode、claude_code、codex、zed、copilot_cli、github_app、cloud_agent、code_review、vscode或jetbrains。无法识别的客户端会归入other。request_count:来自该客户端的成功模型请求数。session_count:来自该客户端的独立会话数。token_usage:Prompt Token、输出 Token 以及每个请求的平均 Token 数。totals_by_model:按模型细分的相同请求与 Token 指标,包含一个model_selection_mode(模型选择模式),用于显示模型是直接请求的(user_selected)、自动选择的(auto),还是由产品选择的(product_selected)。尚未单独报告的选择模式将显示为other,无法规范化的值将显示为unknown。
现在有越来越多的开发者将 Copilot 作为 IDE 外部工具背后的模型提供商。由于这些工具通常不发送编辑器遥测数据,因此其用量在 totals_by_ide 中有所缺失且难以统计。通过在服务端对请求进行计数弥补了这一空白,使您能够查看哪些工具带动了 Copilot 的使用、比较它们之间的请求量与 Token 消耗,并基于真实的使用情况来制定工具支持和治理决策。
这与 Agent 应用活动(agent app activity) 不同,后者统计的是 Claude 和 Codex 等 Agent 应用在 GitHub 上启动的任务(jobs)。而 totals_by_client 衡量的是来自任何使用 Copilot 的工具的模型流量(即请求数和 Token 数)。
- 适用范围(Scope): 企业、组织、企业用户以及组织用户报告,支持 1 天和 28 天两个版本。在汇总的 28 天报告中,
totals_by_client会出现在每个day_totals条目中。 - 访问权限(Access): 面向企业所有者、账单管理员、组织所有者,以及任何拥有授予了“View Copilot Metrics”权限的自定义组织或企业角色的用户开放。必须启用 Copilot 用量指标策略(Copilot usage metrics policy)。
- Copilot 代码审查与 Copilot 云端 Agent(Copilot code review and Copilot cloud agent): 来自这些客户端的请求会报告为
product_selected,因为是由产品选择模型。Copilot 代码审查模型报告为unknown。 - 请求计数(Request counts):
request_count统计的是模型调用次数,而非提示词(prompts)次数。单个提示词可能会触发多次模型调用,因此请勿将此字段直接与提示词或交互次数进行对比。 - 客户端识别(Client identification): 客户端通过每次请求时发送的集成 ID(integration ID)进行识别。请将
client视为一种尽力而为(best-effort)的分组,而非经过严格验证的身份标识。 - 向后兼容性(Backward compatibility): 本次变更为增量更新。现有字段保持不变,在没有需要报告的用量时,
totals_by_client将返回空数组。
访问 Copilot 用量指标 API 文档 即可开始使用。
English / 原文
The Copilot usage metrics API now reports model usage from more of the tools your developers use with Copilot, including tools like OpenCode that weren’t previously captured in your reports. A new totals_by_client array is available in the enterprise, organization, enterprise-user, and organization-user 1-day and 28-day reports.
Each totals_by_client entry represents one client and includes:
client: The tool that sent the requests, such asopencode,claude_code,codex,zed,copilot_cli,github_app,cloud_agent,code_review,vscode, orjetbrains. Unrecognized clients are grouped underother.request_count: The number of successful model requests from the client.session_count: The number of distinct sessions from the client.token_usage: Prompt tokens, output tokens, and average tokens per request.totals_by_model: The same request and token metrics broken down by model, with amodel_selection_modethat shows whether the model was requested directly (user_selected), chosen by auto (auto), or chosen by the product (product_selected). Selection modes that aren’t reported individually yet appear asother, and values that can’t be normalized appear asunknown.
More developers now use Copilot as the model provider behind tools outside the IDE. Because those tools often don’t send editor telemetry, their usage was missing from totals_by_ide and hard to account for. Counting requests on the server closes that gap, so you can see which tools drive Copilot usage, compare request and token volume across them, and base tool support and governance decisions on real usage.
This is different from agent app activity, which counts jobs started by agent apps such as Claude and Codex on GitHub. totals_by_client measures model traffic, meaning requests and tokens, from any tool that uses Copilot.
- Scope: Enterprise, organization, enterprise-user, and organization-user reports, in both 1-day and 28-day versions. In the aggregated 28-day reports,
totals_by_clientappears in eachday_totalsentry. - Access: Available to enterprise owners and billing managers, organization owners, and anyone with a custom organization or enterprise role that grants the
View Copilot Metricspermission. The Copilot usage metrics policy must be enabled. - Copilot code review and Copilot cloud agent: Requests from these clients report
product_selectedbecause the product chooses the model. Copilot code review models are reported asunknown. - Request counts:
request_countcounts model calls, not prompts. One prompt can trigger several model calls, so don’t compare this field directly with prompt or interaction counts. - Client identification: Clients are identified by the integration ID they send with each request. Treat
clientas a best-effort grouping, not a verified identity. - Backward compatibility: This change is additive. Existing fields are unchanged, and
totals_by_clientis an empty array when there is no usage to report.
Visit the Copilot usage metrics API documentation to get started.