Add configurable per-user rate limiting for concurrent requests #1

Open
opened 2026-07-25 22:40:46 +02:00 by goeranh · 0 comments
Owner

Problem

There is currently no rate limiting on API requests. The router should support configurable per-user rate limiting.

Requirements

  • Not rate-limited by default: By default, no rate limits should be applied.
  • Configurable per user: Rate limits are set per user account, not per API key. All API keys belonging to the same user share the same rate limit.
  • Concurrent request limit: Support limiting the number of concurrent requests a user can have active (e.g. 1, 2, 3, etc.).
  • Stored in database: Rate limit configuration should be stored in PostgreSQL alongside the user metadata, and queried during request routing.

Key Behaviour

  • A user's max_concurrent_requests applies to all their API keys combined.
  • If a user has 3 API keys and a limit of 2 concurrent requests, those 3 keys together may only have 2 requests active at any time.
  • The router resolves the active user from each request's API key, then checks the user's aggregate concurrent request count.

Acceptance Criteria

  • Users can have a max_concurrent_requests field (default: unlimited)
  • Router enforces concurrent request limit per user across all their API keys
  • Requests exceeding the limit are rejected with 429 Too Many Requests
  • Rate limit settings can be managed via the llm-keys CLI tool
## Problem There is currently no rate limiting on API requests. The router should support configurable per-user rate limiting. ## Requirements - **Not rate-limited by default**: By default, no rate limits should be applied. - **Configurable per user**: Rate limits are set per user account, not per API key. All API keys belonging to the same user share the same rate limit. - **Concurrent request limit**: Support limiting the number of concurrent requests a user can have active (e.g. 1, 2, 3, etc.). - **Stored in database**: Rate limit configuration should be stored in PostgreSQL alongside the user metadata, and queried during request routing. ## Key Behaviour - A user's `max_concurrent_requests` applies to **all** their API keys combined. - If a user has 3 API keys and a limit of 2 concurrent requests, those 3 keys together may only have 2 requests active at any time. - The router resolves the active user from each request's API key, then checks the user's aggregate concurrent request count. ## Acceptance Criteria - [ ] Users can have a `max_concurrent_requests` field (default: unlimited) - [ ] Router enforces concurrent request limit per user across all their API keys - [ ] Requests exceeding the limit are rejected with 429 Too Many Requests - [ ] Rate limit settings can be managed via the `llm-keys` CLI tool
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
goeranh/aiserver#1
No description provided.