{"record":{"id":"c7c297112ba36822","repo":"Mintplex-Labs/anything-llm","slug":"your-quota-for-this-chat-has-been-reached-try-aga","errorCode":null,"errorMessage":"Your quota for this chat has been reached. Try again later or contact the site owner.","messagePattern":"Your quota for this chat has been reached\\. Try again later or contact the site owner\\.","errorType":"http","errorClass":null,"httpStatus":429,"severity":"warning","filePath":"server/utils/middleware/embedMiddleware.js","lineNumber":164,"sourceCode":"        });\n        return;\n      }\n    }\n\n    if (\n      !isNaN(embed.max_chats_per_session) &&\n      Number(embed.max_chats_per_session) > 0\n    ) {\n      const dailySessionCount = await EmbedChats.count({\n        embed_id: embed.id,\n        session_id: sessionId,\n        createdAt: {\n          gte: new Date(new Date() - 24 * 60 * 60 * 1000),\n        },\n      });\n\n      if (dailySessionCount >= Number(embed.max_chats_per_session)) {\n        response.status(429).json({\n          id: uuidv4(),\n          type: \"abort\",\n          textResponse: null,\n          sources: [],\n          close: true,\n          error:\n            \"Your quota for this chat has been reached. Try again later or contact the site owner.\",\n        });\n        return;\n      }\n    }\n\n    next();\n  } catch {\n    response.status(500).json({\n      id: uuidv4(),\n      type: \"abort\",\n      textResponse: null,","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/middleware/embedMiddleware.js#L146-L182","documentation":"Per-session quota enforcement inside canRespond: when max_chats_per_session > 0 and the count of EmbedChats rows for that embed AND that sessionId within the last 24 hours has reached it, the request gets HTTP 429 with abort payload 'Your quota for this chat has been reached. Try again later or contact the site owner.'. Unlike the daily cap this is per visitor session, so one heavy user cannot be unblocked by other users' inactivity.","triggerScenarios":"A single visitor (one sessionId) sends more messages than max_chats_per_session within 24h; every subsequent message from that session 429s while other sessions still work.","commonSituations":"Aggressive per-session caps (e.g. 5) set to control LLM spend; automated visitors looping on one session; widget 'new chat' button not generating a fresh sessionId so the visitor stays on a exhausted session.","solutions":["Raise or clear max_chats_per_session on the embed config (blank/0 disables it)","Start a new session: generate a new UUID sessionId — the quota is keyed to the session, so a fresh id gets a fresh budget","Otherwise wait until that session's chats age out of the rolling 24h window"],"exampleFix":"// before: widget keeps one hardcoded sessionId forever\nconst sessionId = '00000000-0000-0000-0000-000000000000';\n\n// after: 'New chat' button issues a fresh session\nfunction newChat() { sessionId = crypto.randomUUID(); }","handlingStrategy":"retry","validationCode":"// widget: offer an escape hatch before the cap bites\nif (messagesThisSession >= knownSessionCap) offerNewChat(); // new crypto.randomUUID() resets quota","typeGuard":null,"tryCatchPattern":"if (res.status === 429) {\n  const data = await res.json();\n  if (/quota for this chat/.test(data.error ?? '')) {\n    sessionId = crypto.randomUUID(); // fresh session = fresh per-session quota\n    retryOnceWithNewSession(message);\n  }\n}","preventionTips":["Wire the widget's 'New chat' action to generate a fresh session UUID","Size max_chats_per_session generously enough for real conversations","Track message count per session client-side to warn before the cap"],"tags":["embed","rate-limit","quota","session","http-429"],"backgroundTag":"rate-limit-exceeded","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}