Watch: Stop one user from spamming my AI feature | Vovy
Watch Vovy do it on a Mac: "Limit each user to 20 AI requests an hour so nobody can drain my credits". Add a per-user rate limit to your AI endpoint with Upstash Redis, show a friendly message when it is hit, and protect your AI budget.
"Limit each user to 20 AI requests an hour so nobody can drain my credits"
Add a per-user rate limit to your AI endpoint with Upstash Redis, show a friendly message when it is hit, and protect your AI budget.
What happens in the video
- Create an Upstash Redis database: Vovy opens Upstash, creates a Redis database near your server, and saves the REST URL and token as secrets.
- Add the rate limiter: Vovy asks Claude Code to add @upstash/ratelimit with a sliding window, like 20 requests per hour, keyed by user ID.
- Check before calling the AI: Claude Code makes your AI endpoint check the limit first and return a 429 status with the reset time when a user is over.
- Show a friendly message: Claude Code updates the UI to say how many requests are left and when they reset, instead of a generic error.
- Test and deploy: Vovy fires 25 test requests to prove the 21st is blocked, then deploys once you approve.
Read the step-by-step guideLoading...