I am a student and I want to use the free tier on Gemini, I don’t wanna install a model on my pc. Please, make a rate limiter for requests per second and requests per day. I want to use the features from agno, but i can’t. Agno doesn’t have a internal way to do that on their workflow and teams.
Hey @fmg.programador, Thank you for your question.
Agno doesn’t yet have a built-in way to rate limit requests in Teams or Workflows. But you can wrap your calls with a small limiter. For example:
import time
class RateLimiter:
def __init__(self, rps=1, per_day=100):
self.rps = rps
self.per_day = per_day
self.count, self.last = 0, time.time()
def acquire(self):
if self.count >= self.per_day:
raise Exception("Daily limit reached")
elapsed = time.time() - self.last
if elapsed < 1/self.rps:
time.sleep(1/self.rps - elapsed)
self.last = time.time()
self.count += 1
Then just call:
limiter = RateLimiter(rps=1, per_day=200)
limiter.acquire()
resp = agent.run("your message")
This way you can respect Gemini free tier limits without installing anything locally.
I hope this helps
Thanks, I will try this! Does It work for Teams and workflows? How apply in these cases?
Hey @fmg.programador, As explained above it should work in Team and workflow. It is a python script you can wrap around in any functions. Feel free to use it as you want