Tracking $.usage.total_tokens with AI Agents

Integrations

How do I capture the value of tokens used ($usage.total_tokens) when using the new AI Agents? I was able to do this previously using the retrieveRun call, but can't see how to do this with the new Agents feature. Since I have to pay for token usage when my users interact with AI on my website, it is extremely important to track how many tokens my users have used so I can charge them accordingly. My website model is a pay-for-usage structure rather than a subscription structure

What have you tried so far?

Attempting to use the output from AI Agent (my agent has text output selected) to update a page state variable called tokensUsed (Integer). This will then decrement a Firebase collection which tracks the total tokens a user has on credit.

Did you check FlutterFlow's Documentation for this topic?
Yes
1
1 reply