{"meta":{"title":"使用情况计费","intro":"使用 REST API 获取计费使用情况信息。","product":"REST API","breadcrumbs":[{"href":"/zh/rest","title":"REST API"},{"href":"/zh/rest/billing","title":"计费"},{"href":"/zh/rest/billing/usage","title":"使用情况计费"}],"documentType":"article"},"body":"# 使用情况计费\n\n使用 REST API 获取计费使用情况信息。\n\n此页面上的终结点将返回与终结点关联的帐户将计费的使用情况。 有关确定要报告的使用情况级别的帮助，请参阅 [使用 REST API 自动报告使用情况](/zh/billing/tutorials/automate-usage-reporting#step-1-decide-what-level-to-report-on)。\n\n* 用户终结点将返回直接计费到各个用户的个人帐户的 Copilot 使用情况。 仅当用户购买了自己的 Copilot 计划时，这些端点才适用。\n* 如果通过组织或企业对用户的 Copilot 许可证进行管理和计费，则用户级终结点中不会包括其使用情况。 在这种情况下，必须改用组织或企业级终结点。\n\n若要查看企业级终结点，请选择页面顶部的下拉菜单，然后从免费、专业、& 团队切换到 GitHub Enterprise Cloud。\n\n> \\[!NOTE]\n> Most endpoints use `Authorization: Bearer <YOUR-TOKEN>` and `Accept: application/vnd.github+json` headers, plus `X-GitHub-Api-Version: 2026-03-10`. Curl examples below omit these standard headers for brevity.\n\n## Get billing AI credit usage report for an organization\n\n```\nGET /organizations/{org}/settings/billing/ai_credit/usage\n```\n\nGets a report of AI credit usage for an organization. To use this endpoint, you must be an administrator of an organization within an enterprise or an organization account.\nNote: Only data from the past 24 months is accessible via this endpoint.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n* **`year`** (integer)\n  If specified, only return results for a single year. The value of year is an integer with four digits representing a year. For example, 2025. Default value is the current year.\n\n* **`month`** (integer)\n  If specified, only return results for a single month. The value of month is an integer between 1 and 12. Default value is the current month. If no year is specified the default year is used.\n\n* **`day`** (integer)\n  If specified, only return results for a single day. The value of day is an integer between 1 and 31. If no year or month is specified, the default year and month are used.\n\n* **`user`** (string)\n  The user name to query usage for. The name is not case sensitive.\n\n* **`model`** (string)\n  The model name to query usage for. The name is not case sensitive.\n\n* **`product`** (string)\n  The product name to query usage for. The name is not case sensitive.\n\n### HTTP response status codes\n\n* **200** - Response when getting a billing AI credit usage report\n\n* **400** - Bad Request\n\n* **403** - Forbidden\n\n* **404** - Resource not found\n\n* **500** - Internal Error\n\n* **503** - Service unavailable\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/organizations/ORG/settings/billing/ai_credit/usage\n```\n\n**Response schema (Status: 200):**\n\n* `timePeriod`: required, object:\n  * `year`: required, integer\n  * `month`: integer\n  * `day`: integer\n* `organization`: required, string\n* `user`: string\n* `product`: string\n* `model`: string\n* `usageItems`: required, array of objects:\n  * `product`: required, string\n  * `sku`: required, string\n  * `model`: required, string\n  * `unitType`: required, string\n  * `pricePerUnit`: required, number\n  * `grossQuantity`: required, number\n  * `grossAmount`: required, number\n  * `discountQuantity`: required, number\n  * `discountAmount`: required, number\n  * `netQuantity`: required, number\n  * `netAmount`: required, number\n\n## Get billing premium request usage report for an organization\n\n```\nGET /organizations/{org}/settings/billing/premium_request/usage\n```\n\nGets a report of premium request usage for an organization. To use this endpoint, you must be an administrator of an organization within an enterprise or an organization account.\nNote: Only data from the past 24 months is accessible via this endpoint.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n* **`year`** (integer)\n  If specified, only return results for a single year. The value of year is an integer with four digits representing a year. For example, 2025. Default value is the current year.\n\n* **`month`** (integer)\n  If specified, only return results for a single month. The value of month is an integer between 1 and 12. Default value is the current month. If no year is specified the default year is used.\n\n* **`day`** (integer)\n  If specified, only return results for a single day. The value of day is an integer between 1 and 31. If no year or month is specified, the default year and month are used.\n\n* **`user`** (string)\n  The user name to query usage for. The name is not case sensitive.\n\n* **`model`** (string)\n  The model name to query usage for. The name is not case sensitive.\n\n* **`product`** (string)\n  The product name to query usage for. The name is not case sensitive.\n\n### HTTP response status codes\n\n* **200** - Response when getting a billing premium request usage report\n\n* **400** - Bad Request\n\n* **403** - Forbidden\n\n* **404** - Resource not found\n\n* **500** - Internal Error\n\n* **503** - Service unavailable\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/organizations/ORG/settings/billing/premium_request/usage\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Get billing AI credit usage report for an organization](#get-billing-ai-credit-usage-report-for-an-organization).\n\n## Get billing usage report for an organization\n\n```\nGET /organizations/{org}/settings/billing/usage\n```\n\nGets a report of the total usage for an organization. To use this endpoint, you must be an administrator of an organization within an enterprise or an organization account.\nNote: This endpoint is only available to organizations with access to the enhanced billing platform. For more information, see \"About the enhanced billing platform.\"\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n* **`year`** (integer)\n  If specified, only return results for a single year. The value of year is an integer with four digits representing a year. For example, 2025. Default value is the current year.\n\n* **`month`** (integer)\n  If specified, only return results for a single month. The value of month is an integer between 1 and 12. If no year is specified the default year is used.\n\n* **`day`** (integer)\n  If specified, only return results for a single day. The value of day is an integer between 1 and 31. If no year or month is specified, the default year and month are used.\n\n### HTTP response status codes\n\n* **200** - Billing usage report response for an organization\n\n* **400** - Bad Request\n\n* **403** - Forbidden\n\n* **500** - Internal Error\n\n* **503** - Service unavailable\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/organizations/ORG/settings/billing/usage\n```\n\n**Response schema (Status: 200):**\n\n* `usageItems`: array of objects:\n  * `date`: required, string\n  * `product`: required, string\n  * `sku`: required, string\n  * `quantity`: required, integer\n  * `unitType`: required, string\n  * `pricePerUnit`: required, number\n  * `grossAmount`: required, number\n  * `discountAmount`: required, number\n  * `netAmount`: required, number\n  * `organizationName`: required, string\n  * `repositoryName`: string\n\n## Get billing usage summary for an organization\n\n```\nGET /organizations/{org}/settings/billing/usage/summary\n```\n\nNote\n\nThis endpoint is in public preview and is subject to change.\n\nGets a summary report of usage for an organization. To use this endpoint, you must be an administrator of an organization within an enterprise or an organization account.\nNote: Only data from the past 24 months is accessible via this endpoint.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`org`** (string) (required)\n  The organization name. The name is not case sensitive.\n\n* **`year`** (integer)\n  If specified, only return results for a single year. The value of year is an integer with four digits representing a year. For example, 2025. Default value is the current year.\n\n* **`month`** (integer)\n  If specified, only return results for a single month. The value of month is an integer between 1 and 12. Default value is the current month. If no year is specified the default year is used.\n\n* **`day`** (integer)\n  If specified, only return results for a single day. The value of day is an integer between 1 and 31. If no year or month is specified, the default year and month are used.\n\n* **`repository`** (string)\n  The repository name to query for usage in the format owner/repository.\n\n* **`product`** (string)\n  The product name to query usage for. The name is not case sensitive.\n\n* **`sku`** (string)\n  The SKU to query for usage.\n\n### HTTP response status codes\n\n* **200** - Response when getting a billing usage summary\n\n* **400** - Bad Request\n\n* **403** - Forbidden\n\n* **500** - Internal Error\n\n* **503** - Service unavailable\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/organizations/ORG/settings/billing/usage/summary\n```\n\n**Response schema (Status: 200):**\n\n* `timePeriod`: required, object:\n  * `year`: required, integer\n  * `month`: integer\n  * `day`: integer\n* `organization`: required, string\n* `repository`: string\n* `product`: string\n* `sku`: string\n* `usageItems`: required, array of objects:\n  * `product`: required, string\n  * `sku`: required, string\n  * `unitType`: required, string\n  * `pricePerUnit`: required, number\n  * `grossQuantity`: required, number\n  * `grossAmount`: required, number\n  * `discountQuantity`: required, number\n  * `discountAmount`: required, number\n  * `netQuantity`: required, number\n  * `netAmount`: required, number\n\n## Get billing AI credit usage report for a user\n\n```\nGET /users/{username}/settings/billing/ai_credit/usage\n```\n\nGets a report of AI credit usage for a user.\nNote: Only data from the past 24 months is accessible via this endpoint.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`username`** (string) (required)\n  The handle for the GitHub user account.\n\n* **`year`** (integer)\n  If specified, only return results for a single year. The value of year is an integer with four digits representing a year. For example, 2025. Default value is the current year.\n\n* **`month`** (integer)\n  If specified, only return results for a single month. The value of month is an integer between 1 and 12. Default value is the current month. If no year is specified the default year is used.\n\n* **`day`** (integer)\n  If specified, only return results for a single day. The value of day is an integer between 1 and 31. If no year or month is specified, the default year and month are used.\n\n* **`model`** (string)\n  The model name to query usage for. The name is not case sensitive.\n\n* **`product`** (string)\n  The product name to query usage for. The name is not case sensitive.\n\n### HTTP response status codes\n\n* **200** - Response when getting a billing AI credit usage report\n\n* **400** - Bad Request\n\n* **403** - Forbidden\n\n* **404** - Resource not found\n\n* **500** - Internal Error\n\n* **503** - Service unavailable\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/users/USERNAME/settings/billing/ai_credit/usage\n```\n\n**Response schema (Status: 200):**\n\n* `timePeriod`: required, object:\n  * `year`: required, integer\n  * `month`: integer\n  * `day`: integer\n* `user`: required, string\n* `product`: string\n* `model`: string\n* `usageItems`: required, array of objects:\n  * `product`: required, string\n  * `sku`: required, string\n  * `model`: required, string\n  * `unitType`: required, string\n  * `pricePerUnit`: required, number\n  * `grossQuantity`: required, number\n  * `grossAmount`: required, number\n  * `discountQuantity`: required, number\n  * `discountAmount`: required, number\n  * `netQuantity`: required, number\n  * `netAmount`: required, number\n\n## Get billing premium request usage report for a user\n\n```\nGET /users/{username}/settings/billing/premium_request/usage\n```\n\nGets a report of premium request usage for a user.\nNote: Only data from the past 24 months is accessible via this endpoint.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`username`** (string) (required)\n  The handle for the GitHub user account.\n\n* **`year`** (integer)\n  If specified, only return results for a single year. The value of year is an integer with four digits representing a year. For example, 2025. Default value is the current year.\n\n* **`month`** (integer)\n  If specified, only return results for a single month. The value of month is an integer between 1 and 12. Default value is the current month. If no year is specified the default year is used.\n\n* **`day`** (integer)\n  If specified, only return results for a single day. The value of day is an integer between 1 and 31. If no year or month is specified, the default year and month are used.\n\n* **`model`** (string)\n  The model name to query usage for. The name is not case sensitive.\n\n* **`product`** (string)\n  The product name to query usage for. The name is not case sensitive.\n\n### HTTP response status codes\n\n* **200** - Response when getting a billing premium request usage report\n\n* **400** - Bad Request\n\n* **403** - Forbidden\n\n* **404** - Resource not found\n\n* **500** - Internal Error\n\n* **503** - Service unavailable\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/users/USERNAME/settings/billing/premium_request/usage\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Get billing AI credit usage report for a user](#get-billing-ai-credit-usage-report-for-a-user).\n\n## Get billing usage report for a user\n\n```\nGET /users/{username}/settings/billing/usage\n```\n\nGets a report of the total usage for a user.\nNote: This endpoint is only available to users with access to the enhanced billing platform.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`username`** (string) (required)\n  The handle for the GitHub user account.\n\n* **`year`** (integer)\n  If specified, only return results for a single year. The value of year is an integer with four digits representing a year. For example, 2025. Default value is the current year.\n\n* **`month`** (integer)\n  If specified, only return results for a single month. The value of month is an integer between 1 and 12. If no year is specified the default year is used.\n\n* **`day`** (integer)\n  If specified, only return results for a single day. The value of day is an integer between 1 and 31. If no year or month is specified, the default year and month are used.\n\n### HTTP response status codes\n\n* **200** - Response when getting a billing usage report\n\n* **400** - Bad Request\n\n* **403** - Forbidden\n\n* **500** - Internal Error\n\n* **503** - Service unavailable\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/users/USERNAME/settings/billing/usage\n```\n\n**Response schema (Status: 200):**\n\n* `usageItems`: array of objects:\n  * `date`: required, string\n  * `product`: required, string\n  * `sku`: required, string\n  * `quantity`: required, integer\n  * `unitType`: required, string\n  * `pricePerUnit`: required, number\n  * `grossAmount`: required, number\n  * `discountAmount`: required, number\n  * `netAmount`: required, number\n  * `repositoryName`: string\n\n## Get billing usage summary for a user\n\n```\nGET /users/{username}/settings/billing/usage/summary\n```\n\nNote\n\nThis endpoint is in public preview and is subject to change.\n\nGets a summary report of usage for a user.\nNote: Only data from the past 24 months is accessible via this endpoint.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`username`** (string) (required)\n  The handle for the GitHub user account.\n\n* **`year`** (integer)\n  If specified, only return results for a single year. The value of year is an integer with four digits representing a year. For example, 2025. Default value is the current year.\n\n* **`month`** (integer)\n  If specified, only return results for a single month. The value of month is an integer between 1 and 12. Default value is the current month. If no year is specified the default year is used.\n\n* **`day`** (integer)\n  If specified, only return results for a single day. The value of day is an integer between 1 and 31. If no year or month is specified, the default year and month are used.\n\n* **`repository`** (string)\n  The repository name to query for usage in the format owner/repository.\n\n* **`product`** (string)\n  The product name to query usage for. The name is not case sensitive.\n\n* **`sku`** (string)\n  The SKU to query for usage.\n\n### HTTP response status codes\n\n* **200** - Response when getting a billing usage summary\n\n* **400** - Bad Request\n\n* **403** - Forbidden\n\n* **404** - Resource not found\n\n* **500** - Internal Error\n\n* **503** - Service unavailable\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  https://api.github.com/users/USERNAME/settings/billing/usage/summary\n```\n\n**Response schema (Status: 200):**\n\n* `timePeriod`: required, object:\n  * `year`: required, integer\n  * `month`: integer\n  * `day`: integer\n* `user`: required, string\n* `repository`: string\n* `product`: string\n* `sku`: string\n* `usageItems`: required, array of objects:\n  * `product`: required, string\n  * `sku`: required, string\n  * `unitType`: required, string\n  * `pricePerUnit`: required, number\n  * `grossQuantity`: required, number\n  * `grossAmount`: required, number\n  * `discountQuantity`: required, number\n  * `discountAmount`: required, number\n  * `netQuantity`: required, number\n  * `netAmount`: required, number"}