Skip to content

Add a Day variant to PolicyWindow so team-scoped token quotas can be expressed per day #771

Description

@janiussyafiq

Description

RateLimitPolicy — the only surface that can target a team, member, or team_member — has PolicyWindow = Second | Minute | Hour, with no Day. RateLimit, which does support tpd, attaches only to ApiKey and Model, never to a team.

The result: a per-day token quota works fine on a key or a model, but cannot be expressed for a team at all.

The counters already exist end to end — token_dims, KeyState, and both Redis Lua scripts all handle tpd — so the change is:

  • add a Day variant to PolicyWindow;
  • add the match arm in policy_to_rate_limit;
  • relax the control plane's validateRateLimitWindowTokens allowlist from {minute} to {minute, day}.

It does alter a published API surface (openapi/cp-admin.yaml) and needs a spec regen.

Scope note: per-second and per-hour token caps are deliberately excluded here — those are #396, which has a documented correctness reason for deferral and a genuinely different counter strategy. This issue is only the cheap, already-supported Day window.

Why

Daily is the period operators budget tokens in, and the team is the subject they budget for — so the one combination that cannot be configured is the one most often asked for.

A per-day team USD cap is expressible today via budgets (scope=team, period=day), which may cover the intent in some cases, but spend is not tokens.

Priority

Low — consistency fix, small and self-contained.


Prior art

Product Has it Reference
LiteLLM Partial team tpm_limit is per-minute only; budget_duration is USD
Portkey Yes workspace limits, type = cost or tokens, custom reset
TrueFoundry Yes tokens_per_day × team: subjects
Kong AI Gateway Partial token windows, but not team-scoped per-day
Envoy AI Gateway Partial token cost, not team × day
Bifrost Partial team budgets are USD; token limits below team
Cloudflare AI Gateway No request-denominated only

TrueFoundry and Portkey express token × team × day directly; LiteLLM cannot.

Surveyed 2026-07-15; every claim rests on a fetched docs/source page.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions