Associating token usage of stream to user for billing purposes #232
nikas-belogolov
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm implementing server-side usage tracking in a TanStack Start app. I want to track each user's token usage, but currently there doesnt seem to be a way to do this without intercepting the text stream and checking if chunk is of type "done" to get token usage:
What is the recommended way of associating token usage of a stream to a certain user for billing? I think it's a pretty basic thing for a SaSS apps but I haven't found a good way to do this yet.
Maybe add callbacks to the chat function similar to AI SDK? Or fix aiEventClient to include also other metadata
Beta Was this translation helpful? Give feedback.
All reactions