Token counter in stream. Help

I can’t find a way to count the tokens using stream.
Has anyone achieved it?
I can’t find a way to carry out a count using this function.

I can just count each message’ token and sum them up after the stream ends.

The completion chain in this mode does not offer the number of tokens sent, I can count those generated but not those sent.

Yeah, we should count both input + output manually.

1 Like

After deleting and returning to the complete answers with the accurate token count, I give up on further attempts and tests.
There is no way, the consumption that the website reflects is always higher, very very higher.
I have carried out a thousand tests to rule out compromised equipment, compromised internet lines, I have generated keys in a 100% secure manner and I do not expose them…
The consumption of API is brutal and uncontrolled, even exceeding the established consumption limits.
I am desperate and I have not received a response from openai, I have been sending them messages for a week without getting any response.