Skip to content

feat: Add AI credit billing usage reports#4281

Open
bulutmuf wants to merge 2 commits into
google:masterfrom
bulutmuf:feat/ai-credit-billing-usage
Open

feat: Add AI credit billing usage reports#4281
bulutmuf wants to merge 2 commits into
google:masterfrom
bulutmuf:feat/ai-credit-billing-usage

Conversation

@bulutmuf
Copy link
Copy Markdown
Contributor

@bulutmuf bulutmuf commented Jun 5, 2026

Summary

Add support for the AI credit usage billing endpoints for organizations and users.

This adds typed request options, response models, and BillingService methods for the new AI credit usage reports. The implementation follows the existing enhanced billing and premium request usage report patterns.

Closes #4262.

Changes

  • Add AI credit usage report option, response, time period, and usage item types
  • Add GetOrganizationAICreditUsageReport
  • Add GetAICreditUsageReport
  • Add coverage for request paths, query parameters, response decoding, invalid URLs, and request/do failures
  • Regenerate accessors for the new public types

Testing

  • go test ./github -run 'TestBillingService_Get.*AICreditUsageReport'\n- go test ./github\n- go test -race -covermode atomic ./github\n- script/generate.sh --check\n- script/fmt.sh\n- script/test.sh ./...\n- script/lint.sh\n- git diff --check

bulutmuf added 2 commits June 5, 2026 14:09
Add organization and user billing methods for the AI credit usage endpoints.

Cover request routing, query parameters, response decoding, and failure paths.
Regenerate accessor helpers and tests for the new AI credit billing usage types.
@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 (7290489) to head (f492be7).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4281   +/-   ##
=======================================
  Coverage   97.49%   97.49%           
=======================================
  Files         192      192           
  Lines       19230    19256   +26     
=======================================
+ Hits        18748    18774   +26     
  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.

@gmlewis
Copy link
Copy Markdown
Collaborator

gmlewis commented Jun 5, 2026

@bulutmuf - issue #4262 was assigned to @maishivamhoo123 and we do this to prevent duplicated effort, which happened here.

The interesting thing is that upon casual review, it appears that your implementation supports both organizations and users, which the other implementation does not. It also appears that you introduced new structs that were possibly not necessary.

Let's see what @maishivamhoo123 and @alexandear have to say, but I'm thinking now based purely on the assignment, that we will most likely be closing this PR without merging.

@bulutmuf
Copy link
Copy Markdown
Contributor Author

bulutmuf commented Jun 5, 2026

@bulutmuf - issue #4262 was assigned to @maishivamhoo123 and we do this to prevent duplicated effort, which happened here.

The interesting thing is that upon casual review, it appears that your implementation supports both organizations and users, which the other implementation does not. It also appears that you introduced new structs that were possibly not necessary.

Let's see what @maishivamhoo123 and @alexandear have to say, but I'm thinking now based purely on the assignment, that we will most likely be closing this PR without merging.

Thanks for the context. I missed that #4262 had already been assigned, sorry for the duplicated effort.

I'm happy to defer to @maishivamhoo123's PR. If any part of this implementation is useful, especially the user-level endpoint coverage or the tests, feel free to reuse it. I can also adjust this PR if maintainers prefer a narrower version that builds on the assigned work.

@maishivamhoo123
Copy link
Copy Markdown
Contributor

maishivamhoo123 commented Jun 5, 2026

@bulutmuf - issue #4262 was assigned to @maishivamhoo123 and we do this to prevent duplicated effort, which happened here.

The interesting thing is that upon casual review, it appears that your implementation supports both organizations and users, which the other implementation does not. It also appears that you introduced new structs that were possibly not necessary.

Let's see what @maishivamhoo123 and @alexandear have to say, but I'm thinking now based purely on the assignment, that we will most likely be closing this PR without merging.

@bulutmuf, I'm sorry—I didn't realize you had already opened this PR. Kudos to you; this is a really nice implementation.

While reviewing it, I noticed that some duplicate structs were introduced, which I think we could avoid by reusing the existing models. Apart from that, it's a great contribution.

And thank you, @gmlewis, for considering my PR.

@bulutmuf
Copy link
Copy Markdown
Contributor Author

bulutmuf commented Jun 5, 2026

@bulutmuf - issue #4262 was assigned to @maishivamhoo123 and we do this to prevent duplicated effort, which happened here.
The interesting thing is that upon casual review, it appears that your implementation supports both organizations and users, which the other implementation does not. It also appears that you introduced new structs that were possibly not necessary.
Let's see what @maishivamhoo123 and @alexandear have to say, but I'm thinking now based purely on the assignment, that we will most likely be closing this PR without merging.

@bulutmuf, I'm sorry—I didn't realize you had already opened this PR. Kudos to you; this is a really nice implementation.

While reviewing it, I noticed that some duplicate structs were introduced, which I think we could avoid by reusing the existing models. Apart from that, it's a great contribution.

And thank you, @gmlewis, for considering my PR.

Thanks, @maishivamhoo123. I appreciate the kind words.

That makes sense. I agree that reusing the existing premium request usage models would keep the API surface smaller.

If #4282 moves forward for the organization endpoint, I'm happy to either close this PR or rework it into a narrow follow-up that only adds the user-level AI credit usage endpoint using the shared existing models.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for AI Credit billing endpoint

3 participants