feat(usage): let chat callers see their own quota and conversation cost - #74
Merged
Merged
Conversation
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
…dmins Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… usage Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…rrors Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… the raw message Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Without a userId the upsert filter matched an arbitrary usage document of the owner (an external user's record or the untrusted pool). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The gate is awaited before the finish chunk, so it is never pending there. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
'user1' is not a role: it mapped to no quota, so these members could not exercise the simple-user profile. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Any chat caller (org member, external user, anonymous visitor, account owner) can now see their own AI quota and what the current conversation has cost.
GET /api/gateway/:type/:id/usagereturns the caller's daily/weekly/monthly windows (used, limit, reset date), resolved with the same identity as a completion. The org credit cap and the anonymous+external pool are reported as a status (ok/exhausted+ reset date); their numbers are only shown to admins of the account.usage.costin credits (OpenRouter's convention), including the moderation check when its verdict settles before the gate opens.periodandresets_at, drop the shared budgets' numbers for non-admins, are no longer retried client-side, and render as a localized message ("Your daily AI quota is used up. It resets on …").recordUsagewithout a userId (owner of a user account) could increment an arbitrary usage document of that owner, e.g. an external user's record.test1-user1/dev1-user1had the non-existent org roleuser1; nowuser.Why: a user should be able to see their own quotas and consumption, including the current conversation's.
Heads-up:
account/untrustedscopes,usage/limitare now omitted unless the caller is an admin;periodis added.GET /api/limits/:type/:id(unchanged, intentional), so the redaction mainly protects shared budgets from external/anonymous callers.[DONE]).