Skip to content

feat: Add GetAICreditUsage endpoint for organization AI credits#4282

Open
maishivamhoo123 wants to merge 3 commits into
google:masterfrom
maishivamhoo123:billing/ai-credit-usage
Open

feat: Add GetAICreditUsage endpoint for organization AI credits#4282
maishivamhoo123 wants to merge 3 commits into
google:masterfrom
maishivamhoo123:billing/ai-credit-usage

Conversation

@maishivamhoo123
Copy link
Copy Markdown
Contributor

Closes #4262

Adds the GetAICreditUsage method to BillingService to support the
GET /organizations/{org}/settings/billing/ai_credit/usage endpoint.

Changes:

  • Reuses PremiumRequestUsageReportOptions and PremiumRequestUsageReport
    since the request/response shapes are identical
  • Adds unit tests covering successful response, float quantities, invalid
    org, and request/do failure
  • All code lives in the existing billing.go and billing_test.go files
    per reviewer feedback from feat: Add GetAICreditUsage endpoint for organization AI credits #4264

Signed-off-by: maishivamhoo123 <maishivamhoo@gmail.com>
@maishivamhoo123
Copy link
Copy Markdown
Contributor Author

@gmlewis I updated the code in billing.go as Recommended by @alexandear Ready for Review
Thank you!

@gmlewis gmlewis changed the title billing: add GetAICreditUsage endpoint for organization AI credits feat: Add GetAICreditUsage endpoint for organization AI credits Jun 5, 2026
@gmlewis
Copy link
Copy Markdown
Collaborator

gmlewis commented Jun 5, 2026

It looks like #4281 and #4282 have overlapping functionality.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.49%. Comparing base (531d1cf) to head (67ed937).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4282   +/-   ##
=======================================
  Coverage   97.49%   97.49%           
=======================================
  Files         192      192           
  Lines       19230    19243   +13     
=======================================
+ Hits        18748    18761   +13     
  Misses        267      267           
  Partials      215      215           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@maishivamhoo123
Copy link
Copy Markdown
Contributor Author

@gmlewis @Not-Dhananjay-Mishra can you please review this?
Thank you!

@gmlewis
Copy link
Copy Markdown
Collaborator

gmlewis commented Jun 5, 2026

@gmlewis @Not-Dhananjay-Mishra can you please review this? Thank you!

Are you interested in supporting the User endpoint in addition to the Organization endpoint in this PR as demonstrated by #4281, or what are your plans for this?

It seems to me like having a GetOrgAICreditUsage and GetUserAICreditUsage side-by-side would be extremely useful.

Thoughts?

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Jun 5, 2026
Comment thread github/billing.go
// GitHub API docs: https://docs.github.com/rest/billing/usage?apiVersion=2022-11-28#get-billing-ai-credit-usage-report-for-an-organization
//
//meta:operation GET /organizations/{org}/settings/billing/ai_credit/usage
func (s *BillingService) GetAICreditUsage(ctx context.Context, org string, opts *PremiumRequestUsageReportOptions) (*PremiumRequestUsageReport, *Response, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func (s *BillingService) GetAICreditUsage(ctx context.Context, org string, opts *PremiumRequestUsageReportOptions) (*PremiumRequestUsageReport, *Response, error) {
func (s *BillingService) GetOrgAICreditUsage(ctx context.Context, org string, opts *PremiumRequestUsageReportOptions) (*PremiumRequestUsageReport, *Response, error) {

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

Labels

NeedsReview PR is awaiting a review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for AI Credit billing endpoint

3 participants