Skip to main content
LibreChat is joining ClickHouse to power the open-source Agentic Data Stack 🎉 Learn more
LibreChat

Automated Moderation

Rate limits and violation scores that slow down abuse and temporarily ban accounts and IPs that keep tripping them.

LibreChat watches for abusive patterns, such as hammering the login form, sending messages faster than allowed, or calling the API from a script, and records each one as a violation against the user. When a user's violation score crosses a threshold, the account and its IP are banned for a while. It is meant to stop one or a few bad actors, not a flood of traffic; put a reverse proxy or DDoS protection such as Cloudflare in front of a public instance for that.

What counts as a violation

Most violations come from rate limits. When a request goes over a limit it is rejected with a "too many requests" style error, and the attempt adds to the user's score. The limits cover:

  • Logins and registrations, per IP. Too many failed sign-ins shows "Too many login attempts in a short amount of time."
  • Messages: how many responses one user can have running at once ("Only one message can run at a time"), and how many messages can be sent per minute, per IP and optionally per user.
  • Password reset and email verification requests, and the link submissions that follow them.
  • Two-factor code attempts and passkey enrollment.
  • Conversation imports (100 per IP and 50 per user every 15 minutes), forks (30 per IP and 7 per user each minute), and shared link views, each limited per IP and per user at the same time.
  • File uploads, text-to-speech, speech-to-text, and tool calls.

A few things are violations without any rate limit involved: requests that do not come from a browser, requests for a model the endpoint does not offer (almost always a script probing the server), and attempts to open a conversation the user does not own.

Each violation type has its own score. Non-browser requests count heavily by default, and some types are set to 0 in the example .env, so they are blocked when they go over the limit but do not move the user toward a ban.

Bans

A ban triggers each time a user's total score reaches another multiple of the ban interval (20 by default). The user's sessions are ended immediately, and both the account and the IP it came from are locked out for the ban duration (2 hours by default). A banned user sees "Your account is temporarily banned for violating the terms of service." Bans expire on their own. Scores decay too: a user's score resets after an hour without new violations by default, and each new violation restarts that hour.

To lift a ban early, an admin removes its entry from the logs collection in MongoDB. Violation scores and a per-user history of each violation are kept in data/violations.json and data/logs.json in the LibreChat directory (scores go to Redis instead when Redis is enabled, so every replica sees the same score; bans stay in MongoDB either way), which is the place to look when you want to know why someone got banned.

Message moderation

Separately from the scoring system, an admin can send chat messages through the OpenAI moderation API before they reach the model. This covers regular chats and agents, not the hosted Assistants endpoints. Flagged messages are not sent, and the user sees "This message was flagged by the moderation system."

Setup

Rate limiting and banning are on by default with the values above. An admin tunes every limit, score, and the ban settings through environment variables, and turns on OpenAI moderation the same way; see Automated Moderation configuration. Limits for uploads, speech, and conversation imports can also be set in the rateLimits block of librechat.yaml.

How is this guide?