Algorithm · Stripe · Medium
Design a billing module for a chat-oriented AI service that invoices clients according to token consumption. Every chat interaction generates an entry containing a user_id, the number of input_tokens, the number of output_tokens, and a plan identifier. Given sessions, a collection of monthly chat interaction entries, compute the total spending for each user. A single user may have several records within sessions, each corresponding to one chat interaction during the billing…
Checking your access…