Aias00 opened a new issue, #7934:
URL: https://github.com/apache/shenyu/issues/7934

   ## Goal
   Allow operators to explain AI usage and estimated cost by 
tenant/application, provider and actual model, then reconcile those records 
with provider reports.
   
   ## Existing capabilities and boundary
   #7702 and PR #7848 own token-budget reservations and settlement. #7911 
addresses missing Responses-protocol usage accounting. Reuse normalized usage 
and settlement observations; do not implement a second admission counter or 
present reserved estimates as actual billed usage.
   
   ## MVP
   - Define a versioned usage event: namespace/authorized tenant/application, 
provider, requested/resolved model where known, operation/attempt identity, 
timestamps, protocol, final outcome and available token categories.
   - Distinguish provider-reported usage, estimated usage, reported zero and 
unavailable usage. Record attempted upstream work separately from the final 
logical request so retries/fallback costs are attributable without double 
counting.
   - Attach a versioned operator-supplied price schedule with effective dates, 
currency and supported categories (for example input, output and cached 
tokens). Preserve the price version and raw normalized quantities needed to 
recompute an estimate.
   - Add bounded asynchronous delivery to a pluggable ledger sink and basic 
aggregation/export. Define delivery guarantees, idempotency keys, retention and 
failure visibility; do not block gateway traffic on a remote billing database.
   - Begin with one documented provider/protocol and fixed token pricing. 
Reconciliation against provider exports can be a follow-up; negotiated 
discounts, taxes and unsupported pricing must remain explicit unknowns.
   
   ## Acceptance criteria
   - [ ] Buffered and streaming success, failure, cancellation, missing usage, 
retry and fallback cases create correctly scoped records with no false exact 
cost.
   - [ ] Duplicate delivery is idempotent within a documented retention window; 
queue overflow/crash loss is observable and the delivery guarantee is stated 
honestly.
   - [ ] Historical estimates retain their original price version; revaluation 
produces a separate auditable result rather than silently rewriting history.
   - [ ] Tenant authorization applies to queries/exports. Prompts, responses 
and credentials are excluded by default; event volume, cardinality and 
retention are bounded.
   - [ ] Usage extraction is shared with existing accounting and tested across 
supported formats, including #7911's protocol distinction.
   - [ ] A small fixture reconciles ledger totals, attempts and price 
calculations against known inputs; unavailable pricing is never displayed as 
zero cost.
   
   Related: #7702, PR #7848 and #7911. Cost values are estimates unless a 
provider reconciliation establishes otherwise.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to