Changing ratelimit

This commit is contained in:
2026-07-21 15:51:16 -05:00
parent a1f2f13b1d
commit 571f3e9fd8
3 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ npm run keys:env
The global context limit defaults to 256k tokens and can be changed with `MAX_CONTEXT_TOKENS`. 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. 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
View File
@@ -4,7 +4,7 @@ const FIVE_HOURS = 5 * 60 * 60 * 1_000;
export const RATE_LIMITS = { export const RATE_LIMITS = {
requestsPerSecond: 2, requestsPerSecond: 2,
requestsPerFiveHours: 100, requestsPerFiveHours: 100,
spendPerFiveHours: 10, spendPerFiveHours: 15,
}; };
function prune(timestamps, now, window) { function prune(timestamps, now, window) {
+1 -1
View File
@@ -10,7 +10,7 @@ describe('rate limiter', () => {
expect(limiter.check('ip').allowed).toBe(false); expect(limiter.check('ip').allowed).toBe(false);
time = 1_001; time = 1_001;
expect(limiter.check('ip').allowed).toBe(true); expect(limiter.check('ip').allowed).toBe(true);
limiter.recordCost('ip', 10); limiter.recordCost('ip', 15);
expect(limiter.check('ip').allowed).toBe(false); expect(limiter.check('ip').allowed).toBe(false);
time = 5 * 60 * 60 * 1_000 + 1_002; time = 5 * 60 * 60 * 1_000 + 1_002;
expect(limiter.check('ip').allowed).toBe(true); expect(limiter.check('ip').allowed).toBe(true);