You probably aren’t doing anything wrong. The bits of data (token usage stats) that you want to access probably just aren’t passed along or exposed in any way you can use in a workflow. There’s a discussion about this already here where various things were tried, but I don’t think anything ever worked.
There is a relatively highly voted feature request about this, if you want to add your vote to it.