# OpenAI tokens Usage via token\_counter function

**URL:** <https://community.glideapps.com/t/openai-tokens-usage-via-token-counter-function/65355>\
**Category:** Feature Requests\
**Tags:** ai\
**Created:** [August 24, 2023, 4:27pm UTC](https://community.glideapps.com/t/openai-tokens-usage-via-token-counter-function/65355 "2023-08-24T16:27:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bio\_Sam](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/bio_sam/32/66023_2.png) [@Bio\_Sam](https://community.glideapps.com/u/Bio_Sam)\
**Post date:** [August 24, 2023, 4:27pm UTC](https://community.glideapps.com/t/openai-tokens-usage-via-token-counter-function/65355/1 "2023-08-24T16:27:06Z")

</div>

Hello,

I’m trying to integrate the **token\_counter function** into Glide. I’m currently developing statistics for my app and need to accurately track my usage. My current method, which calculates based on input and output word counts, isn’t precise. It doesn’t distinguish between different languages, and some tokens comprise multiple words.

While it’s straightforward to achieve this with Python, I haven’t found a way to do it within Glide’s existing features. Is there a possible solution or workaround?

---

<div class="post-metadata">

**Author:** ![Eric\_Penn](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/eric_penn/32/73888_2.png) [@Eric\_Penn](https://community.glideapps.com/u/Eric_Penn)\
**Post date:** [August 25, 2023, 11:10am UTC](https://community.glideapps.com/t/openai-tokens-usage-via-token-counter-function/65355/2 "2023-08-25T11:10:47Z")

</div>

What exactly does the Python code do? Maybe it could be done with the JS column

---

<div class="post-metadata">

**Author:** ![Bio\_Sam](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/bio_sam/32/66023_2.png) [@Bio\_Sam](https://community.glideapps.com/u/Bio_Sam)\
**Post date:** [August 30, 2023, 9:30am UTC](https://community.glideapps.com/t/openai-tokens-usage-via-token-counter-function/65355/4 "2023-08-30T09:30:43Z")

</div>

It gives the number of tokens that OPEN AI used in the current API call. I’d love to solve my problem using JavaScript for this, if possible, but I’m unsure of how to proceed at the moment. I’ve set actions to “Send message to ChatGPT without history” and am a bit unclear on how to connect this Glide integration using a JS column.
