API referenceRate limits

Rate limits

Rate limiting needs Redis (MNEMO_REDIS_URL). Without it no limits are enforced. The Docker stack sets it by default.

Budgets

Each API key gets one token bucket per operation class. These are the base budgets, which apply to a key on the free plan:

Operation classMatchesLimitBurst
recallPaths starting with /recall, and /session/{id}/collapse600 / minute50
writeOther POST, PATCH, PUT, DELETE120 / minute20
turnPOST /session/{id}/turn600 / minute100
exportPaths starting with /export or /admin/export10 / day
adminOther paths starting with /admin30 / minute
federationPaths starting with /federation or /memory/federation60 / minute
otherEverything else (reads)600 / minute

Where no burst is listed, the bucket holds the full budget of its window.

A key’s plan scales every budget: pro is 10 times the base and enterprise is 100 times. The plan is set when the key is created.

There is also a concurrency cap per key: 10 requests in flight on free, 25 on pro, 100 on enterprise.

The budgets are constants in packages/server/src/ratelimit.ts. There is no environment variable or database column to change them.

Response headers

When the limiter is active, responses carry:

X-RateLimit-Limit:              10
X-RateLimit-Remaining:          49
X-RateLimit-Reset:              1
Mnemosyne-Rate-Limit-Operation: recall
  • X-RateLimit-Limit is the sustained rate in requests per second for the class (the daily cap for export).
  • X-RateLimit-Reset is the number of seconds until a token is available, not a Unix timestamp.

A 429 adds:

Retry-After:                   1
Mnemosyne-Rate-Limited-Reason: request_rate

The reason is request_rate or concurrency (fleet_shed on a 503, see below). The error body carries the same wait in retryAfterSeconds. See Error codes.

Load shedding

The server also watches the share of Postgres max_connections busy across the cluster, read every 2 seconds. When it reaches a class’s threshold, a request answers 503 with code fleet_shed, Retry-After: 5 and Mnemosyne-Rate-Limited-Reason: fleet_shed. The threshold is 70% for export, admin and federation, and 85% for every other class except recall, which is never shed. Without a database the reading stays 0.

Fail-open behaviour

If Redis is configured but unreachable, the limiter fails open: requests are allowed and a warning is logged.