# Limit the number of AI tokens a user can use in a day?

**URL:** https://meta.discourse.org/t/limit-the-number-of-ai-tokens-a-user-can-use-in-a-day/330500
**Category:** Feature
**Tags:** completed, ai
**Created:** [October 11, 2024, 8:59pm UTC](https://meta.discourse.org/t/limit-the-number-of-ai-tokens-a-user-can-use-in-a-day/330500 "2024-10-11T20:59:12Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![Shauny](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/shauny/32/362012_2.png) [@Shauny](https://meta.discourse.org/u/Shauny)
#### Post date: [October 11, 2024, 8:59pm UTC](https://meta.discourse.org/t/limit-the-number-of-ai-tokens-a-user-can-use-in-a-day/330500/1 "2024-10-11T20:59:12Z")

</div>

If you give certain members access to AI, what is stopping them from using it all the time for their work etc., is there any way to limit how many tokens they can use per day or week etc?

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [October 11, 2024, 9:22pm UTC](https://meta.discourse.org/t/limit-the-number-of-ai-tokens-a-user-can-use-in-a-day/330500/2 "2024-10-11T21:22:07Z")

</div>

There isn’t such limitations when used Discourse AI, so the answer is plain nothing.

The other solution, Chatbot, has weekly limits how many request can be made.

So, you have to choose which one suits better for you. I use both. Chatbot for more general use inside my forum \[1\] and DAI is limited based by a group and (tuned) purposes using personas. So, I kind of exploit the best sides of both, because those two are only partly overlapping.

* * *

1. general means type of questions, otherwise it is tuned more specialized way

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [October 11, 2024, 10:23pm UTC](https://meta.discourse.org/t/limit-the-number-of-ai-tokens-a-user-can-use-in-a-day/330500/3 "2024-10-11T22:23:11Z")

</div>

Moving this to feature, we intend to add a quota system, it keeps popping up

I am thinking of just adding a group selectors with input/output counts and duration on each llm , so you can add optional quotas

---

<div class="post-metadata">

### Author: ![markschmucker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markschmucker/32/141599_2.png) [@markschmucker](https://meta.discourse.org/u/markschmucker)
#### Post date: [January 12, 2025, 9:35pm UTC](https://meta.discourse.org/t/limit-the-number-of-ai-tokens-a-user-can-use-in-a-day/330500/4 "2025-01-12T21:35:53Z")

</div>

I kinda need per-user (not per-group) rate limits now, so am trying to roll my own interim solution. Limiting the number of prompts instead of tokens would be fine. I’m thinking of a webhook on post\_event that says if it’s a PM and a user is posting to a bot, increment a custom field ‘ai\_query\_count’ on the user. I think that part would work.

Then what to do if the count gets too high? I tried some javascript in admin \> customize \> head that reads the user’s count and tries to disable the Reply button if the count is too high, but I can’t come up with a selector term to get the button.

Or maybe there’s a better approach. Any ideas are welcome!

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [January 13, 2025, 2:50am UTC](https://meta.discourse.org/t/limit-the-number-of-ai-tokens-a-user-can-use-in-a-day/330500/5 "2025-01-13T02:50:24Z")

</div>

> [@markschmucker](#):
>
> I kinda need per-user (not per-group) rate limits now

There are technically the same, you just create a group of 1.

This should land this week and solve it:

[https://github.com/discourse/discourse-ai/pull/1047](https://github.com/discourse/discourse-ai/pull/1047)

---

<div class="post-metadata">

### Author: ![markschmucker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markschmucker/32/141599_2.png) [@markschmucker](https://meta.discourse.org/u/markschmucker)
#### Post date: [January 13, 2025, 1:45pm UTC](https://meta.discourse.org/t/limit-the-number-of-ai-tokens-a-user-can-use-in-a-day/330500/6 "2025-01-13T13:45:35Z")

</div>

I understand per-group quotas are are good for managing budget, but what’s to keep one person from hogging all the group’s quota at the beginning of the time period? EDIT: And potentially hogging it for their own unrelated work, like the OP asked?

> [@sam](#):
>
> you just create a group of 1

We have 3000 members. So create 3000 groups? Won’t that wreck /g?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [January 13, 2025, 7:50pm UTC](https://meta.discourse.org/t/limit-the-number-of-ai-tokens-a-user-can-use-in-a-day/330500/7 "2025-01-13T19:50:25Z")

</div>

I am a bit confused about this question, quotas are defined by group now and applied per user

If group is allowed 1000 tokens it means no single user is allowed more than 1000 tokens

Quota is not shared between users, not against adding the concept of absolute quota if we need it later

---

<div class="post-metadata">

### Author: ![markschmucker](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markschmucker/32/141599_2.png) [@markschmucker](https://meta.discourse.org/u/markschmucker)
#### Post date: [January 13, 2025, 9:01pm UTC](https://meta.discourse.org/t/limit-the-number-of-ai-tokens-a-user-can-use-in-a-day/330500/8 "2025-01-13T21:01:45Z")

</div>

Oh. Then I completely misunderstood. The feature says:

> Setting per-group token and usage limits with configurable durations

To me “per-group limits” sounds like the group as a whole has a limit.

So this is exactly what I’m looking for- will wait for the new feature.

---

<div class="post-metadata">

### Author: ![oppman](https://avatars.discourse-cdn.com/v4/letter/o/aca169/32.png) [@oppman](https://meta.discourse.org/u/oppman)
#### Post date: [January 17, 2025, 7:01pm UTC](https://meta.discourse.org/t/limit-the-number-of-ai-tokens-a-user-can-use-in-a-day/330500/10 "2025-01-17T19:01:06Z")

</div>

I’m going to assign this configuration to an intern next Wednesday on a self-hosted Discourse site. Do I need to tell them to pull from a main branch on GitHub? Or, if they add this line in `app.yml`, is it sufficient?

```yaml
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
          ...
          ...
          - git clone https://github.com/discourse/discourse-ai.git 

```

I want to allow the Discourse AI plugin features to only registered users. Is that the default behavior?

It doesn’t look to me that the AI-enhanced search has per-group control???

 ![This image depicts a series of settings and options in an AI interface related to AI embeddings, including model types, semantic search capabilities, and related topics. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/3/a/5/3a5ea3677af4f15a5f3de1c829b996fcf287dbac.png)

For the AI bot, I’m thinking of setting it to trust 0 and setting a limit on tokens per group, increasing as the trust grows. Is this a good strategy?

 ![image](https://global.discourse-cdn.com/meta/original/4X/1/1/7/1172bd15e596bea146096be92f4a95785f9d46a5.png)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [January 20, 2025, 4:39am UTC](https://meta.discourse.org/t/limit-the-number-of-ai-tokens-a-user-can-use-in-a-day/330500/11 "2025-01-20T04:39:02Z")

</div>

This has been merged. I just need to spend some time documenting it.

---

<div class="post-metadata">

### Author: ![oppman](https://avatars.discourse-cdn.com/v4/letter/o/aca169/32.png) [@oppman](https://meta.discourse.org/u/oppman)
#### Post date: [January 22, 2025, 6:33pm UTC](https://meta.discourse.org/t/limit-the-number-of-ai-tokens-a-user-can-use-in-a-day/330500/12 "2025-01-22T18:33:49Z")

</div>

@sam Thank you for your work. The intern set up quotas for each trust level today.

They have not tested it fully yet.

When the group-limit is hit for the day, does the user get a message? Can this message be customized?

I want the AI to be useful, but protect us from abuse. If a person wants to use more AI search, I want to send them a note that they can contact a human to get the limit increased. Staff can then move them into a pre-configured group manually.

In your example, I notice that you’re using amazon nova pro v1. The intern set up our implementation with OpenAI gpt-o4, likely just because of brand recognition.

The intern is still trying to figure out the effectiveness vs costs of different models. Any advice from anyone on the forum would be wonderful.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [April 3, 2025, 6:04am UTC](https://meta.discourse.org/t/limit-the-number-of-ai-tokens-a-user-can-use-in-a-day/330500/13 "2025-04-03T06:04:13Z")

</div>

> [@oppman](#):
>
> When the group-limit is hit for the day, does the user get a message?

Yes this happens now

> [@oppman](#):
>
> Can this message be customized?

Very minimally, we use a translated string so you can amend the translation.

* * *

Closing this one off cause it is complete, feel free to open up new questions about ai!

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [April 3, 2025, 6:04am UTC](https://meta.discourse.org/t/limit-the-number-of-ai-tokens-a-user-can-use-in-a-day/330500/14 "2025-04-03T06:04:15Z")

</div>


