Interface AiQuotaService

All Known Implementing Classes:
AiQuotaServiceImpl

public interface AiQuotaService
Usage limits from AiUsagePolicy: the monthly token quota and the request rate limit, each the maximum across the active policies that apply to the user: the global ones, and those listing one of their roles, their group or themselves. Admins (see AiPermissionService.isAiAdmin(com.axelor.auth.db.User)) have neither.

Only user-initiated sources (CHAT, API) are counted; background calls (titles, the subject, session notes, summaries, recaps, embeddings) are excluded per v1 spec.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Throws AiException when the user's chat-panel turns (CHAT) have consumed at least as many tokens as their role-resolved monthly quota.
    Per-user rate limit in requests/second.
    Monthly token budget (inputTokens + outputTokens) for the user.
  • Method Details

    • checkMonthlyTokenQuota

      void checkMonthlyTokenQuota(User user)
      Throws AiException when the user's chat-panel turns (CHAT) have consumed at least as many tokens as their role-resolved monthly quota. Programmatic and background calls never count. Admins and users with no quota set are always permitted.
    • tokenQuotaMonthly

      Integer tokenQuotaMonthly(User user)
      Monthly token budget (inputTokens + outputTokens) for the user. null means unlimited — the case for admins and users no AiUsagePolicy applies to.
    • rateLimit

      Integer rateLimit(User user)
      Per-user rate limit in requests/second. null means no limit — admins, and users no AiUsagePolicy applies to.