Gradio message limit is there a way?

Hello there! Suppose I have a chat UI created with gradio. Is there a way I can limit the users’ messages they can send to the model(3 per minute for example)?

@freddyaboulton Any solution?

Hi @nbaru,

There isn’t a built-in way to do that. The easiest approach would be to implement user authentication, allowing only signed-in users to run inference. Then, you can easily implement a rate limit. You can try a prototype using user authentication via HF.

Here is how to get user authentication via HF: Gradio LoginButton Docs

A second option is to get users’ IP addresses and implement a rate limit through that. However, this method can be easily bypassed using VPNs or could block many users coming from the same network.

Here is how to get a request IP address: Gradio Request Docs

related response here

Thank you!