Changing ratelimit
This commit is contained in:
@@ -35,7 +35,7 @@ npm run keys:env
|
||||
|
||||
The global context limit defaults to 256k tokens and can be changed with `MAX_CONTEXT_TOKENS`.
|
||||
|
||||
Inference requests are limited per client IP to 2 requests per second, 100 requests per five hours, and $10 of reported upstream cost per five hours. Railway's `X-Real-IP` header is used to identify clients.
|
||||
Inference requests are limited per client IP to 2 requests per second, 100 requests per five hours, and $15 of reported upstream cost per five hours. Railway's `X-Real-IP` header is used to identify clients.
|
||||
|
||||
To exempt trusted clients from those proxy limits, set `UNLIMITED_API_KEYS` to a JSON array and have the client send a configured key using `Authorization: Bearer <key>` or `x-api-key`. These keys only bypass this proxy's rate and spend limits; they do not bypass upstream OpenCode Go limits.
|
||||
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ const FIVE_HOURS = 5 * 60 * 60 * 1_000;
|
||||
export const RATE_LIMITS = {
|
||||
requestsPerSecond: 2,
|
||||
requestsPerFiveHours: 100,
|
||||
spendPerFiveHours: 10,
|
||||
spendPerFiveHours: 15,
|
||||
};
|
||||
|
||||
function prune(timestamps, now, window) {
|
||||
|
||||
@@ -10,7 +10,7 @@ describe('rate limiter', () => {
|
||||
expect(limiter.check('ip').allowed).toBe(false);
|
||||
time = 1_001;
|
||||
expect(limiter.check('ip').allowed).toBe(true);
|
||||
limiter.recordCost('ip', 10);
|
||||
limiter.recordCost('ip', 15);
|
||||
expect(limiter.check('ip').allowed).toBe(false);
|
||||
time = 5 * 60 * 60 * 1_000 + 1_002;
|
||||
expect(limiter.check('ip').allowed).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user